Multi-line strings with type ignore pragma get merged into a single line #4510
Labels
C: preview style
Issues with the preview and unstable style. Add the name of the responsible feature in the title.
F: strings
Related to our handling of strings
T: bug
Something isn't working
Describe the bug
There is a clash between the process of reflowing multi-line strings and the rule that prevents formatting lines with
# type: ignore
pragma at the end. Here is what happens:To Reproduce
Here is a simple example:
Running
black --unstable example.py
produces:Expected behavior
Probably the best option would be that the multi-line string wouldn't be reflown at all in cases there is a type ignore comment at the end. But the formatting definitely shouldn't produce code that breaks the line length rule.
Environment
24.10.0
Additional context
In practice this issue can appear if users do some f-string operations inside a multi-line string and want to suppress type checking. E.g. the following line also gets incorrectly reflown into a single huge line:
The text was updated successfully, but these errors were encountered: