Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,9 @@ def check_override(self, override: FunctionLike, original: FunctionLike,
if isinstance(original, FunctionLike) and isinstance(override, FunctionLike):
if original_class_or_static and not override_class_or_static:
fail = True
elif isinstance(original, CallableType) and isinstance(override, CallableType):
if original.type_guard is not None and override.type_guard is None:
fail = True

if is_private(name):
fail = False
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-typeguard.test
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ def main(a: object) -> None:
reveal_type(a) # N: Revealed type is 'builtins.float'
[builtins fixtures/tuple.pyi]

[case testTypeGuardMethodOverride-skip]
[case testTypeGuardMethodOverride]
from typing_extensions import TypeGuard
class C:
def is_float(self, a: object) -> TypeGuard[float]: pass
class D(C):
def is_float(self, a: object) -> bool: pass # E: Some error
def is_float(self, a: object) -> bool: pass # E: Signature of "is_float" incompatible with supertype "C"
[builtins fixtures/tuple.pyi]