Skip to content

Refactor the PR class.

Created by: smarnach

An (incomplete) suggestion on how to refactor the PR class.

The new version keeps all data retrieved from Github around, and implements most attributes as properties that simply do a lookup in this data dictionary. The extra_settings which are more expensive to retrieve are cached in read-only attributes. A method update_data() allows to update all fields from Github, and makes sure everything is kept in sync.

The repetitiveness of the code can easily be reduced by storing a mapping of property names to paths in the data dict. This structure would allow to easily add new properties, like the base branch (the branch targetted by the PR) or the timestamp of the last update.

(I'm also not sure we really need to hide extra_settings and extra_settings_dict behind read-only attributes. I usually wouldn't do this, since I dislike code doing nothing.)

Merge request reports