Skip to content

Commit

Permalink
verify _check_generic also for typing variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Daraan committed Nov 27, 2024
1 parent 18ab54b commit ed09f84
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5400,6 +5400,24 @@ class ProtoZ(Protocol[P]):
H10args = H10.__args__[0] if sys.version_info >= (3, 10) else H10.__args__
self.assertEqual(H10args, (int, (str, int)))

@skipUnless(TYPING_3_10_0, "ParamSpec not present before 3.10")
def test_substitution_with_typing_variants(self):
# verifies substitution and typing._check_generic working with typing variants
P = ParamSpec("P")
typing_P = typing.ParamSpec("typing_P")
typing_Concatenate = typing.Concatenate[int, P]

class Z(Generic[typing_P]):
pass

P1 = Z[typing_P]
self.assertEqual(P1.__parameters__, (typing_P,))
self.assertEqual(P1.__args__, (typing_P,))

C1 = Z[typing_Concatenate]
self.assertEqual(C1.__parameters__, (P,))
self.assertEqual(C1.__args__, (typing_Concatenate,))

def test_pickle(self):
global P, P_co, P_contra, P_default
P = ParamSpec('P')
Expand Down

0 comments on commit ed09f84

Please sign in to comment.