@@ -325,25 +325,19 @@ def test_restify_pep_585():
325
325
":py:class:`int`]" )
326
326
327
327
328
+ @pytest .mark .skipif (sys .version_info [:2 ] <= (3 , 11 ), reason = 'python 3.11+ is required.' )
328
329
def test_restify_Unpack ():
329
- import typing
330
+ from typing import Unpack
330
331
331
- from typing_extensions import Unpack as UnpackCompat
332
-
333
- class X (typing .TypedDict ):
332
+ class X (t .TypedDict ):
334
333
x : int
335
334
y : int
336
335
label : str
337
336
338
337
# Unpack is considered as typing special form so we always have '~'
339
- expect = rf':py:obj:`~{ UnpackCompat .__module__ } .Unpack`\ [:py:class:`X`]'
340
- assert restify (UnpackCompat ['X' ], 'fully-qualified-except-typing' ) == expect
341
- assert restify (UnpackCompat ['X' ], 'smart' ) == expect
342
-
343
- if NativeUnpack := getattr (typing , 'Unpack' , None ):
344
- expect = r':py:obj:`~typing.Unpack`\ [:py:class:`X`]'
345
- assert restify (NativeUnpack ['X' ], 'fully-qualified-except-typing' ) == expect
346
- assert restify (NativeUnpack ['X' ], 'smart' ) == expect
338
+ expect = r':py:obj:`~typing.Unpack`\ [:py:class:`X`]'
339
+ assert restify (Unpack ['X' ], 'fully-qualified-except-typing' ) == expect
340
+ assert restify (Unpack ['X' ], 'smart' ) == expect
347
341
348
342
349
343
@pytest .mark .skipif (sys .version_info [:2 ] <= (3 , 9 ), reason = 'python 3.10+ is required.' )
@@ -495,29 +489,17 @@ def test_stringify_Annotated():
495
489
assert stringify_annotation (Annotated [str , "foo" , "bar" ], "smart" ) == "str"
496
490
497
491
492
+ @pytest .mark .skipif (sys .version_info [:2 ] <= (3 , 11 ), reason = 'python 3.11+ is required.' )
498
493
def test_stringify_Unpack ():
499
- import typing
500
-
501
- from typing_extensions import Unpack as UnpackCompat
494
+ from typing import Unpack
502
495
503
- class X (typing .TypedDict ):
496
+ class X (t .TypedDict ):
504
497
x : int
505
498
y : int
506
499
label : str
507
500
508
- # typing.Unpack is introduced in 3.11 but typing_extensions.Unpack
509
- # is only using typing.Unpack since 3.12, so those objects are not
510
- # synchronized with each other.
511
- if hasattr (typing , 'Unpack' ) and typing .Unpack is UnpackCompat :
512
- assert stringify_annotation (UnpackCompat ['X' ]) == 'Unpack[X]'
513
- assert stringify_annotation (UnpackCompat ['X' ], 'smart' ) == '~typing.Unpack[X]'
514
- else :
515
- assert stringify_annotation (UnpackCompat ['X' ]) == 'typing_extensions.Unpack[X]'
516
- assert stringify_annotation (UnpackCompat ['X' ], 'smart' ) == '~typing_extensions.Unpack[X]'
517
-
518
- if NativeUnpack := getattr (typing , 'Unpack' , None ):
519
- assert stringify_annotation (NativeUnpack ['X' ]) == 'Unpack[X]'
520
- assert stringify_annotation (NativeUnpack ['X' ], 'smart' ) == '~typing.Unpack[X]'
501
+ assert stringify_annotation (Unpack ['X' ]) == 'Unpack[X]'
502
+ assert stringify_annotation (Unpack ['X' ], 'smart' ) == '~typing.Unpack[X]'
521
503
522
504
523
505
def test_stringify_type_hints_string ():
0 commit comments