Skip to content

ruff: Add --extend-exclude to ruff format#26372

Merged
MichaReiser merged 2 commits into
astral-sh:mainfrom
tingerrr:tinger/pmmuyvoryvmz
Jun 27, 2026
Merged

ruff: Add --extend-exclude to ruff format#26372
MichaReiser merged 2 commits into
astral-sh:mainfrom
tingerrr:tinger/pmmuyvoryvmz

Conversation

@tingerrr

@tingerrr tingerrr commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

See commit messages.

Closes #18980

Test Plan

At $dayjob I'm working on a repository in which we call ruff/ty with --extend-exclude because of various reasons. I uninstalled the version of ruff installed by uv and tested this installation, and it did what I expected.

It respected both the default configured excludes in pyproject.toml and the extended excludes passed via --extend-exclude, which I could confirm with both --show-files and simply running the check.

@tingerrr tingerrr marked this pull request as ready for review June 26, 2026 06:41
@astral-sh-bot astral-sh-bot Bot requested a review from ntBre June 26, 2026 06:41
@tingerrr tingerrr force-pushed the tinger/pmmuyvoryvmz branch from e544212 to b7a4e96 Compare June 26, 2026 12:57
@tingerrr

Copy link
Copy Markdown
Contributor Author

It seems that I've introduced a new warning in some snapshot tests. That's probably not intended, so I'll have to look into that. I don't know enough about the codebase to know why this is the case, though.

@ntBre ntBre left a comment

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.

Thanks! This looks reasonable to me compared to the check version. I'll also ping Micha for a review in case it was intentional to exclude these flags, or I'm missing something else.

Comment thread crates/ruff/src/lib.rs Outdated
@ntBre ntBre requested a review from MichaReiser June 26, 2026 13:02
@ntBre ntBre added cli Related to the command-line interface formatter Related to the formatter labels Jun 26, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser removed their request for review June 26, 2026 17:49
@tingerrr tingerrr force-pushed the tinger/pmmuyvoryvmz branch from b7a4e96 to 2942a4b Compare June 27, 2026 09:34
@tingerrr tingerrr changed the title ruff: Add --show-files and --extend-exclude to ruff format ruff: Add --extend-exclude to ruff format Jun 27, 2026

@MichaReiser MichaReiser 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.

This looks good to me. Would you mind adding a regression test in

fn exclude_stdin() -> Result<()> {

@tingerrr

tingerrr commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

This looks good to me. Would you mind adding a regression test in

fn exclude_stdin() -> Result<()> {

I assume you mean tests which use --extend-exclude since the stdin warning arose from resolving the files for --show-files.

@MichaReiser

Copy link
Copy Markdown
Member

Yes, a test for --extend-exclude. I only shared the line so that you roughly know where to add it

This is a config override just like on `ruff check` and behaves the
same, extending the list of paths to exclude instead of ovewriting them.

Fixes astral-sh#18980.
@tingerrr tingerrr force-pushed the tinger/pmmuyvoryvmz branch from 2942a4b to bad3198 Compare June 27, 2026 12:19
@MichaReiser MichaReiser enabled auto-merge (squash) June 27, 2026 13:59
@MichaReiser

Copy link
Copy Markdown
Member

Thank you

@MichaReiser MichaReiser merged commit fa4a7bc into astral-sh:main Jun 27, 2026
46 checks passed
@tingerrr tingerrr deleted the tinger/pmmuyvoryvmz branch June 27, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command-line interface formatter Related to the formatter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why does ruff format not support --extend-exclude?

3 participants