You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given list(x for x in y), we first hit C400, which fixes to [x for x in y], which hits C416, which fixes to list(y). We should consider short-circuiting this.
The text was updated successfully, but these errors were encountered:
I would like to contribute on this. Should I implement it on inside C400 or add an another rule which matches only expression of type list(x for x in y)?
…matches `C416` (#10419)
## Summary
Short-circuit implementation mentioned in #10403.
I implemented this by extending C400:
- Made `UnnecessaryGeneratorList` have information of whether the the
short-circuiting occurred (to put diagnostic)
- Add additional check for whether in `unnecessary_generator_list`
function.
Please give me suggestions if you think this isn't the best way to
handle this :)
## Test Plan
Extended `C400.py` a little, and written the cases where:
- Code could be converted to one single conversion to `list` e.g.
`list(x for x in range(3))` -> `list(range(3))`
- Code couldn't be converted to one single conversion to `list` e.g.
`list(2 * x for x in range(3))` -> `[2 * x for x in range(3)]`
- `list` function is not built-in, and should not modify the code in any
way.
Given
list(x for x in y)
, we first hit C400, which fixes to[x for x in y]
, which hits C416, which fixes tolist(y)
. We should consider short-circuiting this.The text was updated successfully, but these errors were encountered: