-
Notifications
You must be signed in to change notification settings - Fork 1k
update stub for typing #1896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update stub for typing #1896
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
7c4575e to
910521b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances type checking support for the tokenizers library by improving stub file generation and adding comprehensive type annotations. It supersedes PR #1865 with a more complete solution for static type checking.
Key Changes:
- Enhanced
stub.pyto generate better type stubs with property setters, magic methods, and improved signature handling - Updated PyO3 Rust bindings with explicit
text_signatureannotations for better Python type visibility - Added type ignore comments throughout test and example files to suppress expected type checker warnings
- Introduced type checking workflow integration (using "ty" tool)
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
bindings/python/stub.py |
Major refactoring: added OVERRIDES dict, improved signature extraction, property setter generation, and better error handling for ruff formatting |
bindings/python/src/*.rs |
Added/updated text_signature attributes on PyO3 constructors and methods to expose proper signatures to Python type checkers |
bindings/python/py_src/**/*.pyi |
Generated stub files with complete property setters, magic methods (__getstate__, __setstate__, __getitem__, etc.), and improved type hints |
bindings/python/tests/**/*.py |
Added # type: ignore comments for intentional type violations in tests (e.g., testing error handling with invalid inputs) |
bindings/python/scripts/*.py |
Added # type: ignore[import] for optional/external dependencies like sentencepiece, transformers, jieba, tiktoken |
bindings/python/pyproject.toml |
Added "ty" to testing dependencies, removed deprecated black configuration |
bindings/python/Makefile |
Integrated "ty check" commands into style checking targets |
.github/workflows/python.yml |
Added type checking step in CI workflow |
bindings/python/docs/pyo3.md |
New documentation explaining PyO3 usage patterns for Python bindings |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
McPatate
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever is going on in stub.py I trust that you know what you're doing and that it works as intended lol
Updater stub for better typing.
Superseed #1865!
Really not a typing pro, if anyone wants to make it better you can submit a PR, this is a quick fix IMO