Skip to content

make some tidy errors around python easier to understand#158552

Open
jyn514 wants to merge 3 commits into
rust-lang:mainfrom
ferrocene:jyn/tidy-errors
Open

make some tidy errors around python easier to understand#158552
jyn514 wants to merge 3 commits into
rust-lang:mainfrom
ferrocene:jyn/tidy-errors

Conversation

@jyn514

@jyn514 jyn514 commented Jun 29, 2026

Copy link
Copy Markdown
Member

someone i was helping hit a tidy python formatting error in CI, tried to run the exact tidy command that bootstrap printed as an error, got another error because rustc isn't installed globally, only locally, and then gave up in frustration because they couldn't tell what tidy even wanted them to fix.

make some targeted improvements.

i'm not sure why diffs were disabled by default before. it's been like that ever since python formatting was originally added in #112482, with no explanation. i think showing the diff is a better default.

before:

$ ./x t tidy --extra-checks=py:fmt
checking python file formatting
Would reformat: ferrocene/ci/scripts/calculate_parameters.py
1 file would be reformatted, 118 files already formatted
rerun tidy with `--extra-checks=py:fmt --bless` to reformat Python code
tidy [extra_checks:python_fmt]: checks with external tool 'ruff' failed
tidy [extra_checks:python_fmt]: FAIL
tidy: The following check failed: extra_checks:python_fmt
Command `/home/ci/project/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/home/ci/project --cargo-path=/home/ci/project/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/home/ci/project/build --concurrency=4 --npm-path=yarn --extra-checks=py:fmt` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1630:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1533:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:00:55
$ /home/ci/project/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/home/ci/project --cargo-path=/home/ci/project/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/home/ci/project/build --concurrency=4 --npm-path=yarn --extra-checks=py:fmt --bless
tidy [CI history]: no base commit found. Some checks will be skipped.

thread 'deps (.)' (25771) panicked at src/tools/tidy/src/deps.rs:700:20:
cmd.exec() failed with `cargo metadata` exited with an error: error: could not execute process `rustc -vV` (never executed)

Caused by:
  No such file or directory (os error 2)

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'main' (25768) panicked at src/tools/tidy/src/main.rs:53:61:
called `Result::unwrap()` on an `Err` value: Any { .. }

after:

checking python file formatting
Would reformat: ferrocene/doc/specification/make.py
1 file would be reformatted, 118 files already formatted

python formatting does not match! Printing diff:
--- ferrocene/doc/specification/make.py
+++ ferrocene/doc/specification/make.py
@@ -64,6 +64,7 @@

     return dest / builder

+
 def build_linkchecker(root):
     repo = root / ".linkchecker"
     src = repo / "src" / "tools" / "linkchecker"

1 file would be reformatted, 118 files already formatted
rerun with `--bless` to reformat Python code: `./x.py test tidy --extra-checks=py:fmt --bless`
thread 'deps (.)' (249572429) panicked at src/tools/tidy/src/deps.rs:696:9:
tidy must be run under bootstrap (./x test tidy), not as a standalone command
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

jyn514 added 2 commits June 29, 2026 10:35
…s a standalone command

- error if RUSTC isn't set, which means it'll fall back to the
  user-installed default (wrong)
- be more specific in `--bless` suggestions that they should use `x test
  tidy`, not tidy directly.
for non-interactive cases, such as CI, this makes it easier to tell what
went wrong without having to interactively debug the problem.
@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

tidy extra checks were modified.

cc @lolbinarycat

The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @BoxyUwU

@rustbot rustbot added A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 29, 2026
@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

r? @clubby789

rustbot has assigned @clubby789.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789, jieyouxu

@rustbot

rustbot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

@jyn514

jyn514 commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

i did not change any dependencies, no.

Comment thread src/tools/tidy/src/extra_checks/mod.rs Outdated

@davidtwco davidtwco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me w/ or w/out removing the TIDY_PRINT_DIFF option

View changes since this review

@rustbot

rustbot commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

rustfmt is developed in its own repository. If possible, consider making this change to rust-lang/rustfmt instead.

cc @rust-lang/rustfmt

@rustbot rustbot added A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. labels Jul 3, 2026
@jyn514

jyn514 commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

rust-lang/rustfmt#6734 strikes again

@jyn514 jyn514 force-pushed the jyn/tidy-errors branch from 31cbb5b to 5987617 Compare July 3, 2026 12:38
@jyn514

jyn514 commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

@rustbot label -T-rustfmt

@rustbot rustbot removed the T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. label Jul 3, 2026
and just always show diffs by default.
not sure why you'd want to hide them.
@jyn514 jyn514 force-pushed the jyn/tidy-errors branch from 5987617 to c286fbb Compare July 3, 2026 12:39
@jyn514

jyn514 commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

(reminder that i no longer have r+ permissions and need someone else to hit the merge button)

@clubby789

clubby789 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@bors r=clubby789,davidtwco rollup

@rust-bors

rust-bors Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c286fbb has been approved by clubby789,davidtwco

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 3, 2026
@jyn514

jyn514 commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

omg bors is a fish now???? this is so good

jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 3, 2026
…y789,davidtwco

make some tidy errors around python easier to understand

someone i was helping hit a tidy python formatting error in CI, tried to run the exact `tidy` command that bootstrap printed as an error, got *another* error because rustc isn't installed globally, only locally, and then gave up in frustration because they couldn't tell what tidy even wanted them to fix.

make some targeted improvements.

i'm not sure why diffs were disabled by default before. it's been like that ever since python formatting was originally added in rust-lang#112482, with no explanation. i think showing the diff is a better default.

before:
```
$ ./x t tidy --extra-checks=py:fmt
checking python file formatting
Would reformat: ferrocene/ci/scripts/calculate_parameters.py
1 file would be reformatted, 118 files already formatted
rerun tidy with `--extra-checks=py:fmt --bless` to reformat Python code
tidy [extra_checks:python_fmt]: checks with external tool 'ruff' failed
tidy [extra_checks:python_fmt]: FAIL
tidy: The following check failed: extra_checks:python_fmt
Command `/home/ci/project/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/home/ci/project --cargo-path=/home/ci/project/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/home/ci/project/build --concurrency=4 --npm-path=yarn --extra-checks=py:fmt` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1630:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1533:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:00:55
$ /home/ci/project/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/home/ci/project --cargo-path=/home/ci/project/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/home/ci/project/build --concurrency=4 --npm-path=yarn --extra-checks=py:fmt --bless
tidy [CI history]: no base commit found. Some checks will be skipped.

thread 'deps (.)' (25771) panicked at src/tools/tidy/src/deps.rs:700:20:
cmd.exec() failed with `cargo metadata` exited with an error: error: could not execute process `rustc -vV` (never executed)

Caused by:
  No such file or directory (os error 2)

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'main' (25768) panicked at src/tools/tidy/src/main.rs:53:61:
called `Result::unwrap()` on an `Err` value: Any { .. }
```

after:

```
checking python file formatting
Would reformat: ferrocene/doc/specification/make.py
1 file would be reformatted, 118 files already formatted

python formatting does not match! Printing diff:
--- ferrocene/doc/specification/make.py
+++ ferrocene/doc/specification/make.py
@@ -64,6 +64,7 @@

     return dest / builder

+
 def build_linkchecker(root):
     repo = root / ".linkchecker"
     src = repo / "src" / "tools" / "linkchecker"

1 file would be reformatted, 118 files already formatted
rerun with `--bless` to reformat Python code: `./x.py test tidy --extra-checks=py:fmt --bless`
```
```
thread 'deps (.)' (249572429) panicked at src/tools/tidy/src/deps.rs:696:9:
tidy must be run under bootstrap (./x test tidy), not as a standalone command
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants