[code-quality] __all__ defined inside a class

Steven D'Aprano steve at pearwood.info
Fri Mar 23 01:00:28 EDT 2018


On Thu, Mar 22, 2018 at 08:30:44PM -0500, Ian Stapleton Cordasco wrote:

> 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.

But __all__ is a dunder name, and dunders are reserved for use by 
Python.

I don't know what the author of the class thought they were doing, but 
they shouldn't have been using __all__ for it, hence the idea of a 
warning. But it probably isn't practical to keep a white list of 
permitted dunders and warn about those that any others.


-- 
Steve


More information about the code-quality mailing list