Different behavior between Union
and |
in mypy when dealing with optionals
#10499
Labels
Union
and |
in mypy when dealing with optionals
#10499
In the following two code examples, the first gives an error, while the latter does not. As I understand
type1 | type2
is supposed to be an alias forUnion[type1, type2]
in python3.10 (hence thefrom __future__ import annotations
).error: Incompatible default for argument "a" (default has type "None", argument has type "Union[int, str]")
As of PEP 484, non-explicit optional is discouraged. Is this the correct behavior, or a bug?
Your Environment
3.9.1
0.812
The text was updated successfully, but these errors were encountered: