-
Notifications
You must be signed in to change notification settings - Fork 23
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
Prefer unions over overloads #245
Comments
Hmm, it's a nice idea, but it might be tricky to implement. You'd probably need to "collect" So it might be possible, but also might be a little complicated. Are you interested in working on it? |
I'm sorry, that would be too complicated for me. |
You've already nerd-sniped me into thinking through a possible design, so I'm not saying "no" ;) |
unrelated: some of the flake8-pyi rules are also applicable to py files, for example, this overload-union case. It would be great if flake8-pyi can work on pyi files and on py files with a reduced subset of checks. |
Yeah, we're aware, this has come up a few times:
The core dev team for this plugin is the same as the core dev team for typeshed, though, so this always ends up being somewhat low priority for us to fix :) PRs welcome! |
I had a look at implementing this, but I think it would just be unreasonably complicated for us to do here, sorry. The machinery we'd have to build to properly analyse overloaded functions (and to distinguish between different overloads inside different Mypy or pyright might be interested -- you could always try filing a feature request with one of them. |
overloads are sometimes used in places where a union would be a "better" annotation.
Here is an example from the work-in-progress pandas-stubs:
which could be re-written as
Not only is this much shorter but it also covers the case where the first argument is a union type (not covered by the overloads).
The text was updated successfully, but these errors were encountered: