File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ Bugs fixed
1818
1919* #9504: autodoc: generate incorrect reference to the parent class if the target
2020 class inherites the class having ``_name`` attribute
21+ * #9537: autodoc: Some objects under ``typing`` module are not displayed well
22+ with the HEAD of 3.10
2123* #9512: sphinx-build: crashed with the HEAD of Python 3.10
2224
2325Testing
Original file line number Diff line number Diff line change @@ -148,7 +148,9 @@ def _restify_py37(cls: Optional[Type]) -> str:
148148 args = ', ' .join (restify (a ) for a in cls .__args__ )
149149 return ':obj:`~typing.Union`\\ [%s]' % args
150150 elif inspect .isgenericalias (cls ):
151- if getattr (cls , '_name' , None ):
151+ if isinstance (cls .__origin__ , typing ._SpecialForm ):
152+ text = restify (cls .__origin__ ) # type: ignore
153+ elif getattr (cls , '_name' , None ):
152154 if cls .__module__ == 'typing' :
153155 text = ':class:`~%s.%s`' % (cls .__module__ , cls ._name )
154156 else :
@@ -344,7 +346,7 @@ def _stringify_py37(annotation: Any) -> str:
344346 if not isinstance (annotation .__args__ , (list , tuple )):
345347 # broken __args__ found
346348 pass
347- elif qualname == ' Union' :
349+ elif qualname in ( 'Optional' , ' Union') :
348350 if len (annotation .__args__ ) > 1 and annotation .__args__ [- 1 ] is NoneType :
349351 if len (annotation .__args__ ) > 2 :
350352 args = ', ' .join (stringify (a ) for a in annotation .__args__ [:- 1 ])
You can’t perform that action at this time.
0 commit comments