3 ms·
Are you not in the module's global scope? If you are pylint is right and you wrong, you need to move this line inside a function or a class. There should be no
by gbog 10y ago
Are you not in the module's global scope? If you are pylint is right and you wrong, you need to move this line inside a function or a class. There should be no code running at module level. Here you might argue that this is akin to a decorator, and that bar will not be called, so yes it is a corner case, but the main rule (only allow consts at module level) is still useful, and I'd say vital even.
- emidln 10y agoThis is not 'akin to a decorator', it's is partial function! Do you name your functions: def THIS_IS_IN_GLOBAL_SCOPE(): ... Of course you don't! Then why would you consider forcing someone to write this: def bar(spam, eggs): print spam, eggs def foo(eggs): return bar('baz', eggs) Which even manages to lose information, hence why functools.partial exists in the first place. This is bad because readers now see FOO and think it's a constant: FOO = functools.partial(bar, 'baz')