Skip to content

Commit 207c56e

Browse files
committed
replace the critical in comparisons for testing
1 parent 23bfd4e commit 207c56e

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

mypy/checkexpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3575,7 +3575,7 @@ def visit_comparison_expr(self, e: ComparisonExpr) -> Type:
35753575

35763576
# Only show dangerous overlap if there are no other errors. See
35773577
# testCustomEqCheckStrictEquality for an example.
3578-
if not w.has_new_errors() and operator in ("==", "!="):
3578+
if not w.has_new_errors() and (operator == "==" or operator == "!="):
35793579
right_type = self.accept(right)
35803580
if self.dangerous_comparison(left_type, right_type):
35813581
# Show the most specific literal types possible

mypy/find_sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def find_sources_in_dir(self, path: str) -> list[BuildSource]:
106106
names = sorted(self.fscache.listdir(path), key=keyfunc)
107107
for name in names:
108108
# Skip certain names altogether
109-
if name in ("__pycache__", "site-packages", "node_modules") or name.startswith("."):
109+
if (name == "__pycache__" or name == "site-packages" or name == "node_modules") or name.startswith("."):
110110
continue
111111
subpath = os.path.join(path, name)
112112

mypy/reachability.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def infer_condition_value(expr: Expression, options: Options) -> int:
130130
name = expr.name
131131
elif isinstance(expr, OpExpr) and expr.op in ("and", "or"):
132132
left = infer_condition_value(expr.left, options)
133-
if (left in (ALWAYS_TRUE, MYPY_TRUE) and expr.op == "and") or (
134-
left in (ALWAYS_FALSE, MYPY_FALSE) and expr.op == "or"
133+
if ((left == ALWAYS_TRUE or left == MYPY_TRUE) and expr.op == "and") or (
134+
(left == ALWAYS_FALSE or left == MYPY_FALSE) and expr.op == "or"
135135
):
136136
# Either `True and <other>` or `False or <other>`: the result will
137137
# always be the right-hand-side.

mypy/semanal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5301,13 +5301,13 @@ def visit_op_expr(self, expr: OpExpr) -> None:
53015301

53025302
if expr.op in ("and", "or"):
53035303
inferred = infer_condition_value(expr.left, self.options)
5304-
if (inferred in (ALWAYS_FALSE, MYPY_FALSE) and expr.op == "and") or (
5305-
inferred in (ALWAYS_TRUE, MYPY_TRUE) and expr.op == "or"
5304+
if ((inferred == ALWAYS_FALSE or inferred == MYPY_FALSE) and expr.op == "and") or (
5305+
(inferred == ALWAYS_TRUE or inferred == MYPY_TRUE) and expr.op == "or"
53065306
):
53075307
expr.right_unreachable = True
53085308
return
5309-
elif (inferred in (ALWAYS_TRUE, MYPY_TRUE) and expr.op == "and") or (
5310-
inferred in (ALWAYS_FALSE, MYPY_FALSE) and expr.op == "or"
5309+
elif ((inferred == ALWAYS_TRUE or inferred == MYPY_TRUE) and expr.op == "and") or (
5310+
(inferred == ALWAYS_FALSE or inferred == MYPY_FALSE) and expr.op == "or"
53115311
):
53125312
expr.right_always = True
53135313

0 commit comments

Comments
 (0)