@@ -370,6 +370,27 @@ def test_parse_annotation(app):
370370 [desc_sig_punctuation , "]" ]))
371371 assert_node (doctree [0 ], pending_xref , refdomain = "py" , reftype = "obj" , reftarget = "typing.Literal" )
372372
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+
373394
374395def test_parse_annotation_suppress (app ):
375396 doctree = _parse_annotation ("~typing.Dict[str, str]" , app .env )
@@ -802,7 +823,22 @@ def test_function_pep_695(app):
802823 [desc_sig_name , 'A' ],
803824 [desc_sig_punctuation , ':' ],
804825 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+ )],
806842 )],
807843 [desc_type_parameter , (
808844 [desc_sig_operator , '*' ],
@@ -987,7 +1023,7 @@ def test_class_def_pep_696(app):
9871023 ('[T:(*Ts)|int]' , '[T: (*Ts) | int]' ),
9881024 ('[T:(int|(*Ts))]' , '[T: (int | (*Ts))]' ),
9891025 ('[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' )]]" ),
9911027])
9921028def test_pep_695_and_pep_696_whitespaces_in_bound (app , tp_list , tptext ):
9931029 text = f'.. py:function:: f{ tp_list } ()'
0 commit comments