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 complains about _ignore_ in enum classes #9015

Closed
Hawk777 opened this issue Sep 7, 2023 · 1 comment · Fixed by pylint-dev/astroid#2289 or pylint-dev/astroid#2303
Closed
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable
Milestone

Comments

@Hawk777
Copy link

Hawk777 commented Sep 7, 2023

Bug description

A field called _ignore_ in an enum class should not cause an invalid-name complaint. It is a special field whose name is dictated by the standard library and cannot be changed.

Consider the following code:

import enum


class MyEnum(enum.Enum):
    FOO = enum.auto()
    BAR = enum.auto()
    _ignore_ = ["BAZ"]
    BAZ = 42

Configuration

No configuration file needed.

Command used

pylint test.py

Pylint output

************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:4:0: C0115: Missing class docstring (missing-class-docstring)
test.py:7:4: C0103: Class constant name "_ignore_" doesn't conform to UPPER_CASE naming style (invalid-name)

------------------------------------------------------------------
Your code has been rated at 5.00/10 (previous run: 3.33/10, +1.67)

Expected behavior

The invalid-name error should not appear.

Pylint version

pylint 2.17.5
astroid 2.15.6
Python 3.11.5 (main, Aug 29 2023, 19:39:22) [GCC 12.3.1 20230526]

OS / Environment

No response

Additional dependencies

No response

@Hawk777 Hawk777 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Sep 7, 2023
@mbyrnepr2 mbyrnepr2 added Astroid Related to astroid False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 7, 2023
mbyrnepr2 added a commit to mbyrnepr2/astroid that referenced this issue Sep 7, 2023
@mbyrnepr2 mbyrnepr2 added Needs astroid update Needs an astroid update (probably a release too) before being mergable and removed Astroid Related to astroid labels Sep 7, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.17.6 milestone Sep 11, 2023
Pierre-Sassoulas pushed a commit to pylint-dev/astroid that referenced this issue Sep 12, 2023
#2289)


Refs pylint-dev/pylint#9015

* Fix a false positive for ``no-member`` when accessing the ``_name_`` and ``_value_`` sunders of an Enum member value.

Refs pylint-dev/pylint#7402
@Pierre-Sassoulas
Copy link
Member

Will need an astroid update to be effective.

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 astroid update Needs an astroid update (probably a release too) before being mergable
Projects
None yet
4 participants