On Thu, Mar 22, 2018 at 4:23 PM, Alexander Todorov <atodo...@mrsenko.com> wrote: > Hi folks, > I've just noticed that a legacy piece of code I'm working with contains the > following pattern: > > class SomeClass(object): > __all__ = ['add', 'delete'] > > def __init__(self): > pass > > def get(self): > pass > > def add(self, x): > pass > > def delete(self, x): > pass > > > And the caller of this class actually uses the .get() method. I have this in > at least 10 different places. > > I wasn't able to find any information about __all__ having any special > meaning when defined inside a class so this looks like a mistake. > > Q1: Do we want pylint to warn about __all__ being detected not at module > level ? > > Q2: Do we want another check to warn about class attributes staring with > single/double underscore ? > > -- > Alex
Hi Alex, Regarding Q1: Maybe? It's not entirely clear based on your brief example what the original author though __all__ did here. Regarding Q2: Why would you want to prohibit class attributes starting with single or double underscores? The former is useful for "private" class attributes. The latter performs name mangling which can be useful in situations (see: https://stackoverflow.com/a/1301369/1953283). I don't think pylint should be warning in this case. Cheers, Ian _______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality