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

Using auto enum values provides incorrect type #1847

Open
jasperswallen opened this issue Oct 24, 2022 · 0 comments
Open

Using auto enum values provides incorrect type #1847

jasperswallen opened this issue Oct 24, 2022 · 0 comments
Labels
Brain 🧠 Needs a brain tip

Comments

@jasperswallen
Copy link

import enum


class EnumWithAuto(enum.IntEnum):
    A = enum.auto()
    B = 10


auto_enum = EnumWithAuto.A
print(auto_enum.value.bit_length())  # E1101: Instance of 'auto' has no 'bit_length' member (no-member)

enum_val = EnumWithAuto(123)
print(enum_val.value.bit_length())  # Fine

specific_enum = EnumWithAuto.B
print(specific_enum.value.bit_length())  # Fine

All three of these EnumWithAuto.value should return an int, but only the B and __init__(123) instances do. A (since it uses enum.auto()) seems to return a type of auto, but that should be an int, since this uses an IntEnum.

@Pierre-Sassoulas Pierre-Sassoulas added the Brain 🧠 Needs a brain tip label Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Brain 🧠 Needs a brain tip
Projects
None yet
Development

No branches or pull requests

2 participants