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

[rule] simpify x if x else y to x or y #5377

Closed
dorschw opened this issue Jun 26, 2023 · 4 comments
Closed

[rule] simpify x if x else y to x or y #5377

dorschw opened this issue Jun 26, 2023 · 4 comments
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule

Comments

@dorschw
Copy link

dorschw commented Jun 26, 2023

I wanted to suggest it to flake8-simplify but there hasn't been much activity there in a while, and flake8-pie says they're deprecated and link to ruff.

x = ...
- y = x if x else 'default'
+ y = x or 'default'

It could be a bit confusing to newcomers, but cleaner, imo, to anyone familiar with ternaries in Python.

@charliermarsh charliermarsh added question Asking for support or clarification rule Implementing or modifying a lint rule labels Jun 27, 2023
@evanrittenhouse
Copy link
Contributor

I think the logic here should be pretty closely related to ExprOrTrue.

@evanrittenhouse
Copy link
Contributor

@charliermarsh I can implement this if we want to do it, but it'll diverge from upstream. Is that alright?

@charliermarsh charliermarsh added needs-decision Awaiting a decision from a maintainer and removed question Asking for support or clarification labels Jul 10, 2023
@dosisod
Copy link
Contributor

dosisod commented Aug 17, 2023

This is implemented as FURB110 in Refurb (see #1348), so you could put this check under that category.

@charliermarsh
Copy link
Member

Closed by #10687.

@charliermarsh charliermarsh added preview Related to preview mode features and removed needs-decision Awaiting a decision from a maintainer labels Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

4 participants