Dutcho <dut...@ziggo.nl> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40464>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to