style: switch type checker from basedpyright to ty#100
Conversation
- Update pyproject.toml: change basedpyright to ty==0.0.17 - Update type-check.yml: change command from basedpyright to ty - Remove [tool.pyright] configuration (ty doesn't use include in config) Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
- Add type casts in check.py and notebook.py for sub_fields parameter - Fix filter() calls in dargs.py to use explicit lambdas - Remove unused type: ignore comments in sphinx.py Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Add comments explaining why lambdas are used instead of bound methods in filter() calls - required for ty type checker compatibility. Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #100 +/- ##
==========================================
- Coverage 74.32% 74.22% -0.10%
==========================================
Files 9 9
Lines 810 811 +1
==========================================
Hits 602 602
- Misses 208 209 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
…in permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Jinzhe Zeng <njzjz@qq.com>
Keep [tool.pyright] section with include field. Not adding [tool.ty] section yet as ty 0.0.17 doesn't support the include field - it causes a parse error. Will reply to comment for clarification. Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Add ty configuration with src table containing root, include, and exclude fields as ty requires a struct format, not a simple array. Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR migrates the type checking tool from basedpyright to ty (v0.0.17), a Rust-based type checker. The migration includes updating dependencies, CI configuration, and fixing type errors that ty identified differently than basedpyright.
Changes:
- Replaced
basedpyright==1.12.2withty==0.0.17in optional dependencies - Updated CI workflow to run
ty checkinstead ofbasedpyright - Added type casts to help ty narrow union types after
isinstance()checks - Fixed filter usage with regex match methods for proper type inference
- Removed unnecessary
type: ignorecomments
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Updated typecheck dependency from basedpyright to ty; added [tool.ty.src] configuration |
| .github/workflows/type-check.yml | Changed CI runner and command to use ty instead of basedpyright |
| dargs/check.py | Added cast to help ty narrow list/tuple union after isinstance check |
| dargs/notebook.py | Added cast to help ty narrow list type after isinstance check |
| dargs/dargs.py | Changed filter calls to use explicit lambda for proper type narrowing with regex matches |
| dargs/sphinx.py | Removed unnecessary type: ignore comments from ClassVar declarations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Migrates type checking from basedpyright to ty (v0.0.17), an extremely fast Rust-based type checker.
Changes
basedpyright==1.12.2withty==0.0.17in optional typecheck dependenciestyinstead ofbasedpyright[tool.pyright]section withinclude = ["dargs"]for compatibility and add[tool.ty.src]configuration withroot = ".",include = ["dargs"], andexclude = []Type error fixes
Type narrowing: Added
cast()to help ty narrow union types afterisinstance()checks:Filter overload resolution: Changed
filter(rem.match, ...)to explicit lambdas for correct overload matching:Cleanup: Removed unused
type: ignorecomments flagged by tyNote
ty configuration uses
[tool.ty.src]as a structured table rather than a simple array like pyright'sincludefield. The src table requiresroot,include, andexcludefields.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.