Код: Выделить всё
from enum import IntEnum
from typing import Literal
class Foo(IntEnum):
bar = 42
def my_func(arg: Foo) -> None:
print(arg)
def my_func_2(arg: Literal[42]) -> None:
print(arg)
my_func(42) # "Literal[42]" is not assignable to "Foo" (reportArgumentType)
my_func_2(42)
my_func(Foo.bar)
my_func_2(Foo.bar) # "Literal[Foo.bar]" is not assignable to "Literal[42]" (reportArgumentType)
Код: Выделить всё
def my_func(arg: Foo | Literal[42]) -> None:
print(arg)
Подробнее здесь: https://stackoverflow.com/questions/796 ... ums-values