Skip to content

make some tidy errors around python easier to understand#158552

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

make some tidy errors around python easier to understand#158552
jyn514 wants to merge 2 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.

@clubby789 clubby789 Jun 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you think it would make sense to have a brief note about the historical context here? In isolation, TIDY_PRINT_DIFF being used to only disable diffs seems a bit surprising

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

does it make sense to just remove it altogether, then? i'm not entirely sure why it's an option at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants