mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #9489: autodoc: Custom types using typing.NewType are broken
At the HEAD of 3.10, the implementation of ``typing.NewType`` has been changed to the class based. To follow the change, this uses ``isinstance`` on ``sphinx.util.inspect:isNewType()`.
This commit is contained in:
parent
9ebdc987b0
commit
771507e073
2
CHANGES
2
CHANGES
@ -19,6 +19,8 @@ Features added
|
|||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* #9489: autodoc: Custom types using ``typing.NewType`` are not displayed well
|
||||||
|
with the HEAD of 3.10
|
||||||
* #9435: linkcheck: Failed to check anchors in github.com
|
* #9435: linkcheck: Failed to check anchors in github.com
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
|
@ -211,12 +211,15 @@ def getslots(obj: Any) -> Optional[Dict]:
|
|||||||
|
|
||||||
def isNewType(obj: Any) -> bool:
|
def isNewType(obj: Any) -> bool:
|
||||||
"""Check the if object is a kind of NewType."""
|
"""Check the if object is a kind of NewType."""
|
||||||
__module__ = safe_getattr(obj, '__module__', None)
|
if sys.version_info >= (3, 10):
|
||||||
__qualname__ = safe_getattr(obj, '__qualname__', None)
|
return isinstance(obj, typing.NewType)
|
||||||
if __module__ == 'typing' and __qualname__ == 'NewType.<locals>.new_type':
|
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
return False
|
__module__ = safe_getattr(obj, '__module__', None)
|
||||||
|
__qualname__ = safe_getattr(obj, '__qualname__', None)
|
||||||
|
if __module__ == 'typing' and __qualname__ == 'NewType.<locals>.new_type':
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def isenumclass(x: Any) -> bool:
|
def isenumclass(x: Any) -> bool:
|
||||||
|
Loading…
Reference in New Issue
Block a user