From f3431f791bf4565ee491a5afb146ef7631a4a7e7 Mon Sep 17 00:00:00 2001 From: vldmrdev <70532790+vldmrdev@users.noreply.github.com> Date: Fri, 2 Jan 2026 16:19:16 +0500 Subject: [PATCH] fix: 3753 fix false positive wps457 --- CHANGELOG.md | 6 ++++++ .../test_loops/test_loops/test_infinite_while_loops.py | 7 +++++++ wemake_python_styleguide/visitors/ast/loops.py | 1 + 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ca365bbb..2f09b3a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,12 @@ Semantic versioning in our case means: But, in the future we might change the configuration names/logic, change the client facing API, change code conventions significantly, etc. +## WIP + +### Bugfixes + +- Fixes false positive `WPS457` for ``while True`` loop with ``await`` expressions, #3753 + ## 1.5.0 diff --git a/tests/test_visitors/test_ast/test_loops/test_loops/test_infinite_while_loops.py b/tests/test_visitors/test_ast/test_loops/test_loops/test_infinite_while_loops.py index 016490593..a55672ed2 100644 --- a/tests/test_visitors/test_ast/test_loops/test_loops/test_infinite_while_loops.py +++ b/tests/test_visitors/test_ast/test_loops/test_loops/test_infinite_while_loops.py @@ -99,6 +99,12 @@ def wrapper(): ... """ +correct_while7 = """ +async def worker(): + while True: + await asyncio.sleep(1) +""" + # Do raise: wrong_while1 = """ @@ -166,6 +172,7 @@ def test_correct_while_loops_with_statements( correct_while4, correct_while5, correct_while6, + correct_while7, ], ) def test_correct_while_loops_with_try( diff --git a/wemake_python_styleguide/visitors/ast/loops.py b/wemake_python_styleguide/visitors/ast/loops.py index 6d0a7266c..885658382 100644 --- a/wemake_python_styleguide/visitors/ast/loops.py +++ b/wemake_python_styleguide/visitors/ast/loops.py @@ -114,6 +114,7 @@ class WrongLoopVisitor(base.BaseNodeVisitor): ast.Raise, # We only check for `try/except`, not `try/finally`: ast.ExceptHandler, + ast.Await, ) _containers: ClassVar[_ContainerSpec] = {