Skip to content
Merged
Prev Previous commit
Next Next commit
Add tests for get_origin on starred/unpacked things
  • Loading branch information
mrahtz committed Oct 14, 2022
commit 35d1a82ae78920d64e0bf5c4ef410a8623bb39db
7 changes: 7 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5156,6 +5156,7 @@ def h(x: collections.abc.Callable[P, int]): ...
class GetUtilitiesTestCase(TestCase):
def test_get_origin(self):
T = TypeVar('T')
Ts = TypeVarTuple('Ts')
P = ParamSpec('P')
class C(Generic[T]): pass
self.assertIs(get_origin(C[int]), C)
Expand All @@ -5179,6 +5180,12 @@ class C(Generic[T]): pass
self.assertIs(get_origin(P.kwargs), P)
self.assertIs(get_origin(Required[int]), Required)
self.assertIs(get_origin(NotRequired[int]), NotRequired)
self.assertIs(get_origin((*Ts,)[0]), Unpack)
self.assertIs(get_origin(Unpack[Ts]), Unpack)
self.assertIs(get_origin((*tuple[*Ts],)[0]), tuple)
import pdb; pdb.set_trace()
Comment thread
gvanrossum marked this conversation as resolved.
Resolved
get_origin(Unpack[Tuple[Unpack[Ts]]])
self.assertIs(get_origin(Unpack[Tuple[Unpack[Ts]]]), typing.Tuple)

def test_get_args(self):
T = TypeVar('T')
Expand Down