Skip to content

Commit a70cca8

Browse files
committed
Use new --enable-error-codes functionlity
1 parent 70b10cd commit a70cca8

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

mypy/checkexpr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,7 @@ def check_boolean_op(self, e: OpExpr, context: Context) -> Type:
27472747
# the analysis from the semanal phase below. We assume that nodes
27482748
# marked as unreachable during semantic analysis were done so intentionally.
27492749
# So, we shouldn't report an error.
2750-
if self.chk.options.warn_redundant_expr:
2750+
if codes.REDUNDANT_EXPR in self.chk.options.enabled_error_codes:
27512751
if left_map is None:
27522752
self.msg.redundant_left_operand(e.op, e.left)
27532753

@@ -3682,7 +3682,7 @@ def check_for_comp(self, e: Union[GeneratorExpr, DictionaryComprehension]) -> No
36823682
for var, type in true_map.items():
36833683
self.chk.binder.put(var, type)
36843684

3685-
if self.chk.options.warn_redundant_expr:
3685+
if codes.REDUNDANT_EXPR in self.chk.options.enabled_error_codes:
36863686
if true_map is None:
36873687
self.msg.redundant_condition_in_comprehension(False, condition)
36883688
elif false_map is None:
@@ -3695,7 +3695,7 @@ def visit_conditional_expr(self, e: ConditionalExpr, allow_none_return: bool = F
36953695
# Gain type information from isinstance if it is there
36963696
# but only for the current expression
36973697
if_map, else_map = self.chk.find_isinstance_check(e.cond)
3698-
if self.chk.options.warn_redundant_expr:
3698+
if codes.REDUNDANT_EXPR in self.chk.options.enabled_error_codes:
36993699
if if_map is None:
37003700
self.msg.redundant_condition_in_if(False, e.cond)
37013701
elif else_map is None:

mypy/main.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,6 @@ def add_invertible_flag(flag: str,
578578
help="Warn about statements or expressions inferred to be"
579579
" unreachable",
580580
group=lint_group)
581-
add_invertible_flag('--warn-redundant-expr', default=False, strict_flag=False,
582-
help="Warn about expressions inferred to be redundant",
583-
group=lint_group)
584581

585582
# Note: this group is intentionally added here even though we don't add
586583
# --strict to this group near the end.

mypy/options.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class BuildType:
5151
"strict_optional_whitelist",
5252
"warn_no_return",
5353
"warn_return_any",
54-
"warn_redundant_expr",
5554
"warn_unreachable",
5655
"warn_unused_ignores",
5756
} # type: Final
@@ -175,10 +174,6 @@ def __init__(self) -> None:
175174
# type analysis.
176175
self.warn_unreachable = False
177176

178-
# Report an error for any expressions inferred to be redundant as a result of
179-
# type analysis.
180-
self.warn_redundant_expr = False
181-
182177
# Variable names considered True
183178
self.always_true = [] # type: List[str]
184179

test-data/unit/check-redundant-expr.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- expressions classified as redundant.
33

44
[case testRedundantExpressions]
5-
# flags: --warn-redundant-expr
5+
# flags: --enable-error-code redundant-expr
66
def foo() -> bool: ...
77

88
lst = [1, 2, 3, 4]

0 commit comments

Comments
 (0)