ruff/crates
Dhruv Manilawala cb34e6d322
Avoid parenthesizing comprehension element (#6198)
## Summary

This PR adds a new precedence level for the comprehension element. This fixes
the generator to not add parentheses around the comprehension element every
time.

The new precedence level is `COMPREHENSION_ELEMENT` and it should occur after
the `NAMED_EXPR` precedence level because named expressions are always parenthesized.

This matches the behavior of Python `ast.unparse` and tested with the
following snippet:

```python
import ast

code = ""
ast.unparse(ast.parse(code))
```

## Test Plan

Add a bunch of test cases for all the valid nodes at that position.

fixes: #5777
2023-07-31 20:56:42 +05:30
..
flake8_to_ruff Bump version to 0.0.280 (#5965) 2023-07-21 22:36:13 -04:00
ruff Avoid falsely marking non-submodules as submodule aliases (#6182) 2023-07-30 22:16:25 +00:00
ruff_benchmark Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_cache Only use a single cache file per Python package (#5117) 2023-06-19 17:46:13 +02:00
ruff_cli Skip partial duplicates when applying multi-edit fixes (#6144) 2023-07-29 12:11:57 +00:00
ruff_dev Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_diagnostics Skip partial duplicates when applying multi-edit fixes (#6144) 2023-07-29 12:11:57 +00:00
ruff_formatter Respect indent when measuring with MeasureMode::AllLines (#6120) 2023-07-27 10:22:13 -04:00
ruff_index Add unreachable code rule (#5384) 2023-07-04 14:27:23 +00:00
ruff_macros Remove parser dependency from ruff-python-ast (#6096) 2023-07-26 17:47:22 +02:00
ruff_python_ast Ignore end-of-line file exemption comments (#6160) 2023-07-29 00:40:32 +00:00
ruff_python_codegen Avoid parenthesizing comprehension element (#6198) 2023-07-31 20:56:42 +05:30
ruff_python_formatter Preserve backslash in raw string literal (#6152) 2023-07-31 12:48:17 +00:00
ruff_python_index Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_python_literal Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_python_parser Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_python_resolver Avoid walking past root when resolving imports (#6126) 2023-07-27 10:22:13 -04:00
ruff_python_semantic Avoid falsely marking non-submodules as submodule aliases (#6182) 2023-07-30 22:16:25 +00:00
ruff_python_stdlib Fix logging rules with whitespace around dot (#6022) 2023-07-24 05:14:48 +00:00
ruff_python_trivia Ignore end-of-line file exemption comments (#6160) 2023-07-29 00:40:32 +00:00
ruff_shrinking Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_source_file Skip BOM when determining Locator's line starts (#6159) 2023-07-29 11:47:13 +00:00
ruff_text_size Pull in RustPython parser (#6099) 2023-07-27 09:29:11 +00:00
ruff_wasm Skip partial duplicates when applying multi-edit fixes (#6144) 2023-07-29 12:11:57 +00:00