Describe the bug
Treat Literal of all members of an enum the same way as the annotation of just that enum.
Code or Screenshots
https://discuss.python.org/t/treat-literal-of-all-elements-of-enum-equal-to-the-enum-in-type-annotations/108317
Here is the discuss.python.org link where i asked and showcased this issue. It seems to be a feature in most other type checkers already, with pyright being one of the exceptions.
Code re-pasted from there:
import enum
import typing as t
class Importance(enum.IntEnum):
LOW = 1
MEDIUM = 2
HIGH = 3
type AllT = t.Literal[Importance.LOW, Importance.MEDIUM, Importance.HIGH]
class Task[T: Importance]:
...
def manage_task(task: Task[AllT]) -> t.Any:
...
task: Task[Importance] = ...
manage_task(task) # error
Describe the bug
Treat Literal of all members of an enum the same way as the annotation of just that enum.
Code or Screenshots
https://discuss.python.org/t/treat-literal-of-all-elements-of-enum-equal-to-the-enum-in-type-annotations/108317
Here is the discuss.python.org link where i asked and showcased this issue. It seems to be a feature in most other type checkers already, with pyright being one of the exceptions.
Code re-pasted from there: