ruff/crates/ruff_linter/src
Charlie Marsh d1a7bc38ff
Enable annotation quoting for multi-line expressions (#9142)
Given:

```python
x: DataFrame[
    int
] = 1
```

We currently wrap the annotation in single quotes, which leads to a
syntax error:

```python
x: "DataFrame[
    int
]" = 1
```

There are a few options for what to suggest for users here... Use triple
quotes:

```python
x: """DataFrame[
    int
]""" = 1
```

Or, use an implicit string concatenation (which may require
parentheses):

```python
x: ("DataFrame["
    "int"
"]") = 1
```

The solution I settled on here is to use the `Generator`, which
effectively means we write it out on a single line, like:

```python
x: "DataFrame[int]" = 1
```

It's kind of the "least opinionated" solution, but it does mean we'll
expand to a very long line in some cases.

Closes https://github.com/astral-sh/ruff/issues/9136.
2023-12-15 01:03:09 +00:00
..
checkers Add as_slice method for all string nodes (#9111) 2023-12-13 06:31:20 +00:00
comments Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
cst Update string nodes for implicit concatenation (#7927) 2023-11-24 17:55:41 -06:00
docstrings Split Constant to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
fix [pylint] Add add_argument utility and autofix for PLW1514 (#8928) 2023-12-01 18:23:56 +00:00
importer Update to Rust 1.74 and use new clippy lints table (#8722) 2023-11-16 18:12:46 -05:00
lex Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
message Feature: Add SARIF output support (#9078) 2023-12-13 00:33:19 -05:00
registry [refurb] Implement implicit-cwd (FURB177) (#7704) 2023-09-29 02:18:59 +00:00
rules Enable annotation quoting for multi-line expressions (#9142) 2023-12-15 01:03:09 +00:00
settings Feature: Add SARIF output support (#9078) 2023-12-13 00:33:19 -05:00
snapshots Allow transparent cell magics (#8911) 2023-12-07 14:15:43 -06:00
codes.rs [refurb] Implement hashlib-digest-hex (FURB181) (#9077) 2023-12-10 02:00:11 +00:00
directives.rs Add support for PEP 701 (#7376) 2023-09-29 02:55:39 +00:00
doc_lines.rs Split Constant to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
fs.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
lib.rs Rename Autofix to Fix (#7657) 2023-09-28 10:53:05 +00:00
line_width.rs Rename tab-size to indent-width (#8082) 2023-10-24 10:01:24 -04:00
linter.rs Avoid E703 for last expression in a cell (#8821) 2023-11-23 07:40:57 -06:00
logging.rs Use OneIndexed in NotebookIndex (#7921) 2023-10-13 06:23:49 +05:30
noqa.rs add instructions on line-level suppression to file-level suppression warning (#8052) 2023-10-18 18:46:59 -04:00
packaging.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
pyproject_toml.rs Update pyproject-toml to 0.8 (#8351) 2023-10-30 10:05:37 +00:00
registry.rs Update string nodes for implicit concatenation (#7927) 2023-11-24 17:55:41 -06:00
renamer.rs Add a BindingKind for WithItem variables (#8594) 2023-11-09 22:44:49 -05:00
rule_redirects.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00
rule_selector.rs Add explicit-preview-rules to toggle explicit selection of preview rules (#7390) 2023-09-28 15:00:33 -05:00
source_kind.rs Use SourceKind::diff for formatter (#8240) 2023-10-26 11:08:13 +05:30
test.rs Treat display as a builtin in IPython (#8707) 2023-11-16 01:58:44 +00:00
upstream_categories.rs Rename ruff crate to ruff_linter (#7529) 2023-09-20 08:38:27 +02:00