pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Can't disable "invalid-name" error for module name

Open Hubro opened this issue 4 years ago • 2 comments

Steps to reproduce

  1. Create an empty Python file called run-tests.py
  2. At the top of the file, add # pylint: disable=invalid-name so that pylint won't complain about the module name
  3. 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 avatar Dec 08 '20 16:12 Hubro

@Hubro thanks for your report. I can reproduce it.

hippo91 avatar Dec 08 '20 20:12 hippo91

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.

Pierre-Sassoulas avatar Sep 27 '21 17:09 Pierre-Sassoulas

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 😄

DanielNoord avatar Sep 04 '22 13:09 DanielNoord