ruff
b81d55ed - [ty] Ignore `_generate_next_value_` with custom construction hooks (#25210)

Commit
55 days ago
[ty] Ignore `_generate_next_value_` with custom construction hooks (#25210) ## Summary One oversight in my changes to https://github.com/astral-sh/ruff/pull/25196: if a custom `__new__` is defined, we should treat the alias value as `Any`, rather than relying on `_generate_next_value_`. This matches Pyright, for example. E.g., given: ```python class E(Enum): @staticmethod def _generate_next_value_(...) -> Literal["x"]: return "x" def __new__(cls, value: str): obj = object.__new__(cls) obj._value_ = object() return obj A = auto() B = auto() ``` Prior to this change, we treated `B` as an alias of `A`; but if `__new__` is defined, we don't attempt to detect the alias.
Author
Parents
Loading