7
7
8
8
from __future__ import annotations
9
9
10
- from typing import TYPE_CHECKING
10
+ from typing import TYPE_CHECKING , cast
11
11
12
- from docutils import nodes
13
12
from sphinx import addnodes
13
+ from docutils import nodes
14
14
from sphinx .domains .python import PyObject , PyTypedField
15
15
16
- from . import _setup_sig , metadata
16
+ from . import metadata , _setup_sig
17
17
18
18
19
19
if TYPE_CHECKING :
@@ -37,34 +37,31 @@ class DLTypedField(PyTypedField):
37
37
#: Override the list type
38
38
list_type = nodes .definition_list
39
39
40
- def make_field (
40
+ def make_field ( # type: ignore[override]
41
41
self ,
42
42
types : dict [str , list [nodes .Node ]],
43
43
domain : str ,
44
44
items : tuple [str , list [nodes .inline ]],
45
45
env : BuildEnvironment | None = None ,
46
- ** kw , # noqa: ANN003
46
+ ** kw : Any , # noqa: ANN401
47
47
) -> nodes .field :
48
48
"""Render a field to a documenttree node representing a definition list item."""
49
49
50
50
def make_refs (
51
- role_name : str ,
52
- name : str ,
53
- node : type [TextLikeNode ],
51
+ role_name : str , name : str , node : type [TextLikeNode ]
54
52
) -> list [nodes .Node ]:
55
53
return self .make_xrefs (role_name , domain , name , node , env = env , ** kw )
56
54
57
55
def handle_item (
58
- fieldarg : str ,
59
- content : list [nodes .inline ],
56
+ fieldarg : str , content : list [nodes .inline ]
60
57
) -> nodes .definition_list_item :
61
58
term = nodes .term ()
62
59
term += make_refs (self .rolename , fieldarg , addnodes .literal_strong )
63
60
64
61
field_type = types .pop (fieldarg , None )
65
62
if field_type is not None :
66
63
if len (field_type ) == 1 and isinstance (field_type [0 ], nodes .Text ):
67
- ( text_node ,) = field_type # type: nodes.Text
64
+ [ text_node ] = cast ( tuple [ nodes .Text ], field_type )
68
65
classifier_content = make_refs (
69
66
self .typerolename ,
70
67
text_node .astext (),
0 commit comments