[issue46014] functools.singledispatch does not support Union types

wrobell report at bugs.python.org
Thu Dec 30 07:55:43 EST 2021


wrobell <wrobell at riseup.net> added the comment:

Will it support Optional as well?

According to PEP-604, these two shall be equivalent (using Python 3.10 below)?
```
type(int | None)
types.UnionType

type(tp.Optional[int])
typing._UnionGenericAlias
```

Also, IMHO, the documentation of singledispatch should be improved. It needs to state that only Python types are supported with few exceptions (union type now), but other annotation types are not supported, i.e. generics like `list[int]`.

----------
nosy: +wrobell

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46014>
_______________________________________


More information about the Python-bugs-list mailing list