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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-10-26
skip_specs: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Design

## Where the pin lives

`uv check` takes its `ty` version from the first of these that applies:

1. The `--ty-version` option.
2. The exact version in `uv.lock`, when `ty` is a project dependency or a dependency in the `dev` group.
3. A constrained range (`>=0.0,<0.1`) of `ty`.

Today the step uses the third source, so every `ty` release in the range reaches `main` with no change in the repository.
The change moves the step to the second source with one `ty==0.0.92` entry in the `dev` group. This is the same place that pins `ruff`, `mypy`, `bandit`, `actionlint-py` and `zizmor`.
A person raises the pin in a pull request, and that pull request shows the new diagnostics before they reach `main`.

## Rejected alternatives

- **Pass `--ty-version 0.0.92` in the `uv-check` step of `devops ci`.**
It works, but it keeps a second version number in Python code, away from `uv.lock`, `uv audit` and the outdated-dependency check. The `dev` group is the documented source.
- **Only remove the `cast`.**
Pull request #2283 did it already. It fixes this release of `ty` and leaves the cause: the next release can add a new diagnostic and fail `main` again.
- **Let `uv check` use the range and suppress `redundant-cast` in `[tool.ty.rules]`.**
It lowers a quality threshold, and only the owner can allow that.

## Test

The test reads `pyproject.toml` and `uv.lock` and compares the two. It holds no version number, so a later raise of the pin does not change the test.
It runs no `ty` and reaches no network, as `docs/TESTING.md` requires. The `uv-check` step of `devops ci` is the check that `ty` passes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Proposal

## Why

Issue #2281: `uv run devops ci` failed the `uv check` step on a clean `main`.
`ty` v0.0.92 reported a `redundant-cast` warning in `src/devops_cli/ai/tools/__init__.py`, and the step treats a warning as a failure.
No change in the repository caused the failure. The file did not change, and the `ty` version was not pinned.
`uv check` downloaded the newest `ty` in its default range at run time, so a new `ty` release can fail `main` again at any time.

## What Changes

- Pin `ty==0.0.92` in the `dev` dependency group of `pyproject.toml`, and lock it in `uv.lock`.
`uv check` then uses the exact version in `uv.lock`, as the other gate tools (`ruff`, `mypy`, `bandit`, `zizmor`) already do.
- Add a row for `ty` to the pinned-tool table of the knowledge base.
- Add an offline test that the `dev` group pins `ty` and that `uv.lock` holds the same version.
- The redundant `cast` needs no edit. Pull request #2283 replaced it with `fn: Any = self.function`, and `uv check` passes on `main` with `ty` v0.0.92.
- The change sets `skip_specs: true` in `.openspec.yaml`: no command, option or message changes.
- This change fits in one pull request.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

None.

## Impact

- Code: none.
- Configuration: `pyproject.toml`, `uv.lock`.
- Tests: `tests/test_ci.py`.
- Documentation: `src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md`.

## Feasibility

- Command output on `main` at 7f1145a4, `uv` 0.12.23: `uv check` exited 1 with one `redundant-cast` diagnostic at `src/devops_cli/ai/tools/__init__.py:126`.
- `uv check --ty-version 0.0.91` passed on the same tree, so the new `ty` release is the cause.
- `uv help check` documents the `--ty-version` option: "By default, the exact version resolved in `uv.lock` will be used when `ty` is a project dependency or a dependency in the project's `dev` group. Otherwise, a constrained version range of ty will be used (e.g., `>=0.0,<0.1`)."
- After the pin, `uv check -v` logs `Identified uncached distribution: ty==0.0.92` and the step passes. `uv lock --check` passes.
- On `origin/main` at ad7c38b1, `uv check` already passed with `ty` v0.0.92, because #2283 changed the cast line. This change therefore makes no edit to that file.

## Existing Tool Considered

`uv check` has the pin built in: a `ty` entry in the `dev` group. No new code and no `--ty-version` option in `devops ci` is necessary.
The internal code that the change deletes: none.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Tasks

