pylint #81380 Suggested rule: Warn if single underscores used around special method names [open]
In Python, classes can override a number of different default behaviours by defining special methods - e.g. __init__, __ge__, __copy__. Other attributes are defined for you - e.g. __doc__.
It is an easy (and not uncommon) mistake to only use a single underscore rather than two underscore around these method names. Once made, it is difficult to spot - especially if your font makes two unscores appear as one wide one.
I recently fell for this mistake again by calling a method _ge_ rather than __ge__. Unfortunately, by sheer bloody-minded coincidence, the arbitrary built-in greater-than-or-equal operator consistently passed all unit tests.
I suggest that a warning be created if a method or attribute is used that would be a special attribute if it had the right number of underscores, but doesn't.
I would recommend matching any of these examples:
|appeared in||<not specified>|
|done in||<not specified>|
|closed by||<not specified>|