Skip to content

Commit e355c28

Browse files
authored
Include --strict-equality in --strict (#8290)
Fixes #7910. The stub changes are needed for clean output when using --strict.
1 parent 4731070 commit e355c28

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

mypy/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ def add_invertible_flag(flag: str,
602602
help="Treat imports as private unless aliased",
603603
group=strictness_group)
604604

605-
add_invertible_flag('--strict-equality', default=False, strict_flag=False,
605+
add_invertible_flag('--strict-equality', default=False, strict_flag=True,
606606
help="Prohibit equality, identity, and container checks for"
607607
" non-overlapping types",
608608
group=strictness_group)

test-data/unit/check-flags.test

+8
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,14 @@ def f(c: A) -> None: # E: Missing type parameters for generic type "A"
11491149
pass
11501150
[out]
11511151

1152+
[case testStrictAndStrictEquality]
1153+
# flags: --strict
1154+
x = 0
1155+
y = ''
1156+
if x == y: # E: Non-overlapping equality check (left operand type: "int", right operand type: "str")
1157+
int()
1158+
[builtins fixtures/ops.pyi]
1159+
11521160
[case testStrictEqualityPerFile]
11531161
# flags: --config-file tmp/mypy.ini
11541162
import b

test-data/unit/fixtures/ops.pyi

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class type: pass
1313

1414
class slice: pass
1515

16-
class tuple(Sequence[Tco], Generic[Tco]):
16+
class tuple(Sequence[Tco]):
1717
def __getitem__(self, x: int) -> Tco: pass
1818
def __eq__(self, x: object) -> bool: pass
1919
def __ne__(self, x: object) -> bool: pass
20-
def __lt__(self, x: 'tuple') -> bool: pass
21-
def __le__(self, x: 'tuple') -> bool: pass
22-
def __gt__(self, x: 'tuple') -> bool: pass
23-
def __ge__(self, x: 'tuple') -> bool: pass
20+
def __lt__(self, x: Tuple[Tco, ...]) -> bool: pass
21+
def __le__(self, x: Tuple[Tco, ...]) -> bool: pass
22+
def __gt__(self, x: Tuple[Tco, ...]) -> bool: pass
23+
def __ge__(self, x: Tuple[Tco, ...]) -> bool: pass
2424

2525
class function: pass
2626

@@ -70,6 +70,7 @@ class complex:
7070

7171
class BaseException: pass
7272

73-
def __print(a1=None, a2=None, a3=None, a4=None): pass
73+
def __print(a1: object = None, a2: object = None, a3: object = None,
74+
a4: object = None) -> None: pass
7475

7576
class ellipsis: pass

0 commit comments

Comments
 (0)