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
|
||||
----------
|
||||
|
||||
* #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
|
||||
|
||||
Testing
|
||||
|
@ -211,6 +211,9 @@ def getslots(obj: Any) -> Optional[Dict]:
|
||||
|
||||
def isNewType(obj: Any) -> bool:
|
||||
"""Check the if object is a kind of NewType."""
|
||||
if sys.version_info >= (3, 10):
|
||||
return isinstance(obj, typing.NewType)
|
||||
else:
|
||||
__module__ = safe_getattr(obj, '__module__', None)
|
||||
__qualname__ = safe_getattr(obj, '__qualname__', None)
|
||||
if __module__ == 'typing' and __qualname__ == 'NewType.<locals>.new_type':
|
||||
|
Loading…
Reference in New Issue
Block a user