File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -635,7 +635,7 @@ def test_default_update(self):
635
635
self .assertEqual (wrapper .__name__ , 'f' )
636
636
self .assertEqual (wrapper .__qualname__ , f .__qualname__ )
637
637
self .assertEqual (wrapper .attr , 'This is also a test' )
638
- self .assertEqual (wrapper .__annotations__ ['a' ], 'This is a new annotation' )
638
+ self .assertEqual (wrapper .__annotations__ ['a' ], repr ( 'This is a new annotation' ) )
639
639
self .assertNotIn ('b' , wrapper .__annotations__ )
640
640
641
641
@unittest .skipIf (sys .flags .optimize >= 2 ,
Original file line number Diff line number Diff line change @@ -469,6 +469,11 @@ class ForwardRef(_Final, _root=True):
469
469
def __init__ (self , arg , is_argument = True ):
470
470
if not isinstance (arg , str ):
471
471
raise TypeError (f"Forward reference must be a string -- got { arg !r} " )
472
+ # since annotations feature is now default, stringified annotations
473
+ # should be escaped from quotes, or this will result with double
474
+ # forward refs.
475
+ if arg [0 ] in "'\" " and arg [- 1 ] in "'\" " :
476
+ arg = arg [1 :- 1 ]
472
477
try :
473
478
code = compile (arg , '<string>' , 'eval' )
474
479
except SyntaxError :
You can’t perform that action at this time.
0 commit comments