[code-quality] A couple pylint feature requests

Skip Montanaro skip.montanaro at gmail.com
Wed Jan 10 09:24:45 EST 2018


As I work through code, especially while refactoring, I wish pylint
was at times more stringent about lack of use of certain types of
objects. At the moment, I'm thinking of two scenarios, main programs
and private attributes.

There's a clear difference between a program and a module, the main
one being that a module "exports" its module-level symbols, while a
main program doesn't (at least if it isn't intended to also serve as a
module). It would be nice if there was a pylint checker which
indicated for main programs module-level symbols which aren't used
somewhere within that file. It might be off by default, but be enabled
if you passed a --main flag on the command line, or if the the usual
"if __name__" dance was found at the bottom of the file.

In a similar fashion, I think it would be useful if private attributes
(typically functions or methods, but also data attributes) were called
out in any environment where they were defined but not used. It's
considered bad practice to reach into an object and reference private
attributes. Conversely, if a private attribute isn't "exported," it
should almost certainly be used with that namespace.

Skip


More information about the code-quality mailing list