Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIM110 / SIM111: Use any / all #15

Closed
MartinThoma opened this issue Oct 17, 2020 · 0 comments
Closed

SIM110 / SIM111: Use any / all #15

MartinThoma opened this issue Oct 17, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@MartinThoma
Copy link
Owner

MartinThoma commented Oct 17, 2020

Explanation

It's shorter.

Example 1: any

# Bad
for x in iterable:
    if check(x):
        return True
return False

# Good
return any(check(x) for x in iterable)

Example 2: all

# Bad
for x in iterable:
    if check(x):
        return False
return True

# Good
return all(check(x) for x in iterable)
@MartinThoma MartinThoma added the enhancement New feature or request label Oct 17, 2020
@MartinThoma MartinThoma self-assigned this Oct 17, 2020
@MartinThoma MartinThoma changed the title [New Rule] Use any if just one element needs to have a property to define the boolean output [New Rule] Use any / all Oct 17, 2020
@MartinThoma MartinThoma changed the title [New Rule] Use any / all SIM110 / SIM111: Use any / all Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant