Indexing a Type Alias of an Enum yields false error #7568
Labels
bug
mypy got something wrong
false-positive
mypy gave an error on correct code
priority-2-low
topic-enum
topic-metaclasses
Minimum [not-]working product:
Ah, good old Enums:
I'm fairly certain this is not an intentional design choice. Just to be sure, according to documentation:
Now, Enums actually can't be generic, so I certainly expect the alias to be equivalent. So I think this code should pass (regardless of its usefulness... who wants to alias an Enum anyways?).
Possible Causes
I'm no expert, but I think this is happening because the semantic analyzer deems any
IndexExpr
aTypeApplication
if it has aTypeAlias
as a base. Once it's marked as analyzed, it doesn't reach the stage of the expression checker where the Enum type would be recognized and the indexing processed as valid. Whatever the root of the problem, I think there's only one spot where the expression checker actually looks atis_enum
to handle Enum indexing, so the alias isn't making it there one way or another.The text was updated successfully, but these errors were encountered: