Skip to content

Pylint complains about _ignore_ in enum classes #9015

Closed
@Hawk777

Description

@Hawk777

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds astroid updateNeeds an astroid update (probably a release too) before being mergable

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions