Pylint false positives
Frank Millman
frank at chagford.com
Fri Aug 17 03:46:01 EDT 2018
"Steven D'Aprano" wrote in message news:pl5qbk$r7k$5 at blaine.gmane.org...
>
> On Fri, 17 Aug 2018 08:14:02 +0200, Frank Millman wrote:
>
> > I find that using a separate method per subclass does exactly what I
> > want, and that part of my project has been working stably for some time.
>
> You might consider using single dispatch instead:
>
> https://docs.python.org/3/library/functools.html#functools.singledispatch
>
Thanks. I had a quick look, but I could not see an immediate improvement
over my current setup.
I just did a quick inventory of my Field class, which is an abstract class.
I have 13 datatypes, therefore 13 subclasses. I have 26 methods which are
common to all subclasses, so they are defined on the Field class.
Each subclass has between 5 and 10 methods declared on that subclass. Some
of them do not exist on the Field class, as they are all different. Some of
them do exist on the Field class, as only some of the subclasses require an
override, the rest can use the generic method.
This arrangement has evolved over time, but has now settled down and is
stable.
It is just a slight annoyance (to me) that pylint complains about the
subclass methods when they are called from the Field class. I don't mind
adding 10 stub methods to the Field class to keep it happy, but I do not get
the feeling that it is improving my code. I do grant, however, that it may
be of benefit to someone reading my code for the first time.
Frank
More information about the Python-list
mailing list