Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pylint ignores disable=invalid-name under certain conditions #9861

Open
ya3xp opened this issue Aug 8, 2024 · 0 comments
Open

Pylint ignores disable=invalid-name under certain conditions #9861

ya3xp opened this issue Aug 8, 2024 · 0 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@ya3xp
Copy link

ya3xp commented Aug 8, 2024

Bug description

Consider following structure:

|_ mymodule
   |_ __init__.py
   |_ example.py
   |_ myclasses.py

Where __init__.py is empty.

myclasses.py contains:

class ClassA:
    badClassVariable = 0

And example.py contains:

from mymodule.myclasses import ClassA

class ClassB:
    badClassVariable = 0

example_a = ClassA()
example_a.badClassVariable = 1  # pylint: disable=invalid-name

example_b = ClassB()
example_b.badClassVariable = 1  # pylint: disable=invalid-name

badVariable = 1  # pylint: disable=invalid-name

Pylint will flag example_a.badClassVariable on line 7 despite disable=invalid-name.

Pylint will honor disable=invalid-name on lines 10 and 12 and will not flag example_b.badClassVariable nor badVariable.

Configuration

No response

Command used

pylint --disable=all --enable=C0103 mymodule

Pylint output

************* Module mymodule.example
mymodule/example.py:7:0: C0103: Attribute name "badClassVariable" doesn't conform to snake_case naming style (invalid-name)

Expected behavior

Pylint should not report an issue for line 7, as it already does for lines 10 and 12.

Pylint version

pylint 3.2.6
astroid 3.2.4
Python 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)]
pylintbug-py3.12

OS / Environment

Issue occurred on both MacOS 14.6.1 and containereized Alpine linux 3.18.

Additional dependencies

dill==0.3.8
isort==5.13.2
mccabe==0.7.0
platformdirs==4.2.2
tomlkit==0.13.0
@ya3xp ya3xp added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

1 participant