include .pyw files by default when linting and formatting (#20458)

- Adds test cases exercising file selection by extension with
`--preview` enabled and disabled.
- Adds `INCLUDE_PREVIEW` with file patterns including `*.pyw`.
- In global preview mode, default configuration selects patterns from
`INCLUDE_PREVIEW`.
- Manually tested ruff server with local vscode for both formatting and
linting of a `.pyw` file.

Closes https://github.com/astral-sh/ruff/issues/13246
This commit is contained in:
Amethyst Reese 2025-09-24 08:39:30 -07:00 committed by GitHub
parent fcc76bb7b2
commit 83f80effec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 535 additions and 7 deletions

View file

@ -78,7 +78,9 @@ pub enum TomlSourceType {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum PySourceType {
/// The source is a Python file (`.py`).
/// The source is a Python file (`.py`, `.pyw`).
/// Note: `.pyw` files contain Python code, but do not represent importable namespaces.
/// Consider adding a separate source type later if combining the two causes issues.
#[default]
Python,
/// The source is a Python stub file (`.pyi`).
@ -100,6 +102,7 @@ impl PySourceType {
let ty = match extension {
"py" => Self::Python,
"pyi" => Self::Stub,
"pyw" => Self::Python,
"ipynb" => Self::Ipynb,
_ => return None,
};