| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| Expand Up | @@ -2407,6 +2407,35 @@ Functions and decorators | |||||
|
|
||||||
| See :pep:`484` for details and comparison with other typing semantics. | ||||||
|
|
||||||
| .. versionchanged:: 3.11 | ||||||
| Overloaded functions can now be introspected at runtime using | ||||||
| :func:`get_overloads`. | ||||||
|
|
||||||
|
|
||||||
| .. function:: get_overloads(func) | ||||||
|
|
||||||
| Return a sequence of :func:`@overload <overload>`-decorated definitions for | ||||||
| *func*. *func* is the function object for the implementation of the | ||||||
| overloaded function. For example, given the definition of ``process`` in | ||||||
|
Comment thread
Comment on lines
+2418
to
+2419
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis sentence sounds quite strange to me: *func* is the function object for the implementation of the overloaded function. But I'm not sure I have a better suggestion off the top of my head ://
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYes, unfortunately the overload docs don't have a clear term for the implementation function either.
Sorry, something went wrong.
AlexWaygood reacted with confused emoji
All reactions
|
||||||
| the documentation for :func:`@overload <overload>`, | ||||||
| ``get_overloads(process)`` will return a sequence of three function objects | ||||||
| for the three defined overloads. If called on a function with no overloads, | ||||||
| ``get_overloads`` returns an empty sequence. | ||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Tiny nit -- this paragraph starts off using the imperative mood
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityBut the previous sentence is in the indicative, so I think this is fine?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWell, it's not really a big deal either way :)
Sorry, something went wrong.
All reactions
|
||||||
|
|
||||||
| ``get_overloads`` can be used for introspecting an overloaded function at | ||||||
| runtime. | ||||||
|
Comment thread
JelleZijlstra marked this conversation as resolved.
|
||||||
|
|
||||||
| .. versionadded:: 3.11 | ||||||
|
|
||||||
|
|
||||||
| .. function:: clear_overloads() | ||||||
|
|
||||||
| Clear all registered overloads in the internal registry. This can be used | ||||||
| to reclaim the memory used by the registry. | ||||||
|
|
||||||
| .. versionadded:: 3.11 | ||||||
|
|
||||||
|
|
||||||
| .. decorator:: final | ||||||
|
|
||||||
| A decorator to indicate to type checkers that the decorated method | ||||||
| Expand Down | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Add :func:`typing.get_overloads` and :func:`typing.clear_overloads`. | ||
| Patch by Jelle Zijlstra. |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.