Skip to content

Commit ea563fa

Browse files
committed
fix: 3753 fix false positive wps457
1 parent 6a82d89 commit ea563fa

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Semantic versioning in our case means:
1616
But, in the future we might change the configuration names/logic,
1717
change the client facing API, change code conventions significantly, etc.
1818

19+
## WIP
20+
21+
### Bugfixes
22+
23+
- Fixes false positive `WPS457` for while ``True loop`` with `await` in expression, #3753
24+
1925

2026
## 1.5.0
2127

@@ -30,7 +36,6 @@ Semantic versioning in our case means:
3036

3137
- Fixes `WPS226` false-positive on fstring parts, #3548
3238
- Fixes false positive `WPS412` with docstring and imports in `__init__.py`, #3569
33-
- Fixes false positive `WPS457` for while True loop with await in async function #3753
3439

3540
### Misc
3641

wemake_python_styleguide/visitors/ast/loops.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,8 @@ def _check_infinite_while_loop(self, node: AnyLoop) -> None:
178178
if isinstance(evaled, ast.Name) or not bool(evaled):
179179
return
180180

181-
in_async_function = (
182-
walk.get_closest_parent(node, ast.AsyncFunctionDef) is not None
183-
)
184-
has_await = bool(walk.get_subnodes_by_type(node, ast.Await))
185-
186-
if in_async_function and has_await:
181+
has_await = any(walk.get_subnodes_by_type(node, ast.Await))
182+
if has_await:
187183
return
188184

189185
self.add_violation(InfiniteWhileLoopViolation(node))

0 commit comments

Comments
 (0)