Skip to content

Commit

Permalink
Make get_origin(Literal[...]) == Literal.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed Sep 5, 2021
1 parent 01f1b91 commit fa2ccd4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions test_typing_inspect.py
Expand Up @@ -306,6 +306,7 @@ def test_origin(self):
self.assertEqual(get_origin(ClassVar[int]), None)
self.assertEqual(get_origin(Generic), Generic)
self.assertEqual(get_origin(Generic[T]), Generic)
self.assertEqual(get_origin(Literal[42]), Literal)
if PY39:
self.assertEqual(get_origin(list[int]), list)
if GENERIC_TUPLE_PARAMETRIZABLE:
Expand Down
2 changes: 2 additions & 0 deletions typing_inspect.py
Expand Up @@ -313,6 +313,8 @@ def get_origin(tp):
return Union
if is_tuple_type(tp):
return Tuple
if is_literal_type(tp):
return Literal if NEW_TYPING else _Literal

return None

Expand Down

0 comments on commit fa2ccd4

Please sign in to comment.