You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a function annotated to return tuple[T] returns tuple[Any] no error is raised. Same with list.
To Reproduce
from __future__ importannotationsfromtypingimportAnydefpasses() ->tuple[str]:
a: Anyreturn (a,)
deffails_1() ->tuple[str]:
a: intreturn (a,)
# error: Incompatible return value type (got "Tuple[int]", expected "Tuple[str]")deffails_2() ->str:
a: Anyreturna# error: Returning Any from function declared to return "str"
Expected Behavior
I'd expect passes() to fail with error: Returning Tuple[Any] from function declared to return "Tuple[str]" when using mypy with --strict
Actual Behavior
Tuple[Any] is inferred to Tuple[str]
Your Environment
Mypy version used: 0.812
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files):
Bug Report
When a function annotated to return
tuple[T]
returnstuple[Any]
no error is raised. Same withlist
.To Reproduce
Expected Behavior
I'd expect
passes()
to fail witherror: Returning Tuple[Any] from function declared to return "Tuple[str]"
when using mypy with--strict
Actual Behavior
Tuple[Any]
is inferred toTuple[str]
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: