Skip to content

Replace mypy with ty for static type checking#1042

Merged
guan404ming merged 1 commit intoapache:mainfrom
guan404ming:mypy-ty
Feb 12, 2026
Merged

Replace mypy with ty for static type checking#1042
guan404ming merged 1 commit intoapache:mainfrom
guan404ming:mypy-ty

Conversation

@guan404ming
Copy link
Member

Changes

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • Test
  • CI/CD pipeline
  • Other

Why

Switch to Astral's ty type checker for faster, more consistent tooling alongside ruff and uv.

How

  • Replace mypy pre-commit hook with ty, add ty to dev dependencies
  • Fix type errors: np.array annotation, dict.get nullability, reduce overload, stale type: ignore comments
  • Configure ty to exclude CI/benchmark dirs and allow _qdp native extension imports

Checklist

  • Added or updated unit tests for all changes
  • Added or updated documentation for all changes

Copy link
Member

@ryankert01 ryankert01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not familiar with Ty, but looks good

Copy link
Member

@400Ping 400Ping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

@400Ping
Copy link
Member

400Ping commented Feb 12, 2026

Not familiar with it as well

@guan404ming
Copy link
Member Author

guan404ming commented Feb 12, 2026

FYI: https://docs.astral.sh/ty/, which is widely adopted by open source projects like tvm-ffi

@guan404ming guan404ming merged commit 8c1efe2 into apache:main Feb 12, 2026
6 checks passed
@guan404ming guan404ming deleted the mypy-ty branch February 12, 2026 02:36
@guan404ming
Copy link
Member Author

Thanks!

@rich7420
Copy link
Contributor

@guan404ming thanks for the patch!
A quick question: pre-commit runs ty check, but .github/workflows/python-testing.yml does not.

@rich7420
Copy link
Contributor

should we add it as well?

@guan404ming
Copy link
Member Author

Oops

@guan404ming
Copy link
Member Author

guan404ming commented Feb 12, 2026

Lol, I could add it in a follow up. Thanks for the nice catch.

@rich7420
Copy link
Contributor

got it, thanks

@guan404ming
Copy link
Member Author

After confirmation, we already have ci running for pre-commit, which contains the ty check. I think we could skip that. WDYT?

@rich7420
Copy link
Contributor

sure!

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.

5 participants