Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ jobs:
# Enable experimental support for installing PEP 723 script dependencies.
TY_UV: scripts
UV_LOCKED: "true"
Comment thread
AlexWaygood marked this conversation as resolved.
run: cargo run --quiet -p ty check scripts/*.py --color=always
run: |
uv run --locked scripts/check-scripts.py --write-ty-args-file "$RUNNER_TEMP/script-paths.txt"
cargo run --quiet -p ty check "@$RUNNER_TEMP/script-paths.txt" --color=always
# Check for broken links in the documentation.
- run: cargo doc --all --no-deps
env:
Expand Down
7 changes: 5 additions & 2 deletions crates/ruff_python_ast/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,16 @@ def fields_in_source_order(self) -> list[Field]:

fields = []
for field_name in self.source_order:
field = None
for field in self.fields:
if field.skip_source_order():
continue
if field.name == field_name:
fields.append(field)
break
fields.append(field)
else:
raise ValueError(
f"{self.name}: no source-order field named {field_name!r}"
)
return fields


Expand Down
9 changes: 0 additions & 9 deletions crates/ruff_python_ast/generate.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.11"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
9 changes: 0 additions & 9 deletions crates/ty_python_semantic/mdtest.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ requires-python = ">=3.11"
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"

[manifest]
requirements = [
{ name = "rich" },
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ typeshed-formatting = [

[tool.uv]
no-build = true
# By default, uv records all `exclude-newer-package` exemptions in the lockfile for
# every script in the repo, even when the corresponding package is not in the
# lockfile for that script. This preview feature omits those entries, so changes
# to unrelated exemptions don't cause script lockfiles to be updated when refreshed.
# https://docs.astral.sh/uv/concepts/preview/#missing-exclude-newer-package-lock
preview-features = ["missing-exclude-newer-package-lock"]
# The `missing-exclude-newer-package-lock` preview feature requires uv 0.12.10 or later.
# Before uv 0.12.10, adding an unrelated `exclude-newer-package` exemption could
# also cause uv to update a script's lockfile the next time the script was run,
# leading to unexpected lockfile changes in PRs.
required-version = ">=0.12.10"
# CI installs the local ecosystem runner and tools pinned to Git revisions.
no-binary-package = [
"black",
Expand Down
9 changes: 0 additions & 9 deletions scripts/add_plugin.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.12"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
9 changes: 0 additions & 9 deletions scripts/add_rule.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.12"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
9 changes: 0 additions & 9 deletions scripts/build_ruff_pgo.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.11"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
9 changes: 0 additions & 9 deletions scripts/bump-workspace-crate-versions.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.13"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
9 changes: 0 additions & 9 deletions scripts/check-cargo-bans.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.12"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
125 changes: 125 additions & 0 deletions scripts/check-scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/usr/bin/env -S uv run --script
#
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "pathspec>=1.1.1",
# ]
#
# [tool.ty.rules]
# truthiness-test-of-none-union = "warn"
# blanket-ignore-comment = "warn"
# missing-type-argument = "warn"
# possibly-unresolved-reference = "warn"
# unsound-return-statement = "warn"
# unsound-yield = "warn"
# unsupported-dynamic-base = "warn"
# division-by-zero = "warn"
# dynamic-function-decorator-return = "warn"
# unsound-assignment = "warn"
# redundant-condition-strict = "warn"
# disjoint-cast = "warn"
# missing-direct-dependency = "warn"
# ///

"""Update script lockfiles.

Run `uv run scripts/check-scripts.py` to update the lockfiles.
Use `--write-ty-args-file <path>` to write the discovered scripts to an argument file for ty
instead of updating lockfiles.
"""

from __future__ import annotations

import argparse
import subprocess
import sys
from collections.abc import Iterator
from pathlib import Path

from pathspec import GitIgnoreSpec

ROOT = Path(__file__).resolve().parent.parent
# Crate resources and completion fixtures are inputs, not project scripts.
COMPLETION_FIXTURES = Path("crates/ty_completion_eval/truth")


def scripts() -> Iterator[Path]:
Comment thread
MichaReiser marked this conversation as resolved.
"""Yield paths to Python scripts containing PEP 723 metadata.

The paths are relative to the repository root. Files ignored by the root
`.gitignore`, symlinks, crate resources, and completion fixtures are
excluded. Scripts with invalid metadata are included so `uv lock` can
report the error.
"""

gitignore = GitIgnoreSpec.from_lines((ROOT / ".gitignore").read_text().splitlines())

# uv's script listing skips invalid metadata, so find candidates before
# asking uv to validate and lock them.
#
# We use `.walk()` here rather than `.rglob()` because some of our ignored directories are
# huge; `.walk()` allows us to lazily inspect whether they're gitignored before recursively
# descending into them.
for directory, dirnames, filenames in ROOT.walk():
dirnames[:] = [
dirname
for dirname in dirnames
if (path := (directory / dirname).relative_to(ROOT)) != Path(".git")
and not gitignore.match_file(f"{path.as_posix()}/")
]

for filename in filenames:
if not filename.endswith(".py"):
continue

full_path = directory / filename

path = full_path.relative_to(ROOT)

if path.is_relative_to(COMPLETION_FIXTURES):
continue

match full_path.relative_to(ROOT).parts:
case ("crates", _, "resources", *_):
continue

if (
full_path.is_symlink()
or not full_path.is_file()
or gitignore.match_file(path)
):
continue

if b"# /// script" in full_path.read_bytes().splitlines():
Comment thread
AlexWaygood marked this conversation as resolved.
yield path


def main() -> int:
parser = argparse.ArgumentParser(description=__doc__, allow_abbrev=False)
parser.add_argument(
"--write-ty-args-file",
type=Path,
help="Write script paths to an argument file for ty",
)
args = parser.parse_args()

if args.write_ty_args_file is not None:
args.write_ty_args_file.write_text(
"".join(f"{script}\n" for script in scripts()), encoding="utf-8"
)
return 0

failed = False

for script in scripts():
print(script, flush=True)
command = ["uv", "lock", "--script", str(script), "--refresh", "--no-locked"]
result = subprocess.run(command, cwd=ROOT, check=False)
failed |= result.returncode != 0

return int(failed)


if __name__ == "__main__":
sys.exit(main())
19 changes: 19 additions & 0 deletions scripts/check-scripts.py.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version = 1
revision = 3
requires-python = ">=3.12"

[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[manifest]
requirements = [{ name = "pathspec", specifier = ">=1.1.1" }]

[[package]]
name = "pathspec"
version = "1.1.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/5a/82/42f767fc1c1143d6fd36efb827202a2d997a375e160a71eb2888a925aac1/pathspec-1.1.1.tar.gz", hash = "sha256:17db5ecd524104a120e173814c90367a96a98d07c45b2e10c2f3919fff91bf5a", size = 135180, upload-time = "2026-04-27T01:46:08.907Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/f1/d9/7fb5aa316bc299258e68c73ba3bddbc499654a07f151cba08f6153988714/pathspec-1.1.1-py3-none-any.whl", hash = "sha256:a00ce642f577bf7f473932318056212bc4f8bfdf53128c78bbd5af0b9b20b189", size = 57328, upload-time = "2026-04-27T01:46:07.06Z" },
]
9 changes: 0 additions & 9 deletions scripts/check_docs_formatted.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ requires-python = ">=3.12"
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"

[manifest]
requirements = [{ name = "ruff" }]

Expand Down
9 changes: 0 additions & 9 deletions scripts/collect_ty_ecosystem_run_metadata.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.11"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
9 changes: 0 additions & 9 deletions scripts/conformance.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.12"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
9 changes: 0 additions & 9 deletions scripts/ecosystem_all_check.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ requires-python = ">=3.12"
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"

[manifest]
requirements = [{ name = "tqdm" }]

Expand Down
9 changes: 0 additions & 9 deletions scripts/generate-crate-readmes.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.13"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
9 changes: 0 additions & 9 deletions scripts/generate_builtin_modules.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ requires-python = ">=3.12"
[options]
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"
9 changes: 0 additions & 9 deletions scripts/generate_known_standard_library.py.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ requires-python = ">=3.12"
exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
exclude-newer-span = "P7D"

[options.exclude-newer-package]
astral-dev-toolchain-cargo-codspeed = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-deny = "2026-09-15T19:10:00Z"
astral-dev-toolchain-cargo-fuzz = "2026-09-01T00:00:00Z"
astral-dev-toolchain-cargo-insta = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-nextest = "2026-08-27T00:00:00Z"
astral-dev-toolchain-cargo-shear = "2026-08-27T00:00:00Z"
astral-dev-toolchain-hyperfine = "2026-08-27T00:00:00Z"

[manifest]
requirements = [{ name = "stdlibs" }]

Expand Down
Loading
Loading