@@ -325,25 +325,19 @@ def test_restify_pep_585():
325325 ":py:class:`int`]" )
326326
327327
328+ @pytest .mark .skipif (sys .version_info [:2 ] <= (3 , 11 ), reason = 'python 3.11+ is required.' )
328329def test_restify_Unpack ():
329- import typing
330+ from typing import Unpack
330331
331- from typing_extensions import Unpack as UnpackCompat
332-
333- class X (typing .TypedDict ):
332+ class X (t .TypedDict ):
334333 x : int
335334 y : int
336335 label : str
337336
338337 # 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
347341
348342
349343@pytest .mark .skipif (sys .version_info [:2 ] <= (3 , 9 ), reason = 'python 3.10+ is required.' )
@@ -495,29 +489,17 @@ def test_stringify_Annotated():
495489 assert stringify_annotation (Annotated [str , "foo" , "bar" ], "smart" ) == "str"
496490
497491
492+ @pytest .mark .skipif (sys .version_info [:2 ] <= (3 , 11 ), reason = 'python 3.11+ is required.' )
498493def test_stringify_Unpack ():
499- import typing
500-
501- from typing_extensions import Unpack as UnpackCompat
494+ from typing import Unpack
502495
503- class X (typing .TypedDict ):
496+ class X (t .TypedDict ):
504497 x : int
505498 y : int
506499 label : str
507500
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]'
521503
522504
523505def test_stringify_type_hints_string ():
0 commit comments