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

False positives on enum _name_ and _value_ attributes #305

Closed
eltoder opened this issue Feb 24, 2023 · 2 comments · Fixed by #306
Closed

False positives on enum _name_ and _value_ attributes #305

eltoder opened this issue Feb 24, 2023 · 2 comments · Fixed by #306

Comments

@eltoder
Copy link
Contributor

eltoder commented Feb 24, 2023

from enum import Enum

class E(Enum):
    A = ('a', 1)
    B = ('b', 2)

    def __init__(self, name, value):
        self._name_ = name
        self._value_ = value

E.A, E.B

Here vulture says that attributes _name_ and _value_ are unused:

$ python -m vulture enum_sunder.py
enum_sunder.py:8: unused attribute '_name_' (60% confidence)
enum_sunder.py:9: unused attribute '_value_' (60% confidence)

These are special attributes used to set enum members' name and value respectively. They should be whitelisted.

@jendrikseipp
Copy link
Owner

Thanks for the report! I agree that these names should be whitelisted. Do you want to add an enum_whitelist.py file here and make a pull request?

eltoder added a commit to eltoder/vulture that referenced this issue Feb 25, 2023
eltoder added a commit to eltoder/vulture that referenced this issue Feb 25, 2023
@eltoder
Copy link
Contributor Author

eltoder commented Feb 25, 2023

@jendrikseipp Here you go. I didn't find any tests for whitelists, so no tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants