Skip to content

Support uv check - #5435

Open
kinto0 wants to merge 3 commits into
meta:mainfrom
kinto0:export-D128114982
Open

kinto0 wants to merge 3 commits into
meta:mainfrom
kinto0:export-D128114982

Conversation

@kinto0

@kinto0 kinto0 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary:
Stack context: Check PEP 723 scripts in their own uv environments, and let uv check select files by path, as it does for ty.

  • Add pyrefly check --exclude-scripts. Pyrefly skips the files with a PEP 723 # /// script block that it finds in the project or in the given directories, and still checks files given explicitly.
  • uv check checks a project without its scripts, which must be checked with uv check --script. ty finds the scripts in its own walk and skips them with the same flag, so uv only passes the flag. Without it, uv must find the scripts itself and pass each one as --project-excludes.

Differential Revision: D128114982

Summary:
Stack context: Check PEP 723 scripts in their own uv environments, and let `uv check` select files by path, as it does for ty.

- Add a per-file callback to `ConfigFinder`. It receives the config found for a Python file and may return a config for that file alone. `ConfigFinder::new_constant_with_file` gives a constant finder the same callback. All existing finders pass the config through unchanged.
- A PEP 723 script runs in its own environment, so it needs a different interpreter from the other files under the same config. Today a config finder can only return a config per directory.

Differential Revision: D127959345
Summary:
Stack context: Check PEP 723 scripts in their own uv environments, and let `uv check` select files by path, as it does for ty.

- Add the `use-uv` config option. For each checked file with a `# /// script` block, Pyrefly runs `uv workspace metadata --script <file>` and checks the file with the interpreter of the environment that uv reports. Every other setting comes from the file's config, and every other file keeps the configured or discovered interpreter.
- Today Pyrefly checks a script with the project's interpreter, so it cannot import the script's own dependencies. ty reads script environments from the same `uv workspace metadata` contract (astral-sh/uv#22941). This is the alternative to the `uv` build system in D127889580: uv selects files by path and Pyrefly reads only environments from uv, so Pyrefly never lists a member's files.
- Pyrefly never creates or updates a script's environment. If it does not exist, Pyrefly warns and checks the script with its directory config. Each script's config is cached until the file's modification time or its directory config changes.

Differential Revision: D127959383
Summary:
Stack context: Check PEP 723 scripts in their own uv environments, and let `uv check` select files by path, as it does for ty.

- Add `pyrefly check --exclude-scripts`. Pyrefly skips the files with a PEP 723 `# /// script` block that it finds in the project or in the given directories, and still checks files given explicitly.
- `uv check` checks a project without its scripts, which must be checked with `uv check --script`. ty finds the scripts in its own walk and skips them with the same flag, so uv only passes the flag. Without it, uv must find the scripts itself and pass each one as `--project-excludes`.

Differential Revision: D128114982
@meta-cla meta-cla Bot added the cla signed label Oct 28, 2026
@meta-codesync

meta-codesync Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@kinto0 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D128114982.

@kinto0 kinto0 changed the title Add --exclude-scripts Oct 28, 2026
@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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

Review automatically exported from Phabricator review in Meta.

This branch has not been deployed

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

2 participants