pylint woes

Peter Otten __peter__ at web.de
Sun May 8 10:12:20 EDT 2016


Chris Angelico wrote:

> On Sun, May 8, 2016 at 1:28 PM, DFS <nospam at dfs.com> wrote:
>> Invalid constant name "cityzip" (invalid-name)
>> Invalid constant name "state" (invalid-name)
>> Invalid constant name "miles" (invalid-name)
>> Invalid constant name "store" (invalid-name)
>> Invalid variable name "rs" (invalid-name)
> 
> ... huh?? The first four seem to have been incorrectly detected as
> constants. How are they used?

As globals. pylint doesn't like it when you put your normal code outside a 
function, and I agree with the general idea. The problem is that it's not 
smart enough to recognize the exceptions like

plus_one = make_adder(1)

where plus_one obeys the naming convention for a function, but the linter 
asks you to change the line to

PLUS_ONE = make_adder(1)

In

Row = collections.namedtuple("Row", "alpha beta")

though pylint does recognize that collections.namedtuple() produces a class,
so there might also be a way to teach it how to handle the custom factory.

The OP should of course put the whole shebang into a main() function. That 
also simplifies it to determine which values should be passed as arguments 
when he breaks his blob into smaller parts.




More information about the Python-list mailing list