ruff/crates/ruff_python_formatter
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
..
resources/test/fixtures Fix binary expression formatting with leading comments (#4964) 2023-06-09 09:02:50 +00:00
src Introduce PythonWhitespace to confine trim operations to Python whitespace (#4994) 2023-06-09 21:44:50 -04:00
Cargo.toml Move Python whitespace utilities into new ruff_python_whitespace crate (#4993) 2023-06-10 00:59:57 +00:00
Docs.md Generate FormatRule definitions (#4724) 2023-06-01 08:38:53 +02:00
generate.py Format Function definitions (#4951) 2023-06-08 16:07:33 +00:00
orphan_rules_in_the_formatter.svg Generate FormatRule definitions (#4724) 2023-06-01 08:38:53 +02:00