-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Bug Report
This may be related to #12211.
When extracting a type annotation like -> t.AnyStr | int
to a t.Union
alias, mypy fail to detect incorrect return types.
The actual problem for me was that annotating flask view functions with ResponseValueType
did not find obvious return type violations, but (as I found out during writing of this issue) a workaround seems to have been added.
I'm unsure what to expect of mypy here but silently allowing everything seems like a big hazard to me.
To Reproduce
See the functions foo2
and bar2
in the following gist:
https://mypy-play.net/?mypy=latest&python=3.11&gist=04f598b90124f58021cf19209a7df967.
Expected Behavior
the return statements of foo2
and bar2
should cause an error, either the same error as foo
and bar
or the same as foo3
and bar3
.
Actual Behavior
foo2
and bar2
don't cause an error
Your Environment
- Mypy version used: 1.4.1
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.11