Files
priya-sundaram-devpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
c6c68355f7 ci: add informational ty type-check job (config-only replacement for #15174) (#15180)
* ci: add informational (non-blocking) ty type-check job

* ci: pin ty environment python-version to 3.14

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* pyproject.toml: Ignore some ty rules

* Refactor ty.yml for dependency installation and checks

Updated ty.yml to install test dependencies and modify ty check command.

* Add virtual environment setup to workflow

* ci(ty): install deps with 'uv sync' instead of 'uv pip install .'

The previous 'uv pip install ".[test]"' step failed because this repo is a
flat-layout collection of algorithms, not an installable package: setuptools'
legacy backend errors with 'Multiple top-level packages discovered in a
flat-layout'. Rather than restructuring into a src-layout, mirror the existing
'build' job and use 'uv sync' -- pyproject.toml has no [build-system], so uv
treats the project as virtual and installs only its dependencies. Pin a regular
GIL 3.14 so typed third-party deps resolve, and pull ty in ephemerally with
'uv run --with ty' so it needn't touch the lockfile. Also drop the stray
per-step 'source .venv/bin/activate' (each run: is its own shell, so it was a
no-op). Job stays continue-on-error (informational).

* ci(ty): keep the advisory job green with inline annotations

ty emits ::error annotations via --output-format=github; those render on
the PR diff regardless of the step's exit code. Add '|| true' so the check
stays green (it's informational, not a gate) while findings remain visible
as inline annotations -- avoids a permanent red X on every commit. Remove
'|| true' and continue-on-error to promote ty to a required gate later.

* ci(ty): keep ty's real exit status (drop || true), rely on continue-on-error for non-blocking

* ci(ty): pin the ty run to regular 3.14 and use native --exit-zero

The ty step ran 'uv run --with ty' without --python, so uv re-resolved the
project default (free-threaded 3.14t), where many third-party stubs don't
resolve -- that env-resolution failure, not real type errors, produced the
unresolved-import/unresolved-attribute noise and masked whether [tool.ty.rules]
severities apply. Pin the run to regular 3.14 so ty sees the synced deps.

Replace the continue-on-error/real-status juggling with ty's native --exit-zero
(the analog of 'ruff check --exit-zero'): always exit 0 while --output-format=github
still surfaces findings as inline annotations. continue-on-error stays only as a
crash guard. Documents the --exit-zero -> --exit-zero-on-warning -> gate path.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-04 21:04:55 +02:00

52 lines
2.6 KiB
YAML

# https://docs.astral.sh/ty/
name: ty
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
ty:
runs-on: ubuntu-latest
# Informational only: ty is not yet a required gate. This job surfaces
# type-check findings in the logs so they can be triaged into gradual
# [tool.ty] rules without blocking merges. Flip `continue-on-error` to
# false once the baseline is clean.
continue-on-error: true
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: uv.lock
# Mirror the `build` job: `uv sync` installs the dependencies without
# building this flat-layout repo as a wheel. pyproject.toml has no
# [build-system], so uv treats the project as virtual and installs only
# its dependencies -- no "Multiple top-level packages discovered in a
# flat-layout" error and no need for a src-layout. (`uv pip install .`
# would force that wheel build and fail.) Pin a regular GIL 3.14 so typed
# third-party dependencies resolve; the free-threaded 3.14t interpreter the
# test matrix uses lacks wheels for several of them. ty itself is pulled in
# ephemerally with `--with` so it needn't be added to the lockfile.
- run: uv sync --python 3.14
# Pin the *run* to the same regular-GIL 3.14 too. Without `--python 3.14`
# here, `uv run` re-resolved the project's default interpreter -- the
# free-threaded 3.14t used by the test matrix -- so ty type-checked against
# an env where many third-party stubs don't resolve, drowning real findings
# in `unresolved-import` / `unresolved-attribute` noise. Pinning 3.14 lets
# ty see the synced dependencies, so the `[tool.ty.rules]` severities in
# pyproject.toml apply to a meaningful baseline.
#
# `--exit-zero` is ty's native advisory switch (the analog of ruff's
# `ruff check --exit-zero`): the step always exits 0, yet with
# `--output-format=github` ty still emits ::error annotations that render
# inline on the diff, so findings stay visible without a red X. Promotion
# path: `--exit-zero` (informational, always green) -> `--exit-zero-on-warning`
# (fail only on error-severity, tolerate warnings) -> drop the flag entirely
# to make ty a required gate once the [tool.ty] baseline is clean.
# `continue-on-error: true` above stays as a belt-and-suspenders guard so a
# ty *crash* (not a diagnostic) can never block a merge either.
- run: uv run --python 3.14 --with ty ty check --output-format=github --exit-zero