@@ -861,8 +861,8 @@ def test_getfullargspec(self):
861
861
formatted = '(*arg1, arg2=1)' )
862
862
863
863
self .assertFullArgSpecEquals (mod2 .annotated , ['arg1' ],
864
- ann_e = {'arg1' : list },
865
- formatted = ' (arg1: list)' )
864
+ ann_e = {'arg1' : ' list' },
865
+ formatted = " (arg1: ' list')" )
866
866
self .assertFullArgSpecEquals (mod2 .keyword_only_arg , [],
867
867
kwonlyargs_e = ['arg' ],
868
868
formatted = '(*, arg)' )
@@ -2211,27 +2211,27 @@ def test(a, b:'foo') -> 123:
2211
2211
pass
2212
2212
self .assertEqual (self .signature (test ),
2213
2213
((('a' , ..., ..., "positional_or_keyword" ),
2214
- ('b' , ..., 'foo' , "positional_or_keyword" )),
2215
- 123 ))
2214
+ ('b' , ..., repr ( 'foo' ) , "positional_or_keyword" )),
2215
+ ' 123' ))
2216
2216
2217
2217
def test_signature_on_wkwonly (self ):
2218
2218
def test (* , a :float , b :str ) -> int :
2219
2219
pass
2220
2220
self .assertEqual (self .signature (test ),
2221
- ((('a' , ..., float , "keyword_only" ),
2222
- ('b' , ..., str , "keyword_only" )),
2223
- int ))
2221
+ ((('a' , ..., ' float' , "keyword_only" ),
2222
+ ('b' , ..., ' str' , "keyword_only" )),
2223
+ ' int' ))
2224
2224
2225
2225
def test_signature_on_complex_args (self ):
2226
2226
def test (a , b :'foo' = 10 , * args :'bar' , spam :'baz' , ham = 123 , ** kwargs :int ):
2227
2227
pass
2228
2228
self .assertEqual (self .signature (test ),
2229
2229
((('a' , ..., ..., "positional_or_keyword" ),
2230
- ('b' , 10 , 'foo' , "positional_or_keyword" ),
2231
- ('args' , ..., 'bar' , "var_positional" ),
2232
- ('spam' , ..., 'baz' , "keyword_only" ),
2230
+ ('b' , 10 , repr ( 'foo' ) , "positional_or_keyword" ),
2231
+ ('args' , ..., repr ( 'bar' ) , "var_positional" ),
2232
+ ('spam' , ..., repr ( 'baz' ) , "keyword_only" ),
2233
2233
('ham' , 123 , ..., "keyword_only" ),
2234
- ('kwargs' , ..., int , "var_keyword" )),
2234
+ ('kwargs' , ..., ' int' , "var_keyword" )),
2235
2235
...))
2236
2236
2237
2237
def test_signature_without_self (self ):
@@ -2466,7 +2466,7 @@ def __call__(*, a):
2466
2466
self .assertEqual (self .signature (Test ().m1 ),
2467
2467
((('arg1' , ..., ..., "positional_or_keyword" ),
2468
2468
('arg2' , 1 , ..., "positional_or_keyword" )),
2469
- int ))
2469
+ ' int' ))
2470
2470
2471
2471
self .assertEqual (self .signature (Test ().m2 ),
2472
2472
((('args' , ..., ..., "var_positional" ),),
@@ -2490,7 +2490,7 @@ def m1d(*args, **kwargs):
2490
2490
self .assertEqual (self .signature (m1d ),
2491
2491
((('arg1' , ..., ..., "positional_or_keyword" ),
2492
2492
('arg2' , 1 , ..., "positional_or_keyword" )),
2493
- int ))
2493
+ ' int' ))
2494
2494
2495
2495
def test_signature_on_classmethod (self ):
2496
2496
class Test :
@@ -2640,12 +2640,12 @@ def test(a, b, c:int) -> 42:
2640
2640
2641
2641
self .assertEqual (self .signature (partial (partial (test , 1 ))),
2642
2642
((('b' , ..., ..., "positional_or_keyword" ),
2643
- ('c' , ..., int , "positional_or_keyword" )),
2644
- 42 ))
2643
+ ('c' , ..., ' int' , "positional_or_keyword" )),
2644
+ '42' ))
2645
2645
2646
2646
self .assertEqual (self .signature (partial (partial (test , 1 ), 2 )),
2647
- ((('c' , ..., int , "positional_or_keyword" ),),
2648
- 42 ))
2647
+ ((('c' , ..., ' int' , "positional_or_keyword" ),),
2648
+ '42' ))
2649
2649
2650
2650
psig = inspect .signature (partial (partial (test , 1 ), 2 ))
2651
2651
@@ -2764,12 +2764,12 @@ def test(it, a, *, c) -> 'spam':
2764
2764
((('it' , ..., ..., 'positional_or_keyword' ),
2765
2765
('a' , ..., ..., 'positional_or_keyword' ),
2766
2766
('c' , 1 , ..., 'keyword_only' )),
2767
- 'spam' ))
2767
+ repr ( 'spam' ) ))
2768
2768
2769
2769
self .assertEqual (self .signature (Spam ().ham ),
2770
2770
((('a' , ..., ..., 'positional_or_keyword' ),
2771
2771
('c' , 1 , ..., 'keyword_only' )),
2772
- 'spam' ))
2772
+ repr ( 'spam' ) ))
2773
2773
2774
2774
class Spam :
2775
2775
def test (self : 'anno' , x ):
@@ -2778,7 +2778,7 @@ def test(self: 'anno', x):
2778
2778
g = partialmethod (test , 1 )
2779
2779
2780
2780
self .assertEqual (self .signature (Spam .g ),
2781
- ((('self' , ..., 'anno' , 'positional_or_keyword' ),),
2781
+ ((('self' , ..., repr ( 'anno' ) , 'positional_or_keyword' ),),
2782
2782
...))
2783
2783
2784
2784
def test_signature_on_fake_partialmethod (self ):
@@ -3116,20 +3116,16 @@ def foo(a={}): pass
3116
3116
with self .assertRaisesRegex (TypeError , 'unhashable type' ):
3117
3117
hash (inspect .signature (foo ))
3118
3118
3119
- def foo (a ) -> {}: pass
3120
- with self .assertRaisesRegex (TypeError , 'unhashable type' ):
3121
- hash (inspect .signature (foo ))
3122
-
3123
3119
def test_signature_str (self ):
3124
3120
def foo (a :int = 1 , * , b , c = None , ** kwargs ) -> 42 :
3125
3121
pass
3126
3122
self .assertEqual (str (inspect .signature (foo )),
3127
- '(a: int = 1, *, b, c=None, **kwargs) -> 42 ' )
3123
+ '(a: \' int\' = 1, *, b, c=None, **kwargs) -> \' 42 \' ' )
3128
3124
3129
3125
def foo (a :int = 1 , * args , b , c = None , ** kwargs ) -> 42 :
3130
3126
pass
3131
3127
self .assertEqual (str (inspect .signature (foo )),
3132
- '(a: int = 1, *args, b, c=None, **kwargs) -> 42 ' )
3128
+ '(a: \' int\' = 1, *args, b, c=None, **kwargs) -> \' 42 \' ' )
3133
3129
3134
3130
def foo ():
3135
3131
pass
@@ -3172,8 +3168,8 @@ def test() -> 42:
3172
3168
self .assertIs (sig .return_annotation , None )
3173
3169
sig = sig .replace (return_annotation = sig .empty )
3174
3170
self .assertIs (sig .return_annotation , sig .empty )
3175
- sig = sig .replace (return_annotation = 42 )
3176
- self .assertEqual (sig .return_annotation , 42 )
3171
+ sig = sig .replace (return_annotation = '42' )
3172
+ self .assertEqual (sig .return_annotation , '42' )
3177
3173
self .assertEqual (sig , inspect .signature (test ))
3178
3174
3179
3175
def test_signature_on_mangled_parameters (self ):
@@ -3185,8 +3181,8 @@ class Ham(Spam):
3185
3181
3186
3182
self .assertEqual (self .signature (Spam .foo ),
3187
3183
((('self' , ..., ..., "positional_or_keyword" ),
3188
- ('_Spam__p1' , 2 , 1 , "positional_or_keyword" ),
3189
- ('_Spam__p2' , 3 , 2 , "keyword_only" )),
3184
+ ('_Spam__p1' , 2 , '1' , "positional_or_keyword" ),
3185
+ ('_Spam__p2' , 3 , '2' , "keyword_only" )),
3190
3186
...))
3191
3187
3192
3188
self .assertEqual (self .signature (Spam .foo ),
0 commit comments