wemake-python-styleguide icon indicating copy to clipboard operation
wemake-python-styleguide copied to clipboard

Forbid implicit `all` or `any` pattern

Open sobolevn opened this issue 4 years ago • 9 comments

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.

sobolevn avatar Mar 08 '20 11:03 sobolevn

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 avatar Mar 28 '20 18:03 jdrober9

@jdrober9 you are more than welcome! 👍

sobolevn avatar Mar 28 '20 20:03 sobolevn

Make sure to read our contributing guides

I am here to help: ask anything you need.

sobolevn avatar Mar 28 '20 20:03 sobolevn

I would like to work on this please.

karlmarx avatar Oct 03 '21 11:10 karlmarx

@karlmarx awesome! Thanks!

sobolevn avatar Oct 03 '21 17:10 sobolevn

Hey there, I am a first time contributor. Is this issue still up for grabs?

kimchidonut0 avatar Aug 05 '23 03:08 kimchidonut0

Yes, feel free :)

sobolevn avatar Aug 05 '23 05:08 sobolevn

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?

kimchidonut0 avatar Aug 05 '23 17:08 kimchidonut0

CI says that it works: https://github.com/wemake-services/wemake-python-styleguide/actions/runs/5735582765/job/15543550904

sobolevn avatar Aug 05 '23 18:08 sobolevn