Skip to content

upgrade ty - #70

Merged
tony merged 3 commits into
masterfrom
ty
Nov 29, 2026
Merged

tony merged 3 commits into
masterfrom
ty

Conversation

@tony

@tony tony commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #69.

Check all maintained Python files with ty

The previous ty 0.0.110 configuration selected the package, scripts and tests. The new root check also covers the two documentation files and the root pytest configuration. The 51 Python files are byte-identical across the two revisions. The lock update changes only ty. The existing Linux, Windows and macOS checks now select the Python version of their respective jobs. Migration issue · Previous roots · CI matrix

Both the native trunk command and the expanded 51-file trunk control passed. On Python 3.12 and 3.15, the candidate gate reported an injected invalid assignment in each of the 51 files, then passed after restoration. Ruff lint and formatting passed. The local suite ran 257 passing tests with one skip on each interpreter, using isolated tmux sockets. The benchmark compares synthetic strict mypy 2.4.1 with ty 0.0.113 on all 51 unchanged files. Mypy reported 29 errors in 13 files and ty reported none.

Type-checker benchmark

The benchmark uses a synthetic mypy configuration. Its timings apply to the supplied benchmark configuration. Both tools checked the same 51 candidate files with Python 3.12.13. Both targeted Python 3.12. All measured files are byte-identical across the two source snapshots. The two series do not establish a clean-check speed ratio. Mypy settings · Ty settings · Candidate lock

Cache state mypy 2.4.1 ty 0.0.113
Empty checker cache 3913.6 ± 132.0 ms 206.2 ± 19.0 ms
Repeat after two warmups 149.3 ± 2.6 ms 200.9 ± 17.4 ms

The table gives mean wall time and sample standard deviation across 8 fresh CLI processes per cell. mypy 2.4.1 exited 1 (16/16). ty 0.0.113 exited 0 (16/16). hyperfine 1.20.0 timed the installed checker executables on Linux x86_64. Mypy used no configured plugins.

Cold runs cleared the checker cache before each sample. Repeat runs followed two untimed warmups. Mypy reused its module cache. Ty wrote no files under its isolated cache root, so its repeat timings measure another fresh process. The OS page cache stayed warm. Setup and diagnostics ran outside the timed commands.

Synthetic mypy configuration

[tool.mypy]
strict = true
python_version = "3.12"

Diagnostics

Check Exit Errors Warnings
ty-trunk 0 0 0
ty-trunk-maintained 0 0 0
mypy-empty 1 29 0
mypy-repeat 1 29 0
ty-empty 0 0 0
ty-repeat 0 0 0

The examples show 8 distinct checker/rule combinations. The totals include all reported locations.

Samples

Checker State Exit codes, in order Wall times (ms)
mypy cold 1, 1, 1, 1, 1, 1, 1, 1 3780.33, 3800.96, 3841.67, 3884.52, 3883.23, 3902.21, 4041.10, 4174.82
ty cold 0, 0, 0, 0, 0, 0, 0, 0 220.74, 197.96, 228.20, 223.45, 185.41, 202.82, 215.54, 175.68
mypy warm 1, 1, 1, 1, 1, 1, 1, 1 152.68, 145.11, 151.54, 146.41, 151.04, 149.78, 149.67, 148.28
ty warm 0, 0, 0, 0, 0, 0, 0, 0 198.52, 223.13, 192.06, 212.48, 165.61, 212.24, 205.88, 197.46

