Repository navigation
Switch type checker from pyright to ty - #209
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 passtylocally 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 onpyranges1/.Config
pyright == 1.1.406is replaced byty == 0.0.87, and the tox commandpyrightis nowty check. ty is pre-1.0, so it's pinned to an exact version.devextras:pyrightis replaced byty == 0.0.87. Thepandas-stubs<3cap stays.[tool.pyright]is replaced by[tool.ty], which sets the include/exclude paths (pyranges_groupby.pystays excluded, as before) and allows four unresolved optional imports:pyBigWigandgtfreader._parserare compiled and have no stubs.fisherandfirearen't installed in CI.check_typing_linting_and_formatting.pynow runsty check.Type ignores: 97 → 12
Most
# type: ignore[...]/# pyright: ignore[...]comments weren't needed under ty. Most of them coveredDataFrame.take(ndarray)andruranges.numpy.*calls, which ty accepts. Three spots got real fixes instead of an ignore:core/options.py: the options store is typeddict[str, tuple[Any, str]]. Some options (console_width,html_max_rows) default toNone.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:PyRangesoverridesRangeFrame'scount_overlaps,overlap,join_overlaps,nearest_rangesandsubtract_overlapswith different signatures.RangeFrameoverrides pandas'dropandreindex, andPyRangesoverridesto_parquet.copy, which pandas-stubs marks@final.RangeFramecalls_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: passestests/run_doctest_tutorial_howto.py: 10 passedpytest --doctest-modules pyranges1: 111 passed, 7 skippedpytest tests/unit: 847 passedruff format --checkandruff check: clean🤖 Generated with Claude Code