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

Inconsistent behavior of fully qualified type hints. #351

Closed
nikfilippas opened this issue Apr 28, 2023 · 8 comments · Fixed by #400
Closed

Inconsistent behavior of fully qualified type hints. #351

nikfilippas opened this issue Apr 28, 2023 · 8 comments · Fixed by #400

Comments

@nikfilippas
Copy link

nikfilippas commented Apr 28, 2023

In conf.py I have set typehints_fully_qualified = False.
However, while most type hints adhere to this, there are some cases where they appear fully qualified for no apparent reason.

For example

def mass_translator(
        *,
        mass_in: Union[str, MassDef],
        mass_out: Union[str, MassDef],
        concentration: Union[str, Concentration]
) -> Callable[[Cosmology, Union[Real, NDArray], Real],
              Union[Real, NDArray]]:

gets interpreted as
Screenshot from 2023-04-28 11-22-04

while

def convert_concentration(
        cosmo: Cosmology,
        *,
        c_old: Union[Real, NDArray[Real]],
        Delta_old: Real,
        Delta_new: Real
) -> Union[float, NDArray[float]]:

looks alright
Screenshot from 2023-04-28 11-26-31

It also doesn't work well at all with numpy.typing.ArrayLike, as it always fully qualifies it:

-> ArrayLike

becomes
Screenshot from 2023-04-28 11-28-30

This is the rest of the config for autodoc and autodoc_typehints:

# Additional `autodoc` options.
autodoc_default_options = {
    "member-order": "bysource",
    "show-inheritance": True,
    "inherited-members": True,
    "special-members": "__call__",
}

# Options for `sphnix_autodoc_typehints`.
typehints_fully_qualified = False
typehints_defaults = "braces"
typehints_document_rtype = False
typehints_use_signature_return = True

I use Sphinx 6.2.1 and Python 3.11 on Ubuntu 22.04 LTS.
sphinx_autodoc_typehints.__version__ = '1.21.8'.

@nikfilippas
Copy link
Author

nikfilippas commented May 16, 2023

@gaborbernat quick question regarding ArrayLike: could you verify that you can reproduce the problem, or am I doing something wrong with the options I am passing to the extension?

[edit: just saw the AFW banner - no rush]

@gaborbernat
Copy link
Member

Can't help you, if you find the problem, PR welcome.

@gaborbernat
Copy link
Member

Seems stalled.

@nikfilippas
Copy link
Author

FYI this is still an issue, it isn't completed. I have provided all the info needed to reproduce it, but let me know if I can provide you with anything else too.

@gaborbernat
Copy link
Member

A PR is welcome, 👍 note we don't plan to do the work for you, but if you fill a PR we'll help with that.

@nikfilippas
Copy link
Author

I don't know what is happening under the hood, so unfortunately I can't contribute with a PR. I opened an issue because I feel like this is a bug to do with the repo.
If the Issue log here is only meant to represent a to-do list feel free to close.

@gaborbernat
Copy link
Member

It's a TODO list for the community; I'm just the maintainer here, not the developer in residence 😊 we can keep it open if you think we have all the info you wanted.

@nikfilippas
Copy link
Author

Yes, I think all the info needed to reproduce is provided.

PS: I know it's a community project, and that's why I never asked that someone in particular solves it. I only raised the fyi because you closed it as "completed" without the bug having actually been fixed.

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

Successfully merging a pull request may close this issue.

2 participants