File manifest

  • conftest.py
  • docs/__init__.py
  • docs/conf.py
  • scripts/__init__.py
  • scripts/bench_vt.py
  • scripts/benchmark.py
  • scripts/generate_ucd.py
  • src/libvt/__about__.py
  • src/libvt/__init__.py
  • src/libvt/__main__.py
  • src/libvt/_grid.py
  • src/libvt/_ucd.py
  • src/libvt/aio.py
  • src/libvt/codec.py
  • src/libvt/config.py
  • src/libvt/contrib/__init__.py
  • src/libvt/contrib/tmux/__init__.py
  • src/libvt/contrib/tmux/capture.py
  • src/libvt/contrib/tmux/control.py
  • src/libvt/contrib/tmux/profile.py
  • src/libvt/events.py
  • src/libvt/exc.py
  • src/libvt/graphics.py
  • src/libvt/input.py
  • src/libvt/modes.py
  • src/libvt/parser.py
  • src/libvt/profiles.py
  • src/libvt/pytest_plugin.py
  • src/libvt/screen.py
  • src/libvt/status.py
  • src/libvt/style.py
  • src/libvt/terminal.py
  • src/libvt/testing.py
  • tests/__init__.py
  • tests/_ghostty_vt.py
  • tests/test_aio.py
  • tests/test_benchmark.py
  • tests/test_codec.py
  • tests/test_differential_ghostty.py
  • tests/test_exc.py
  • tests/test_graphics.py
  • tests/test_input.py
  • tests/test_libvt.py
  • tests/test_parser.py
  • tests/test_pyte_compat.py
  • tests/test_screen.py
  • tests/test_status.py
  • tests/test_terminal.py
  • tests/test_testing.py
  • tests/test_tmux.py
  • tests/test_ucd.py

Reproduce

Run from a clone containing both revisions with bash, uv 0.12.0, hyperfine 1.20.0 and the utilities used below.

$ bash <<'SH'
set -euo pipefail
base=a8dfc4db69e3ef90ac0bfd2684eded55f2a6381d
candidate=ec3240984d005941d646c69ea600a308451d811e
work=$(mktemp -d)
results=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
for side in base candidate; do
  mkdir "$work/$side"
  git archive -o "$work/source.tar" "${!side}"
  tar -xf "$work/source.tar" -C "$work/$side"
done
files=(conftest.py docs/__init__.py docs/conf.py scripts/__init__.py scripts/bench_vt.py scripts/benchmark.py scripts/generate_ucd.py src/libvt/__about__.py src/libvt/__init__.py src/libvt/__main__.py src/libvt/_grid.py src/libvt/_ucd.py src/libvt/aio.py src/libvt/codec.py src/libvt/config.py src/libvt/contrib/__init__.py src/libvt/contrib/tmux/__init__.py src/libvt/contrib/tmux/capture.py src/libvt/contrib/tmux/control.py src/libvt/contrib/tmux/profile.py src/libvt/events.py src/libvt/exc.py src/libvt/graphics.py src/libvt/input.py src/libvt/modes.py src/libvt/parser.py src/libvt/profiles.py src/libvt/pytest_plugin.py src/libvt/screen.py src/libvt/status.py src/libvt/style.py src/libvt/terminal.py src/libvt/testing.py tests/__init__.py tests/_ghostty_vt.py tests/test_aio.py tests/test_benchmark.py tests/test_codec.py tests/test_differential_ghostty.py tests/test_exc.py tests/test_graphics.py tests/test_input.py tests/test_libvt.py tests/test_parser.py tests/test_pyte_compat.py tests/test_screen.py tests/test_status.py tests/test_terminal.py tests/test_testing.py tests/test_tmux.py tests/test_ucd.py)
old_files=("${files[@]}")
unset VIRTUAL_ENV PYTHONPATH PYTHONHOME UV_PROJECT UV_WORKING_DIRECTORY
for key in $(compgen -e | awk '/^(MYPY|TY_)/'); do unset "$key"; done
export UV_PROJECT_ENVIRONMENT="$work/venv"
opts=(--frozen --dev --all-extras --python 3.12.13)
uv sync "${opts[@]}" --project "$work/base"
export VIRTUAL_ENV="$work/venv" PATH="$work/venv/bin:$PATH" NO_COLOR=1
export XDG_CACHE_HOME="$work/xdg-cache" XDG_CONFIG_HOME="$work/xdg-config"
status=0
(cd "$work/base" && ty check --python "$work/venv/bin/python" --python-version 3.12 --output-format concise -- "${old_files[@]}") > "$results/ty-trunk.txt" 2>&1 || status=1
(cd "$work/base" && ty check --python "$work/venv/bin/python" --output-format concise) > "$results/ty-trunk-maintained.txt" 2>&1 || status=1
project=$("$work/venv/bin/python" -c 'import sys,tomllib; print(tomllib.load(open(sys.argv[1], "rb"))["project"]["name"])' "$work/base/pyproject.toml")
uv sync "${opts[@]}" --project "$work/candidate" --reinstall-package "$project"
uv pip list --python "$work/venv/bin/python" --format json | jq -r '.[] | "\(.name)==\(.version)"' > "$results/candidate-constraints.txt"
cat > "$results/overlay-pins.txt" <<'PINS'
ast-serialize==0.13.1
librt==0.17.0
mypy==2.4.1
mypy-extensions==1.2.0
pathspec==1.1.1
PINS
uv pip install --python "$work/venv/bin/python" --constraints "$results/candidate-constraints.txt" --constraints "$results/overlay-pins.txt" mypy==2.4.1
uv pip check --python "$work/venv/bin/python"
cd "$work/candidate"
cat > "$results/synthetic-mypy.toml" <<'TOML'
[tool.mypy]
strict = true
python_version = "3.12"
TOML
mypy=("$work"/venv/bin/mypy --python-executable "$work"/venv/bin/python --config-file "$results"/synthetic-mypy.toml --cache-dir "$work"/mypy-cache --)
ty=("$work"/venv/bin/ty check --python "$work"/venv/bin/python --python-version 3.12 --)
for mode in diagnostics cold warm; do
  for tool in mypy ty; do
    declare -n cmd=$tool
    cache="$work/mypy-cache"
    [[ $tool == mypy ]] || cache="$XDG_CACHE_HOME"
    if [[ $mode == diagnostics ]]; then
      rm -rf "$cache"
      for state in empty repeat; do
        diag=("${cmd[@]}")
        if [[ $tool == ty ]]; then
          diag=("${cmd[@]:0:${#cmd[@]}-1}" --output-format concise --)
        fi
        "${diag[@]}" "${files[@]}" > "$results/$tool-$state.txt" 2>&1 || status=1
      done
      continue
    fi
    controls=()
    if [[ $mode == cold ]]; then
      printf -v clear '%q ' rm -rf "$cache"
      controls=(--prepare "$clear")
    else
      for pass in 1 2; do "${cmd[@]}" "${files[@]}" >/dev/null 2>&1 || status=1; done
    fi
    printf -v command '%q ' "${cmd[@]}" "${files[@]}"
    json="$results/$tool-$mode.json"
    hyperfine --shell=none \
      --runs 8 \
      --ignore-failure \
      --command-name "$tool-$mode" \
      --export-json "$json" \
      "${controls[@]}" "$command"
    jq -e '.results[].exit_codes | length == 8 and all(. == 0)' "$json" || status=1
  done
