Skip to content

Simplify using flake8-simplify #391

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

Closed
wants to merge 3 commits into from

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Apr 25, 2023

% ruff --select=SIM108,SIM118 --fix .

Found 7 errors (7 fixed, 0 remaining).

% ruff rule SIM108

if-else-block-instead-of-if-exp (SIM108)

Derived from the flake8-simplify linter.

Autofix is sometimes available.

Message formats:

  • Use ternary operator {contents} instead of if-else-block

% ruff rule SIM118

in-dict-keys (SIM118)

Derived from the flake8-simplify linter.

Autofix is always available.

Message formats:

  • Use {key} in {dict} instead of {key} in {dict}.keys()

value = "true"
else:
value = "false"
value = "true" if value else "false"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would disable this. It’s harder to read, generates more diff noise if you change either branch, and vertical height isn’t a strictly limited resource.

@cclauss
Copy link
Contributor Author

cclauss commented Apr 25, 2023

Closing in favor of #392

@cclauss cclauss closed this Apr 25, 2023
@cclauss cclauss deleted the simplify branch April 25, 2023 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants