wemake-python-styleguide
wemake-python-styleguide copied to clipboard
Enforce consistent ternary expressions
Rule request
Thesis
We need to fix how we write ternary expressions, currently it has too many options:
some = other if x > 1 else None
some = (
other
if x > 1 else None
)
some = (
other
if x > 1
else None
)
some = (
other if x > 1
else None
)
some = other if x > 1
else None
Probably, there are other cases as well.
So, we should decide which ones we allow and which ones are going to be violations. I know that single line ternary is always good.
To decide - we can analyze the code inside this project.
Related #1266 Related #1706
I like this one:
some = (
other
if x > 1
else None
)