Skip to content

Allow the walrus operator to be used in the while loop in WPS332 #3505

@MatMerd

Description

@MatMerd

WPS332 prohibits the use of the walrus operator (:=) outside of comprehensions, but I think it could be allowed for the while loop too. Example:

while something := fetch_something(offset, limit, filters):
    DO_WORK

I think it looks clear and as readable as the standard while loop code.

while True:
    something = fetch_something(offset, limit, filters)
    if not something:
        break
    DO_WORK

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions