Rollup merge of #135950 - Kobzol:tidy-python-improvements, r=onur-ozkan
Tidy Python improvements Fixes display of Python formatting diffs in tidy, and refactors the code to make it simpler and more robust. Also documents Python formatting and linting in the Rustc dev guide. Fixes: https://github.com/rust-lang/rust/issues/135942 r? `@onur-ozkan`
This commit is contained in:
commit
3dcb2ad5d9
|
|
@ -25,6 +25,7 @@ pass the <!-- date-check: nov 2022 --> `--edition=2021` argument yourself when c
|
||||||
`rustfmt` directly.
|
`rustfmt` directly.
|
||||||
|
|
||||||
[fmt]: https://github.com/rust-dev-tools/fmt-rfcs
|
[fmt]: https://github.com/rust-dev-tools/fmt-rfcs
|
||||||
|
|
||||||
[`rustfmt`]:https://github.com/rust-lang/rustfmt
|
[`rustfmt`]:https://github.com/rust-lang/rustfmt
|
||||||
|
|
||||||
## Formatting C++ code
|
## Formatting C++ code
|
||||||
|
|
@ -40,6 +41,26 @@ When modifying that code, use this command to format it:
|
||||||
This uses a pinned version of `clang-format`, to avoid relying on the local
|
This uses a pinned version of `clang-format`, to avoid relying on the local
|
||||||
environment.
|
environment.
|
||||||
|
|
||||||
|
## Formatting and linting Python code
|
||||||
|
|
||||||
|
The Rust repository contains quite a lof of Python code. We try to keep
|
||||||
|
it both linted and formatted by the [ruff][ruff] tool.
|
||||||
|
|
||||||
|
When modifying Python code, use this command to format it:
|
||||||
|
```sh
|
||||||
|
./x test tidy --extra-checks=py:fmt --bless
|
||||||
|
```
|
||||||
|
|
||||||
|
and the following command to run lints:
|
||||||
|
```sh
|
||||||
|
./x test tidy --extra-checks=py:lint
|
||||||
|
```
|
||||||
|
|
||||||
|
This uses a pinned version of `ruff`, to avoid relying on the local
|
||||||
|
environment.
|
||||||
|
|
||||||
|
[ruff]: https://github.com/astral-sh/ruff
|
||||||
|
|
||||||
<a id="copyright"></a>
|
<a id="copyright"></a>
|
||||||
|
|
||||||
<!-- REUSE-IgnoreStart -->
|
<!-- REUSE-IgnoreStart -->
|
||||||
|
|
@ -165,4 +186,5 @@ to the compiler.
|
||||||
crate-related, often the spelling is changed to `krate`.
|
crate-related, often the spelling is changed to `krate`.
|
||||||
|
|
||||||
[tcx]: ./ty.md
|
[tcx]: ./ty.md
|
||||||
|
|
||||||
[crates]: ./crates-io.md
|
[crates]: ./crates-io.md
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue