Skip to content

Switch type checker from pyright to ty - #209

Merged
endrebak merged 1 commit into
masterfrom
switch-to-ty
Oct 15, 2026
Merged

endrebak merged 1 commit into
masterfrom
switch-to-ty

Conversation

@endrebak

Copy link
Copy Markdown
Collaborator

Switches the CI type checker from pyright to ty, and removes the type-ignore comments that ty doesn't need.

AGENTS.md already told agents to run ty, but CI ran pyright. Code could pass ty locally and then fail pyright in CI, which happened on #198. With this PR both use the same checker. ty is also much faster: about 0.1s against about 3s for pyright on pyranges1/.

Config

  • tox: pyright == 1.1.406 is replaced by ty == 0.0.87, and the tox command pyright is now ty check. ty is pre-1.0, so it's pinned to an exact version.
  • dev extras: pyright is replaced by ty == 0.0.87. The pandas-stubs<3 cap stays.
  • [tool.pyright] is replaced by [tool.ty], which sets the include/exclude paths (pyranges_groupby.py stays excluded, as before) and allows four unresolved optional imports:
    • pyBigWig and gtfreader._parser are compiled and have no stubs.
    • fisher and fire aren't installed in CI.
  • check_typing_linting_and_formatting.py now runs ty check.

Type ignores: 97 → 12

Most # type: ignore[...] / # pyright: ignore[...] comments weren't needed under ty. Most of them covered DataFrame.take(ndarray) and ruranges.numpy.* calls, which ty accepts. Three spots got real fixes instead of an ignore:

  • core/options.py: the options store is typed dict[str, tuple[Any, str]]. Some options (console_width, html_max_rows) default to None.
  • methods/summary.py: tabulate(df.itertuples(), ...) replaces passing a DataFrame, which types-tabulate doesn't accept. The output is byte-identical.
  • range_frame.py (assert_valid_ranges): getattr(function, "__name__", "<lambda>"), because not every callable has __name__.

The 12 remaining # ty: ignore[<rule>] comments are all deliberate design choices:

  • PyRanges overrides RangeFrame's count_overlaps, overlap, join_overlaps, nearest_ranges and subtract_overlaps with different signatures.
  • RangeFrame overrides pandas' drop and reindex, and PyRanges overrides to_parquet.
  • Both classes override copy, which pandas-stubs marks @final.
  • RangeFrame calls _from_mgr, a private pandas method missing from pandas-stubs.

Removing these would mean changing the public API. Note that pyright would now fail on this code, because the ignores it relied on are gone.

Checks run locally

I ran the full tox command list in a venv matching the tox deps:

  • ty check: passes
  • tests/run_doctest_tutorial_howto.py: 10 passed
  • pytest --doctest-modules pyranges1: 111 passed, 7 skipped
  • pytest tests/unit: 847 passed
  • ruff format --check and ruff check: clean

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@endrebak
endrebak merged commit d30047a into master Oct 15, 2026
4 checks passed
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.

1 participant