Skip to content

Commit b148276

Browse files
committed
fix: 3753 fix false positive wps457
1 parent f55a9c2 commit b148276

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

  • wemake_python_styleguide/visitors/ast

wemake_python_styleguide/visitors/ast/loops.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class WrongLoopVisitor(base.BaseNodeVisitor):
114114
ast.Raise,
115115
# We only check for `try/except`, not `try/finally`:
116116
ast.ExceptHandler,
117+
ast.Await,
117118
)
118119

119120
_containers: ClassVar[_ContainerSpec] = {
@@ -175,14 +176,8 @@ def _check_infinite_while_loop(self, node: AnyLoop) -> None:
175176

176177
with suppress(ValueError):
177178
evaled = ast.literal_eval(node.test)
178-
if isinstance(evaled, ast.Name) or not bool(evaled):
179-
return
180-
181-
has_await = any(walk.get_subnodes_by_type(node, ast.Await))
182-
if has_await:
183-
return
184-
185-
self.add_violation(InfiniteWhileLoopViolation(node))
179+
if not isinstance(evaled, ast.Name) and bool(evaled):
180+
self.add_violation(InfiniteWhileLoopViolation(node))
186181

187182

188183
@final

0 commit comments

Comments
 (0)