Message368079
I'm afraid my "even return" was interpreted in https://github.com/python/cpython/pull/19871 as "only return", while as stated "any annotation" suffices. To rephrase:
If the *first* parameter of the registered function isn't annotated, any non-first annotation suffices for registering, but will not dispatch correctly.
Example:
```
>>> @functools.singledispatch
... def func(arg, x):...
>>> @func.register
... def _int(arg, x:int):...
>>> @func.register
... def _str(arg, x:str):...
```
No errors happen, although parameter `x` is annotated, not the first parameter `arg`. So `func()` will dispatch on the type of `arg` according to the annotation of `x`.
So I'm afraid the PR solves the specific "return" example case, but not the flagged general issue. |
|
Date |
User |
Action |
Args |
2020-05-04 20:00:54 | Dutcho | set | recipients:
+ Dutcho, FFY00, bim_bam |
2020-05-04 20:00:54 | Dutcho | set | messageid: <1588622454.64.0.434626130273.issue40464@roundup.psfhosted.org> |
2020-05-04 20:00:54 | Dutcho | link | issue40464 messages |
2020-05-04 20:00:54 | Dutcho | create | |
|