Skip to content

Commit 13dc8cf

Browse files
simplify tests a little
1 parent 06ea9a4 commit 13dc8cf

File tree

1 file changed

+24
-38
lines changed

1 file changed

+24
-38
lines changed

test-data/unit/check-flags.test

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,48 +2518,34 @@ def f():
25182518

25192519
[case testSpotCheckEnableAllErrorCodes]
25202520
# flags: --enable-all-error-codes
2521-
# It would be annoying to check every error here, so let's just check a couple.
2522-
from typing_extensions import override
2523-
2521+
-- It would be annoying to check every error here, so let's just check a couple.
25242522
class Parent:
2525-
def f(self, x: int) -> None:
2526-
pass
2527-
2528-
def g(self, y: int) -> None:
2529-
pass
2530-
2523+
def f(self, x: int) -> None: pass
25312524
class Child(Parent):
2532-
def f(self, x: int) -> None: # E: Method "f" is not using @override but is overriding a method in class "__main__.Parent"
2533-
pass
2534-
2535-
@override
2536-
def g(self, y: int) -> None: #type: ignore # E: Unused "type: ignore" comment # E: "type: ignore" comment without error code
2537-
pass
2538-
[builtins fixtures/tuple-simple.pyi]
2525+
def f(self, x: int) -> None: pass # E: Method "f" is not using @override but is overriding a method in class "__main__.Parent"
2526+
#type: ignore # E: Unused "type: ignore" comment # E: "type: ignore" comment without error code
2527+
2528+
[case testSpotCheckEnableAllErrorCodesSomeCodes-xfail]
2529+
# flags: --enable-all-error-codes --show-error-codes
2530+
-- See https://github.com/python/mypy/issues/19604 for why this doesn't work, probably.
2531+
def inc(x): # E: Function is missing a type annotation [no-untyped-def]
2532+
return x + 1
2533+
class Parent:
2534+
def f(self, x): pass # E: Function is missing a type annotation [no-untyped-def]
2535+
from typing import cast
2536+
cast(int, 1) # E: Redundant cast to "int" [redundant-cast]
25392537

25402538
[case testSpotCheckEnableAllErrorCodesNot]
2541-
# This test case exists purely to ensure that the testSpotCheckErrorCodeAll test does not become obsolete.
2542-
# (For example, if all the errors expected by testSpotCheckErrorCodeAll get turned on by default, then
2543-
# the testSpotCheckErrorCodeAll test would fail to guarantee the enablement of any additional errors!
2544-
# (hint: if that does happen, breaking this test, then consider changing these two tests to pick *different*,
2545-
# not-enabled-by-default, error codes. Also, testSpotCheckEnableAllErrorCodesConfig.))
2546-
from typing_extensions import override
2547-
2539+
-- This test case exists purely to ensure that the testSpotCheckErrorCodeAll test does not become obsolete.
2540+
-- If all the errors expected by testSpotCheckErrorCodeAll get turned on by default, then the
2541+
-- testSpotCheckErrorCodeAll test would fail to guarantee the enablement of any additional errors!
2542+
-- If that does happen, breaking this test, then consider changing this pair of tests to pick *different*,
2543+
-- not-enabled-by-default, error codes. Also, testSpotCheckEnableAllErrorCodesConfig.
25482544
class Parent:
2549-
def f(self, x: int) -> None:
2550-
pass
2551-
2552-
def g(self, y: int) -> None:
2553-
pass
2554-
2545+
def f(self, x: int) -> None: pass
25552546
class Child(Parent):
2556-
def f(self, x: int) -> None:
2557-
pass
2558-
2559-
@override
2560-
def g(self, y: int) -> None: #type: ignore
2561-
pass
2562-
[builtins fixtures/tuple-simple.pyi]
2547+
def f(self, x: int) -> None: pass
2548+
#type: ignore
25632549

25642550
[case testSpotCheckEnableAllErrorCodesConfig]
25652551
# flags: --config-file tmp/mypy.ini
@@ -2610,8 +2596,8 @@ enable_all_error_codes = True
26102596

26112597
[case testSpotCheckEnableAllErrorCodesCountermand]
26122598
# flags: --enable-all-error-codes --disable-error-code unused-ignore
2613-
x = 2 # type: ignore # E: "type: ignore" comment without error code
2599+
# type: ignore # E: "type: ignore" comment without error code
26142600

26152601
[case testSpotCheckEnableAllErrorCodesCountermandCountermand]
26162602
# flags: --enable-all-error-codes --disable-error-code ignore-without-code --disable-error-code unused-ignore --enable-error-code ignore-without-code
2617-
x = 2 # type: ignore # E: "type: ignore" comment without error code
2603+
# type: ignore # E: "type: ignore" comment without error code

0 commit comments

Comments
 (0)