flake8-pie
flake8-pie copied to clipboard
`foo or bar` instead of `foo if foo else bar`
aka when checking the truthiness of the value, or is shorter
# err
foo if foo else bar
foo.buzz if foo.buzz else bar
# ok
foo.buzz if cond else bar
# essentially anytime the test in the if expression doesn't match the value being returned in the truthy case, we'd allow it
foo or bar
This is somewhat tricky to implement as there isn't an easy way to compare the two AST trees to ensure they are equivalent
rel: https://github.com/sbdchd/flake8-pie/pull/84/files#diff-2cef682e5cbc4dc317854e5887d9f23ac9a3421cbb53a95f621808bcc8165244R8