Skip to content

Commit 9e20166

Browse files
add a spotcheck test for error code all
1 parent 3007cf3 commit 9e20166

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test-data/unit/check-flags.test

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,3 +2467,45 @@ A = Union[C, List] # OK
24672467
-- check_untyped_defs is False by default.
24682468
def f():
24692469
x: int = "no" # N: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs
2470+
2471+
[case testSpotCheckErrorCodeAll]
2472+
# flags: --enable-error-code all
2473+
# It would be annoying to check every error here, so let's just check a couple.
2474+
from typing import override
2475+
2476+
class Parent:
2477+
def f(self, x: int) -> None:
2478+
pass
2479+
2480+
def g(self, y: int) -> bool:
2481+
return True
2482+
2483+
class Child(Parent):
2484+
def f(self, x: int) -> None: # E: Missing @override decorator
2485+
pass
2486+
2487+
@override
2488+
def g(self, y: int) -> bool: #type: ignore # E: Unused "type: ignore" comment # E: "type: ignore" comment without error code
2489+
return True
2490+
2491+
[case testSpotCheckErrorCodeAllNotUsed]
2492+
# This test case exists purely to ensure that the testSpotCheckErrorCodeAll test does not become obsolete.
2493+
# (For example, if all the errors expected by testSpotCheckErrorCodeAll get turned on by default, then
2494+
# the testSpotCheckErrorCodeAll test would fail to guarantee the enablement of any additional errors!)
2495+
2496+
from typing import override
2497+
2498+
class Parent:
2499+
def f(self, x: int) -> None:
2500+
pass
2501+
2502+
def g(self, y: int) -> bool:
2503+
return True
2504+
2505+
class Child(Parent):
2506+
def f(self, x: int) -> None:
2507+
pass
2508+
2509+
@override
2510+
def g(self, y: int) -> bool: #type: ignore
2511+
return True

0 commit comments

Comments
 (0)