@@ -370,6 +370,27 @@ def test_parse_annotation(app):
370
370
[desc_sig_punctuation , "]" ]))
371
371
assert_node (doctree [0 ], pending_xref , refdomain = "py" , reftype = "obj" , reftarget = "typing.Literal" )
372
372
373
+ # Annotated type with callable gets parsed
374
+ doctree = _parse_annotation ("Annotated[Optional[str], annotated_types.MaxLen(max_length=10)]" , app .env )
375
+ assert_node (doctree , (
376
+ [pending_xref , 'Annotated' ],
377
+ [desc_sig_punctuation , '[' ],
378
+ [pending_xref , 'str' ],
379
+ [desc_sig_space , ' ' ],
380
+ [desc_sig_punctuation , '|' ],
381
+ [desc_sig_space , ' ' ],
382
+ [pending_xref , 'None' ],
383
+ [desc_sig_punctuation , ',' ],
384
+ [desc_sig_space , ' ' ],
385
+ [pending_xref , 'annotated_types.MaxLen' ],
386
+ [desc_sig_punctuation , '(' ],
387
+ [desc_sig_name , 'max_length' ],
388
+ [desc_sig_operator , '=' ],
389
+ [desc_sig_literal_number , '10' ],
390
+ [desc_sig_punctuation , ')' ],
391
+ [desc_sig_punctuation , ']' ],
392
+ ))
393
+
373
394
374
395
def test_parse_annotation_suppress (app ):
375
396
doctree = _parse_annotation ("~typing.Dict[str, str]" , app .env )
@@ -802,7 +823,22 @@ def test_function_pep_695(app):
802
823
[desc_sig_name , 'A' ],
803
824
[desc_sig_punctuation , ':' ],
804
825
desc_sig_space ,
805
- [desc_sig_name , ([pending_xref , 'int | Annotated[int, ctype("char")]' ])],
826
+ [desc_sig_name , (
827
+ [pending_xref , 'int' ],
828
+ [desc_sig_space , ' ' ],
829
+ [desc_sig_punctuation , '|' ],
830
+ [desc_sig_space , ' ' ],
831
+ [pending_xref , 'Annotated' ],
832
+ [desc_sig_punctuation , '[' ],
833
+ [pending_xref , 'int' ],
834
+ [desc_sig_punctuation , ',' ],
835
+ [desc_sig_space , ' ' ],
836
+ [pending_xref , 'ctype' ],
837
+ [desc_sig_punctuation , '(' ],
838
+ [desc_sig_literal_string , "'char'" ],
839
+ [desc_sig_punctuation , ')' ],
840
+ [desc_sig_punctuation , ']' ],
841
+ )],
806
842
)],
807
843
[desc_type_parameter , (
808
844
[desc_sig_operator , '*' ],
@@ -987,7 +1023,7 @@ def test_class_def_pep_696(app):
987
1023
('[T:(*Ts)|int]' , '[T: (*Ts) | int]' ),
988
1024
('[T:(int|(*Ts))]' , '[T: (int | (*Ts))]' ),
989
1025
('[T:((*Ts)|int)]' , '[T: ((*Ts) | int)]' ),
990
- (' [T:Annotated[int,ctype(" char" )]]' , ' [T: Annotated[int, ctype(" char" )]]' ),
1026
+ (" [T:Annotated[int,ctype(' char' )]]" , " [T: Annotated[int, ctype(' char' )]]" ),
991
1027
])
992
1028
def test_pep_695_and_pep_696_whitespaces_in_bound (app , tp_list , tptext ):
993
1029
text = f'.. py:function:: f{ tp_list } ()'
0 commit comments