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
from contextlib import contextmanager
def foo() -> None:
with bar(): # Error: Cannot determine type of 'bar'
print('here')
@contextmanager
def bar():
print('before')
yield
print('after')
The reason is that when type checking foo, we haven't run type inference for bar yet. More general multi-pass type inference (#481) would fix this (and other related issues), but that's somewhat tricky to implement. A quick fix would be to support just a few cases such as the above, at least for common kinds of decorators.
The text was updated successfully, but these errors were encountered:
Mypy complains about code like this:
The reason is that when type checking
foo
, we haven't run type inference forbar
yet. More general multi-pass type inference (#481) would fix this (and other related issues), but that's somewhat tricky to implement. A quick fix would be to support just a few cases such as the above, at least for common kinds of decorators.The text was updated successfully, but these errors were encountered: