Ken Jin <kenjin4...@gmail.com> added the comment:

Apologies to all for the spam, I made a misclick. 

Maybe the documentation could be clearer for that specific example. The 
following code seems to work on mypy (in a non-stub file):
```
from typing import overload, Any, Optional

@overload
def utf8(value: None) -> None: 
    ...
@overload
def utf8(value: bytes) -> bytes: 
    ...
def utf8(value: Optional[bytes]) -> Optional[bytes]:
    if value is None:
        return None
    return b''
```
But I don't know if that's the intended usage, because that makes overload 
appear rather redundant.

----------
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.6, Python 3.7

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

Reply via email to