wemake-python-styleguide
wemake-python-styleguide copied to clipboard
Forbid implicit `all` or `any` pattern
Rule request
Thesis
Sometimes you can find a code like this:
for ... in ...:
if ...:
return False # or True
return True # or False
And this ugly imperative logic can be easily replaced with pretty all()
or any()
calls.
Notice that we don't care about all
or any
specifics. And treat them equally. Because they can be easily refactored into each other.
Reasoning
It really improves readability of your code. It should be a refactoring pattern.
I am a student from U of M. My partner and I need to help patch an issue for our project, may we take this?
@jdrober9 you are more than welcome! 👍
I would like to work on this please.
@karlmarx awesome! Thanks!
Hey there, I am a first time contributor. Is this issue still up for grabs?
Yes, feel free :)
Sounds good. I would like to work on this. Could you assign this to me? @sobolevn
And also, I ran mypy
against the cloned repo (master branch) and it was showing errors in the source files.
wemake_python_styleguide/logic/tree/functions.py:86: error: "arguments" has no attribute "posonlyargs"; maybe "kwonlyargs"? [attr-defined]
wemake_python_styleguide/logic/tree/functions.py:104: error: "arguments" has no attribute "posonlyargs"; maybe "kwonlyargs"? [attr-defined]
wemake_python_styleguide/visitors/ast/operators.py:228: error: Name "ast.NamedExpr" is not defined [name-defined]
wemake_python_styleguide/visitors/ast/functions.py:476: error: "arguments" has no attribute "posonlyargs"; maybe "kwonlyargs"? [attr-defined]
wemake_python_styleguide/visitors/ast/naming/validation.py:58: error: Too many arguments for "_NamingPredicate" [call-arg]
wemake_python_styleguide/visitors/ast/naming/validation.py:62: error: Too many arguments for "_NamingPredicate" [call-arg]
wemake_python_styleguide/visitors/ast/naming/validation.py:66: error: Too many arguments for "_NamingPredicate" [call-arg]
wemake_python_styleguide/visitors/ast/naming/validation.py:121: error: Too many arguments for "_NamingPredicate" [call-arg]
wemake_python_styleguide/visitors/ast/naming/validation.py:126: error: Too many arguments for "_NamingPredicate" [call-arg]
wemake_python_styleguide/visitors/ast/naming/validation.py:131: error: Too many arguments for "_NamingPredicate" [call-arg]
wemake_python_styleguide/visitors/ast/naming/validation.py:135: error: Too many arguments for "_NamingPredicate" [call-arg]
Found 75 errors in 13 files (checked 145 source files)
Is this normal? Or should I use another branch?
CI says that it works: https://github.com/wemake-services/wemake-python-styleguide/actions/runs/5735582765/job/15543550904