Support for multiple dispatch libraries at runtime with @overload #5886
gabrieldemarmiesse
started this conversation in
Ideas
Replies: 1 comment
-
Update: here is the pep: https://github.com/gabrieldemarmiesse/PEP-draft-multiple-dispatcher here is the discussion: https://discuss.python.org/t/multiple-dispatch-based-on-typing-overload/26197 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there! Thanks for the awesome tool!
With
@overload
andget_overloads
, Python has opened a path to implement multiple dispatch libraries that work at runtime. Similar to C++ and Julia.I made my own by following closely the semantics of the Mypy guide on overload here: https://mypy.readthedocs.io/en/stable/more_types.html#function-overloading
Here is the library (not released on Pypi yet, but in a few days probably): https://github.com/gabrieldemarmiesse/overtake
That works with Mypy and Pycharm. For Pyright it works for the most part, I just have a small error (legitimate, I might say).
It can easily be fixed by a
# type: ignore
without impacting too much the type checking.I am aware that this is not a false positive. I'm not asking anything of the Pyright devs now. Just to keep it in mind when implementing more checks.
If all goes well, maybe I can do a PEP so that multiple dispatch libraries like those are supported by the typing system completely. Well the support is not very far since Mypy doesn't complain at all, and Pyright doesn't complain much.
Beta Was this translation helpful? Give feedback.
All reactions