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

invalid-name false positive on assignment to class attribute tearDown #9765

Closed
oprypin opened this issue Jul 3, 2024 · 1 comment · Fixed by #9772
Closed

invalid-name false positive on assignment to class attribute tearDown #9765

oprypin opened this issue Jul 3, 2024 · 1 comment · Fixed by #9772
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation Regression
Milestone

Comments

@oprypin
Copy link

oprypin commented Jul 3, 2024

Bug description

"""hi"""
import unittest

class BaseCase(unittest.TestCase):
    """hi"""
    def tearDown(self):
        pass

class SubCase(unittest.TestCase):
    """hi"""
    tearDown = BaseCase.tearDown  # [invalid-name] - false positive!

Configuration

[BASIC]
# https://github.com/google/styleguide/blob/1ae7350b45445b3a3a289c5fe756ab7c80014fe5/pylintrc#L191
class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$

Command used

/tmp/pylint/venv/bin/pylint test.py

Pylint output

************* Module test
test.py:11:4: C0103: Class attribute name "tearDown" doesn't conform to '^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$' pattern (invalid-name)

------------------------------------------------------------------
Your code has been rated at 8.33/10 (previous run: 8.33/10, +0.00)

Expected behavior


--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

In the past, pylint had this behavior - it did not complain about invalid-name here.

a4aff97 is the first bad commit

Pylint version

pylint 3.3.0-dev0
astroid 3.2.2
Python 3.11.8 (main, May 26 2024, 00:40:16) [GCC 13.2.0]

OS / Environment

No response

Additional dependencies

No response

@oprypin oprypin added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jul 3, 2024
@jacobtylerwalls
Copy link
Member

Thanks for the bisect!

@jacobtylerwalls jacobtylerwalls added Regression False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jul 7, 2024
@jacobtylerwalls jacobtylerwalls self-assigned this Jul 7, 2024
@jacobtylerwalls jacobtylerwalls added this to the 3.2.6 milestone Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation Regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants