pylint
pylint copied to clipboard
Can't disable "invalid-name" error for module name
Steps to reproduce
- Create an empty Python file called
run-tests.py - At the top of the file, add
# pylint: disable=invalid-nameso that pylint won't complain about the module name - Pylint complains anyway
Current behavior
Explained above
Expected behavior
Pylint should not complain about the module name. Yes I realize I can disable the rule entirely in the config file, but 99% of the time I want the rule enforced. The exception is when I'm writing Python scripts (rather than modules), in which case I prefer the dashed naming style, as in run-tests.py.
pylint --version output
pylint 2.6.0
astroid 2.4.2
Python 3.8.6 (default, Oct 29 2020, 08:08:02)
[GCC 9.3.0]
@Hubro thanks for your report. I can reproduce it.
Similar to #516 but this regressed as in #516 we're talking about being able to disable but not having to do that if there's a sheband and it's a script.
I added a regression test for this.
This actually works but the file can't only have a disable comment due to the way we parse such comments. As soon as there is more than only a disable comment this works as expected on the current version 😄