Skip to content
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

Elegant typehints' qualname overrides aren't processed in autodoc's show-inheritance option #18

Closed
laymonage opened this issue Sep 6, 2020 · 2 comments · Fixed by #19

Comments

@laymonage
Copy link

When using the :show-inheritance: option for automodule, autoclass, or autoexception directives, the qualname overrides specified for elegant_typehints are not processed by Sphinx. The :show-inheritance: option will make Sphinx also list the base classes (and link them) for each class. However, since the qualname_overrides aren't processed, using the :show-inheritance: option will throw errors for classes whose base classes' qualnames should be overridden.

For example, with the following rst file:

Exceptions
==========

.. automodule:: mypackage.exceptions
   :members:
   :show-inheritance:

and the following mypackage/exceptions.py:

import requests


class MyConnectionError(requests.ConnectionError):
    pass

This will throw an error because requests.ConnectionError's qualname is requests.exceptions.ConnectionError but the object inventory exposes requests.ConnectionError... which is the reason why we'd use qualname_overrides from elegant typehints. The expected behavior is that elegant typehints should handle this case as well.

Link to Sphinx's autoclass inheritance checking implementation:
https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/ext/autodoc/__init__.py#L1485-L1494

@laymonage
Copy link
Author

P.s. on another note, this may actually be expected as it's not related to type hints. Still, I wonder if we can elevate the qualname overrides feature into something more general, maybe as its own extension.

@flying-sheep
Copy link
Collaborator

flying-sheep commented Sep 9, 2020

Hey, thank you for the nice report. As mentioned in the docs:

Once either sphinx issue 4826 or sphinx-autodoc-typehints issue 38 are fixed, this part of the functionality will no longer be necessary

I created #19 to add this functionality, but it doesn’t work yet. IDK what I’m doing wrong.

Breakpoints don’t even hit that function …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants