I have started a critical review of the code. Here are preliminary remarks. I focused on the
__init__ methods but it is likely that the same remarks may apply to others.
There remains many Python 2 class definitions (where they inherit from
This is quite easy to fix, but it is spread out all over the source tree
Since there is no variable declaration per se in Python, many classes do “neutral” initialisation (i.e. to 0, empty or None) in their
__init__method as a way to advertise variables created in this class. Approximately as many classes don’t follow this rule and simply set their local variables when needed, which is enough to create a variable in the local scope.
What is the Gramps recommended style? Using the
__init__as a declaration reminder or making profit of Python relaxed rules?
Many derived classes are only “specialisation” of a base class, differing only on some methods (frequently to apply default or ad hoc value to some arguments of the base class). I noticed that even if their
__init__method is strictly identical to the base class, the
__init__method is written again (duplicating the original).
Is thera a documentary interest in duplicating the method vs. inheriting it from the base class?
Instance initialisation adding to base class
Frequently subclasses add to base class definition (extra variables and methods). To guarantee error-free consistency, base class
__init__is requested before adding specific variables. Present coding is principally written as
baseclass.__init__(self, …), much less frequently
super().__init__(…). This is not consistent.
super()has the advantage of being immune to inheritance changes but doesn’t hint to the actual inheritance (forcing to scroll back to read it).
What is the Gramps recommended style?
There are occurrences where variables are initialised before the
__init__call(s), resulting in the potential risk that variable initialisation is replaced by some initialisation in the parent class.
__init__calls be grouped first before any subclass initialisation is done?
Multiple inheritance classes
__init__methods to base classes are explicitly called one after another as
baseclass_i.__init__(self,…). Would it be worth to transform the base classes into “super()-cooperative” classes so that all this initialisation reduces to
super().__init(…)in a more concise coding, although less “documenting” but immune to class modification?
What is the Gramps policy regarding code concision vs. intuitively understood coding?