ruff/crates/ruff_diagnostics/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
..
diagnostic.rs Implement Ranged on more structs (#6921) 2023-08-27 19:03:08 +00:00
edit.rs Enable annotation quoting for multi-line expressions (#9142) 2023-12-15 01:03:09 +00:00
fix.rs Update applicability messages for clarity in tests (#8541) 2023-11-07 16:11:43 +00:00
lib.rs Rename FixKind to FixAvailability (#7658) 2023-10-02 14:38:25 +00:00
source_map.rs Enable formatting for Jupyter notebooks (#7749) 2023-10-02 14:44:18 +00:00
violation.rs Rename FixKind to FixAvailability (#7658) 2023-10-02 14:38:25 +00:00