-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove sphinx.util.inspect.isNewType
#12646
Conversation
Is there a matching documentation? I cannot see anything about this at https://www.sphinx-doc.org/en/master/extdev/deprecated.html Is there anywhere where we can find why it did not go through deprecation and directly to undocumented removal? I just bumped into this while trying to build sagemath documentation with 8.0.0_rc1 after checking that all the documented as removed in 8.0 API are gone from the code. |
Hi François, from our perspective this is a purely internal API, note that we don't document it in https://www.sphinx-doc.org/en/master/extdev/index.html. I can add a note to the changelog if useful, perhaps? A |
Thanks for the kind answer. It makes sense if it is supposed to be an internal API. sagemath has clearly been using something they should not. To be fair we have been trying to get rid of the old copy of autodoc.py shipped into sagemath and that needs to be changed every major release of sphinx or so. |
See b0485f9 for a migration note. The full old definition of the function (if you need to vendor it) was: def safe_getattr(obj: Any, name: str, *defargs: Any) -> Any:
"""A getattr() that turns all exceptions into AttributeErrors."""
try:
return getattr(obj, name, *defargs)
except Exception as exc:
# sometimes accessing a property raises an exception (e.g.
# NotImplementedError), so let's try to read the attribute directly
try:
# In case the object does weird things with attribute access
# such that accessing `obj.__dict__` may raise an exception
return obj.__dict__[name]
except Exception:
pass
# this is a catch-all for all the weird things that some modules do
# with attribute access
if defargs:
return defargs[0]
raise AttributeError(name) from exc
def isNewType(obj: Any) -> bool:
"""Check the if object is a kind of :class:`~typing.NewType`."""
if sys.version_info[:2] >= (3, 10):
return isinstance(obj, typing.NewType)
__module__ = safe_getattr(obj, '__module__', None)
__qualname__ = safe_getattr(obj, '__qualname__', None)
return __module__ == 'typing' and __qualname__ == 'NewType.<locals>.new_type' A |
Thanks for all the pointers but I may try something more ambitious (get rid of https://github.com/sagemath/sage/blob/develop/src/sage_docbuild/ext/sage_autodoc.py) and see how hard it is to adapt. |
No description provided.