File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 52
52
py_sig_re ,
53
53
)
54
54
55
+ _TYPING_ALL = frozenset (typing .__all__ )
56
+
55
57
logger = logging .getLogger (__name__ )
56
58
57
59
pairindextypes = {
@@ -1076,13 +1078,6 @@ def builtin_resolver(
1076
1078
app : Sphinx , env : BuildEnvironment , node : pending_xref , contnode : Element
1077
1079
) -> Element | None :
1078
1080
"""Do not emit nitpicky warnings for built-in types."""
1079
-
1080
- def istyping (s : str ) -> bool :
1081
- if s .startswith ('typing.' ):
1082
- s = s .split ('.' , 1 )[1 ]
1083
-
1084
- return s in typing .__all__
1085
-
1086
1081
if node .get ('refdomain' ) != 'py' :
1087
1082
return None
1088
1083
elif node .get ('reftype' ) in {'class' , 'obj' } and node .get ('reftarget' ) == 'None' :
@@ -1092,13 +1087,17 @@ def istyping(s: str) -> bool:
1092
1087
if inspect .isclass (getattr (builtins , reftarget , None )):
1093
1088
# built-in class
1094
1089
return contnode
1095
- if istyping (reftarget ):
1090
+ if _is_typing (reftarget ):
1096
1091
# typing class
1097
1092
return contnode
1098
1093
1099
1094
return None
1100
1095
1101
1096
1097
+ def _is_typing (s : str , / ) -> bool :
1098
+ return s .removeprefix ('typing.' ) in _TYPING_ALL
1099
+
1100
+
1102
1101
def setup (app : Sphinx ) -> ExtensionMetadata :
1103
1102
app .setup_extension ('sphinx.directives' )
1104
1103
You can’t perform that action at this time.
0 commit comments