## 1. Failing test

- [x] Add `test_ci_uv_check_type_checks_with_the_ty_the_lockfile_pins` to `tests/test_ci.py`: the `dev` group pins `ty` and `uv.lock` holds the same version
- Verification: `uv run devops ci test tests/test_ci.py -k type_checks_with_the_ty`

## 2. Pin ty

- [x] Add `ty==0.0.92` to the `dev` group of `pyproject.toml` and run `uv lock`
- Verification: `uv lock --check`
- [x] Confirm that `uv check` passes with the locked `ty`
- Verification: `uv check`
- [x] Add a `ty` row to the pinned-tool table of `src/devops_cli/ai/knowledge_base/devops_cli/python_packages.md`
- Verification: `uv run devops ci test tests/test_kb.py`

## 3. Verification and static checks

- [x] Verify the fail-to-pass check run passes against the base
- Verification: `uv run devops ci fail-to-pass --base origin/main`
- [x] Verify the full static checks pass
- Verification: `uv run devops ci`

## Workflow follow-up

- Pending a person: review the diff in tuicr (`tuicr -r origin/main..HEAD`).
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ dev = [
"pytest-mock==3.16.0",
"ruff==0.16.8",
"mypy==2.3.1",
"ty==0.0.92",
"types-PyYAML==6.0.12.20260906",
"pytest-cov==7.1.0",
"diff-cover==10.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ The development environment leverages modern Python engineering tools managed vi
| :--- | :--- | :--- | :--- |
| **`ruff`** | `0.16.8` | Extreme-speed linter and code formatter running the rule families selected in `pyproject.toml` `[tool.ruff.lint]`. | `uv run ruff check .` / `uv run ruff format .` |
| **`mypy`** | `2.3.1` | Strict static type checker validating 100% type coverage with Pydantic v2 plugin. | `uv run mypy src` |
| **`ty`** | `0.0.92` | Type checker that `uv check` runs. The `dev` group pins it, and `uv check` uses the version in `uv.lock`, so a new release cannot fail `main` with no change in the repository. | `uv check` |
| **`pytest`** | `9.1.1` | Comprehensive unit and integration test runner. | `uv run pytest` |
| **`pytest-asyncio`** | `1.4.0` | Asyncio fixture and test execution plugin for asynchronous tool loops. | Included in pytest suite |
| **`pytest-mock`** | `3.16.0` | Thin wrapper around standard library `unittest.mock` for clean fixture patching. | Included in pytest suite |
Expand Down
16 changes: 16 additions & 0 deletions tests/test_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
import subprocess
import sys
import threading
import tomllib
from collections.abc import Callable, Iterator
from pathlib import Path
from typing import Any, cast
from unittest.mock import patch

import pytest
import typer
from packaging.requirements import Requirement
from typer.testing import CliRunner

from devops_cli.commands import ci as ci_module
Expand Down Expand Up @@ -388,6 +390,20 @@ def mock_run(cmd, *args, **kwargs):
assert (result.exit_code, any("uv" in c and "check" in c for c in called)) == (0, True)


def test_ci_uv_check_type_checks_with_the_ty_the_lockfile_pins() -> None:
"""`uv check` runs the exact `ty` that `uv.lock` resolves when `ty` is in the dev group, so a
new `ty` release cannot fail `main` with no change in the repository (#2281)."""
dev = tomllib.loads((REPO_ROOT / "pyproject.toml").read_text(encoding="utf-8"))[
"dependency-groups"
]["dev"]
lock = tomllib.loads((REPO_ROOT / "uv.lock").read_text(encoding="utf-8"))["package"]
pinned = [str(req.specifier) for req in map(Requirement, dev) if req.name == "ty"]
locked = [package["version"] for package in lock if package["name"] == "ty"]

assert pinned == [f"=={version}" for version in locked]
assert len(locked) == 1


def test_ci_lockfile_command(monkeypatch) -> None:
called = []

Expand Down
27 changes: 27 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading