Skip to content

Commit 7031574

Browse files
committed
Do not emit redundant-expr warnings for if TYPE_CHECKING statements.
1 parent c387368 commit 7031574

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mypy/checker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5019,7 +5019,10 @@ def visit_if_stmt(self, s: IfStmt) -> None:
50195019

50205020
if_map, else_map = self.find_isinstance_check(e)
50215021

5022-
if codes.REDUNDANT_EXPR in self.options.enabled_error_codes:
5022+
if codes.REDUNDANT_EXPR in self.options.enabled_error_codes and not (
5023+
isinstance(e, NameExpr)
5024+
and e.fullname in ("typing.TYPE_CHECKING", "typing_extensions.TYPE_CHECKING")
5025+
):
50235026
if if_map is None:
50245027
if s.while_stmt:
50255028
self.msg.redundant_condition_in_while(e)

0 commit comments

Comments
 (0)