Message413751
I'd dearly like better introspection tools for functions decorated with @overload, but I'd rather have a solution where:
- inspect.signature doesn't have to import typing. That doesn't feel worth it for users who aren't using typing.overload, but inspect.signature would have to import typing whether or not @overload was being used, in order to *check* whether @overload was being used.
- The solution could be reused by, and generalised to, other kinds of functions that have multiple signatures.
If we create an __overloads__ dunder that stored the signatures of multi-signature functions, as Raymond suggests, inspect.signature could check that dunder to examine whether the function is a multi-dispatch signature, and change its representation of the function accordingly. This kind of solution could be easily reused by other parts of the stdlib, like @functools.singledispatch, and by third-party packages such as plum-dispatch, multipledispatch, and Nikita's dry-python/classes library.
So, while it would undoubtedly be more complex to implement, I much prefer Raymond's suggested solution. |
|
Date |
User |
Action |
Args |
2022-02-22 22:13:23 | AlexWaygood | set | recipients:
+ AlexWaygood, rhettinger, ronaldoussoren, JelleZijlstra, Spencer Brown, sobolevn, kj, DiddiLeija |
2022-02-22 22:13:23 | AlexWaygood | set | messageid: <1645568003.21.0.52016765866.issue45100@roundup.psfhosted.org> |
2022-02-22 22:13:23 | AlexWaygood | link | issue45100 messages |
2022-02-22 22:13:23 | AlexWaygood | create | |
|