I need to check if object is descendant of typing.Literal, I have annotation like this:
GameState: Literal['start', 'stop']
And I need to check GameState annotation type:
def parse_values(ann)
if isinstance(ann, str):
# do sth
if isinstance(ann, int):
# do sth
if isinstance(ann, Literal):
# do sth
But it causes error, so I swapped the last one to:
if type(ann) == Literal:
# do sth
But it never returns True, so anyone knows a workaround for this?