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

Support for typing @overload annotation #442

Open
jpfeuffer opened this issue Sep 28, 2022 · 4 comments
Open

Support for typing @overload annotation #442

jpfeuffer opened this issue Sep 28, 2022 · 4 comments

Comments

@jpfeuffer
Copy link

jpfeuffer commented Sep 28, 2022

Problem Description

Some support for function overloads specified by @overload annotation in typestubs is missing. All functions that have it, are just shown with the general base implementation (*args, **kwds) instead of the declared and fully typed overloads.

Proposal

In the beginning, just one entry per overload would be nice.

Additional context

Trying to document a Cython extension that due to its C++ origin has typestubs with @overload annotations

@mhils
Copy link
Member

mhils commented Sep 28, 2022

pdoc heavily relies on dynamic analysis. As far as I know, you cannot access @overload signatures using that approach (the final function definition overwrites all previous ones). Implementing support using static analysis would be a major undertaking and introduce significant complexity. I think your request is by all means valid, but I'm afraid the answer here is to 1) use a different documentation generator, 2) not use @overload, or 3) live with it.

@jpfeuffer
Copy link
Author

I see. That makes sense. Do you by chance know about any documentation tool that supports both typestubs and overloads 😅 It is surprisingly hard to find.

Btw: It might be possible starting from 3.11.
python/cpython#89263

@mhils
Copy link
Member

mhils commented Sep 29, 2022

Seems like this hasn't made it into 3.11 in time and will be in 3.12 the earliest.

I see. That makes sense. Do you by chance know about any documentation tool that supports both typestubs and overloads

I don't know, but Sphinx and maybe mkdocstrings have the largest ecosystems.

@jpfeuffer
Copy link
Author

Yes, not in the help() function but maybe via the typing stdlib (typing.getOverloads()). The PR for that was merged early enough I think.

Anyway, I give up for now and will revisit the whole thing in the very distant future again. (Sphinx autosummary/doc does not support type stubs at all and overloads only via docstrings and without descriptions of each overload).

Thanks for considering!

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

No branches or pull requests

2 participants