Skip to content

Commit

Permalink
Test PEP 695 type parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
oxan committed Oct 19, 2023
1 parent 2c1a679 commit bc1eb91
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_py312.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,15 @@ class Hinted:
self.assertEqual(hints['a'], str)
self.assertEqual(hints['b'], list[str])
self.assertEqual(typing.get_origin(hints['c']), list)

def test_typevar_pep695(self):
type GenericList[T: str] = list[T]
def fn() -> GenericList:
pass

tp = typing_utils.get_resolved_type_hints(fn)['return']

self.assertTrue(typing_utils.is_iterable_type(tp))
element_type = typing_utils.get_iterable_element_type(tp)
self.assertTrue(typing_utils.is_type_variable(element_type))
self.assertEqual(typing_utils.get_type_variable_substitution(element_type), str)

0 comments on commit bc1eb91

Please sign in to comment.