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
We might not always be able to infer the type of the variable bound by a with statement, just like we might not always be able to infer the type of a variable being assigned to for the first time. For this minimal example
from typing import TypeVar
from contextlib import ContextManager
T = TypeVar('T')
def g() -> ContextManager[T]: ...
with g() as x:
pass
mypy reports
with.py:6: error: Need type annotation for variable
It would be nice to be able to write, for example,
with g() as x: # type: int
declaring the type of x. This is currently rejected by mypy as a parse error.
The text was updated successfully, but these errors were encountered:
We might not always be able to infer the type of the variable bound by a
with
statement, just like we might not always be able to infer the type of a variable being assigned to for the first time. For this minimal examplemypy reports
It would be nice to be able to write, for example,
declaring the type of
x
. This is currently rejected by mypy as a parse error.The text was updated successfully, but these errors were encountered: