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
from typing import Iterator
class Foo(object):
@contextmanager
def bar(self):
# type: () -> Iterator[int]
yield 4
class Bar(Foo):
@contextmanager
def bar(self):
# type: () -> Iterator[int]
yield 3
reveal_type(Foo.bar)
reveal_type(Bar.bar)
Fails thus:
t5.py: note: In class "Bar":
t5.py:12: error: Signature of "bar" incompatible with supertype "Foo"
t5.py: note: At top level:
t5.py:17: error: Revealed type is 'def (*Any, **Any) -> contextlib.ContextManager[builtins.int*]'
t5.py:18: error: Revealed type is 'def (*Any, **Any) -> contextlib.ContextManager[builtins.int*]'
tmp.py:12: error: Signature of "bar" incompatible with supertype "Foo"
tmp.py:16: error: Revealed type is 'Any'
tmp.py:17: error: Revealed type is 'Any'
Activity
JukkaL commentedon Jan 16, 2017
You can use
# type: ignoreas a workaround.thomasballinger commentedon Jan 19, 2017
Maybe the same bug, if so this is more general than contextmanager.
gives
FuegoFro commentedon Aug 1, 2017
Is this a duplicate of #1441? Also is this possibly related to the forward referencing issue listed in #2907 (comment)?
JukkaL commentedon Aug 8, 2017
Yes, this looks like a duplicate of #1441. This likely isn't related to forward references.