@@ -385,6 +385,21 @@ def test_restify_mock():
385
385
assert restify (unknown .secret .Class , "smart" ) == ':py:class:`~unknown.secret.Class`'
386
386
387
387
388
+ @pytest .mark .xfail (sys .version_info [:2 ] <= (3 , 9 ), reason = 'ParamSpec not supported in Python 3.9.' )
389
+ def test_restify_type_hints_paramspec ():
390
+ from typing import ParamSpec
391
+ P = ParamSpec ('P' )
392
+
393
+ assert restify (P ) == ":py:obj:`tests.test_util.test_util_typing.P`"
394
+ assert restify (P , "smart" ) == ":py:obj:`~tests.test_util.test_util_typing.P`"
395
+
396
+ assert restify (P .args ) == "P.args"
397
+ assert restify (P .args , "smart" ) == "P.args"
398
+
399
+ assert restify (P .kwargs ) == "P.kwargs"
400
+ assert restify (P .kwargs , "smart" ) == "P.kwargs"
401
+
402
+
388
403
def test_stringify_annotation ():
389
404
assert stringify_annotation (int , 'fully-qualified-except-typing' ) == "int"
390
405
assert stringify_annotation (int , "smart" ) == "int"
@@ -722,3 +737,21 @@ def test_stringify_type_ForwardRef():
722
737
assert stringify_annotation (Tuple [dict [ForwardRef ("MyInt" ), str ], list [List [int ]]]) == "Tuple[dict[MyInt, str], list[List[int]]]" # type: ignore[attr-defined]
723
738
assert stringify_annotation (Tuple [dict [ForwardRef ("MyInt" ), str ], list [List [int ]]], 'fully-qualified-except-typing' ) == "Tuple[dict[MyInt, str], list[List[int]]]" # type: ignore[attr-defined]
724
739
assert stringify_annotation (Tuple [dict [ForwardRef ("MyInt" ), str ], list [List [int ]]], 'smart' ) == "~typing.Tuple[dict[MyInt, str], list[~typing.List[int]]]" # type: ignore[attr-defined]
740
+
741
+
742
+ @pytest .mark .xfail (sys .version_info [:2 ] <= (3 , 9 ), reason = 'ParamSpec not supported in Python 3.9.' )
743
+ def test_stringify_type_hints_paramspec ():
744
+ from typing import ParamSpec
745
+ P = ParamSpec ('P' )
746
+
747
+ assert stringify_annotation (P , 'fully-qualified' ) == "~P"
748
+ assert stringify_annotation (P , 'fully-qualified-except-typing' ) == "~P"
749
+ assert stringify_annotation (P , "smart" ) == "~P"
750
+
751
+ assert stringify_annotation (P .args , 'fully-qualified' ) == "typing.~P"
752
+ assert stringify_annotation (P .args , 'fully-qualified-except-typing' ) == "~P"
753
+ assert stringify_annotation (P .args , "smart" ) == "~typing.~P"
754
+
755
+ assert stringify_annotation (P .kwargs , 'fully-qualified' ) == "typing.~P"
756
+ assert stringify_annotation (P .kwargs , 'fully-qualified-except-typing' ) == "~P"
757
+ assert stringify_annotation (P .kwargs , "smart" ) == "~typing.~P"
0 commit comments