Skip to content

Include configured extensions in file discovery#23400

Merged
amyreese merged 6 commits intomainfrom
amy/discover-mapped-extensions
Feb 23, 2026
Merged

Include configured extensions in file discovery#23400
amyreese merged 6 commits intomainfrom
amy/discover-mapped-extensions

Conversation

@amyreese
Copy link
Member

When running ruff with --preview, this includes any configured file
extension mappings in the default file discovery globs.

Eg, ruff check --preview --extension foo:py, ruff will default to
including *.foo in the file discovery, preventing the need to set
both an extension map and add a new glob to the include setting.

Issue #23204

@astral-sh-bot
Copy link

astral-sh-bot bot commented Feb 18, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@amyreese amyreese requested a review from ntBre February 18, 2026 19:57
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me, but could we add a test or two? I'm kind of surprised we didn't do this already, but I guess it could be a more common scenario after #23384.

Should we add *.md to INCLUDE_PREVIEW while we're here?

@ntBre ntBre added configuration Related to settings and configuration preview Related to preview mode features labels Feb 18, 2026
@amyreese amyreese force-pushed the amy/discover-mapped-extensions branch from efc6fd5 to 81ecde0 Compare February 19, 2026 23:48
@amyreese
Copy link
Member Author

Added an integration test, but I want to hold off on including *.md by default in this PR, for a couple reasons:

  • I think it's a big enough change that we should have a separate line item in a changelog, and that's more likely to happen with a dedicated PR
  • Micha had a concern around how we handle file discovery and when we show the error message "no python files found", and especially for linting where we don't yet operate on markdown files, we should perhaps have some more nuanced behavior, or at the very least consider if we want to change the error message

@amyreese amyreese force-pushed the amy/discover-mapped-extensions branch from 81ecde0 to 1b2424e Compare February 20, 2026 00:16
@amyreese
Copy link
Member Author

#23434 has a draft PR to add *.md to the default include list in preview mode.

@amyreese amyreese force-pushed the amy/discover-mapped-extensions branch from 1b2424e to 292310c Compare February 23, 2026 20:42
@amyreese
Copy link
Member Author

Moved the test case, and also added a short blurb to the configuration documentation.

@amyreese amyreese merged commit 32a59c2 into main Feb 23, 2026
42 checks passed
@amyreese amyreese deleted the amy/discover-mapped-extensions branch February 23, 2026 23:39
@MichaReiser
Copy link
Member

Does this require any changes to Ruff's VS Code extension/LSP? Seems tricky, so maybe not something we need to solve now but it might be worth opening an issue.

@amyreese
Copy link
Member Author

amyreese commented Mar 3, 2026

I did update the LSP to declare that it supports the Markdown file format, which means if the editor determines the file contents is Markdown, then it should automatically be able to ask Ruff to format it, and same thing for the Python file formats, and as long as Ruff is configured correctly, it should be willing to format that file accordingly.

That said, I just tested this in vscode by creating a Markdown file with a random extension, and then setting it's file type in the editor as Markdown — that gives me the option to Format Document With... and select Ruff, but then it got No result returned, so I'll open an issue and see if I can debug that at some point.

@amyreese
Copy link
Member Author

amyreese commented Mar 3, 2026

Filed astral-sh/ruff-vscode#974

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

Labels

configuration Related to settings and configuration preview Related to preview mode features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants