ruff/crates/ruff_python_formatter/src
Charlie Marsh f401050878
Introduce PythonWhitespace to confine trim operations to Python whitespace (#4994)
## Summary

We use `.trim()` and friends in a bunch of places, to strip whitespace
from source code. However, not all Unicode whitespace characters are
considered "whitespace" in Python, which only supports the standard
space, tab, and form-feed characters.

This PR audits our usages of `.trim()`, `.trim_start()`, `.trim_end()`,
and `char::is_whitespace`, and replaces them as appropriate with a new
`.trim_whitespace()` analogues, powered by a `PythonWhitespace` trait.

In general, the only place that should continue to use `.trim()` is
content within docstrings, which don't need to adhere to Python's
semantic definitions of whitespace.

Closes #4991.
2023-06-09 21:44:50 -04:00
..
comments Introduce PythonWhitespace to confine trim operations to Python whitespace (#4994) 2023-06-09 21:44:50 -04:00
expression Fix binary expression formatting with leading comments (#4964) 2023-06-09 09:02:50 +00:00
module Replace verbatim text with NOT_YET_IMPLEMENTED (#4904) 2023-06-07 14:57:25 +02:00
other Track formatted comments (#4979) 2023-06-09 09:09:45 +00:00
pattern Replace verbatim text with NOT_YET_IMPLEMENTED (#4904) 2023-06-07 14:57:25 +02:00
snapshots Fix binary expression formatting with leading comments (#4964) 2023-06-09 09:02:50 +00:00
statement Format if statements (#4961) 2023-06-09 10:55:14 +02:00
builders.rs Add basic Constant formatting (#4954) 2023-06-08 11:42:44 +00:00
cli.rs Add a formatter CLI for debugging (#4809) 2023-06-05 07:33:33 +00:00
context.rs Format binary expressions (#4862) 2023-06-06 08:34:53 +00:00
generated.rs Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
lib.rs Format if statements (#4961) 2023-06-09 10:55:14 +02:00
main.rs Add a formatter CLI for debugging (#4809) 2023-06-05 07:33:33 +00:00
prelude.rs Suite formatting and JoinNodesBuilder (#4805) 2023-06-02 14:14:38 +00:00
trivia.rs Move Python whitespace utilities into new ruff_python_whitespace crate (#4993) 2023-06-10 00:59:57 +00:00