done
printf 'Raw evidence: %s\n' "$results"
exit "$status"
SH

The Python typing policy describes how to check a proposed signature against downstream callers and when an open input type is appropriate.

Hosted checks

Checks on 55fa34799a7e

Skipped — release.

Passed — test (3.15) · test (3.12) · test-windows · test-macos · test (3.14) · build (3.14) · test (3.13) · test-pypy.

why: The type check should use the supported Python version for each CI job and include maintained Python tooling.
what:
- Pin ty and refresh its lock entry under a package-specific cooldown exception.
- Check the repository from its root and select the target interpreter version in CI.
tony added a commit that referenced this pull request Nov 29, 2026
why: Contributors need the supported checker and its scope in the release notes.
what:
- Summarize the migration and link its pull request.
@tony tony changed the title Update ty and check the complete Python tree upgrade ty Nov 29, 2026
tony added 2 commits November 29, 2026 13:12
why: Contributors need a consistent way to resolve typing ambiguities while preserving the contract callers rely on.
what:
- Describe the limited uses of object and Any at input boundaries.
- Check precise signatures against supported callers, misuse and downstream inference.
why: Contributors need the supported checker and its scope in the release notes.
what:
- Summarize the migration and link its pull request.
@tony
tony merged commit 7fa141a into master Nov 29, 2026
9 checks passed
@tony
tony deleted the ty branch December 5, 2026 12:12
@tony tony mentioned this pull request Dec 5, 2026
35 of 38 tasks

This branch was previously deployed

1 inactive deployment
docs — 55fa3479 Deployed Nov 29, 2026 by tony via build (3.14) #150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the Python ty gate and benchmark the existing checker configuration

1 participant