From 8ca2b5555d47e211c04136637477c5227172d885 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 17 Oct 2025 20:30:17 +0100 Subject: [PATCH] Dogfood ty on py-fuzzer in CI (#20946) --- .github/workflows/ci.yaml | 9 ++++++++- python/py-fuzzer/fuzz.py | 2 +- python/py-fuzzer/pyproject.toml | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0a52349001..f4f0b9b607 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -277,7 +277,8 @@ jobs: run: cargo test -p ty_python_semantic --test mdtest || true - name: "Run tests" run: cargo insta test --all-features --unreferenced reject --test-runner nextest - + # Dogfood ty on py-fuzzer + - run: uv run --project=./python/py-fuzzer cargo run -p ty check --project=./python/py-fuzzer # Check for broken links in the documentation. - run: cargo doc --all --no-deps env: @@ -519,6 +520,7 @@ jobs: with: persist-credentials: false - uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1 + - uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0 - name: "Install Rust toolchain" run: rustup component add rustfmt # Run all code generation scripts, and verify that the current output is @@ -533,6 +535,11 @@ jobs: ./scripts/add_plugin.py test --url https://pypi.org/project/-test/0.1.0/ --prefix TST ./scripts/add_rule.py --name FirstRule --prefix TST --code 001 --linter test - run: cargo check + # Lint/format/type-check py-fuzzer + # (dogfooding with ty is done in a separate job) + - run: uv run --directory=./python/py-fuzzer mypy + - run: uv run --directory=./python/py-fuzzer ruff format --check + - run: uv run --directory=./python/py-fuzzer ruff check ecosystem: name: "ecosystem" diff --git a/python/py-fuzzer/fuzz.py b/python/py-fuzzer/fuzz.py index 22f6965244..eacd7587b2 100644 --- a/python/py-fuzzer/fuzz.py +++ b/python/py-fuzzer/fuzz.py @@ -139,7 +139,7 @@ class FuzzResult: case Executable.TY: panic_message = f"The following code triggers a {new}ty panic:" case _ as unreachable: - assert_never(unreachable) + assert_never(unreachable) # ty: ignore[type-assertion-failure] print(colored(panic_message, "red")) print() diff --git a/python/py-fuzzer/pyproject.toml b/python/py-fuzzer/pyproject.toml index 020f91b899..52bc17f25a 100644 --- a/python/py-fuzzer/pyproject.toml +++ b/python/py-fuzzer/pyproject.toml @@ -32,6 +32,10 @@ warn_unreachable = true local_partial_types = true enable_error_code = "ignore-without-code,redundant-expr,truthy-bool" +[tool.ty.rules] +possibly-unresolved-reference = "error" +unused-ignore-comment = "error" + [tool.ruff] fix = true preview = true