-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Wrapped overloaded function drops all but the first overload #15737
Comments
Supporting overloads for |
Fixes #15737 Fixes #12844 Fixes #12716 My goal was to fix the `ParamSpec` issues, but it turns out decorated overloads were not supported at all. Namely: * Decorators on overload items were ignored, caller would see original undecorated item types * Overload item overlap checks were performed for original types, while arguably we should use decorated types * Overload items completeness w.r.t. to implementation was checked with decorated implementation, and undecorated items Here I add basic support using same logic as for regular decorated functions: initially set type to `None` and defer callers until definition is type-checked. Note this results in few more `Cannot determine type` in case of other errors, but I think it is fine. Note I also add special-casing for "inline" applications of generic functions to overload arguments. This use case was mentioned few times alongside overloads. The general fix would be tricky, and my special-casing should cover typical use cases. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@maffoo is the project you were running into this on open source? |
Hi @hauntsaninja, yes, the project where I ran into this is in "duet", a small library for doing concurrency with futures: https://github.com/google/duet. In particular, there's a function def sync(f: Callable[P, Awaitable[T]]) -> Callable[P, T]:
... Unfortunately, we use |
Bug Report
When wrapping an overloaded function and using
ParamSpec
to preserve the call signature, only the first overload is preserved on the resulting function.To Reproduce
See:
Expected Behavior
I would expect the overloads to be preserved on the decorated function, e.g.
Actual Behavior
Your Environment
The text was updated successfully, but these errors were encountered: