Add typing support and switch to uv#73
Open
mrexodia wants to merge 6 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the nanobind example project by adding comprehensive type checking support and migrating to uv as the development tool. The changes include generating type stubs for C++ extension modules, updating Python version requirements, and adding CI workflows to verify type checking functionality.
Key changes:
- Migrated from pip-based development to uv with automatic rebuild on source changes
- Added type stub generation using nanobind's
nanobind_add_stubfunctionality - Implemented type checking CI workflow with ty, pyright, and mypy verification
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| typecheck_smoke.py | New smoke test file with intentional type errors to verify type stubs are working |
| tests/test_basic.py | Minor formatting change (added blank line) |
| src/nanobind_example_ext.cpp | Refactored lambda to named function and added docstring for better type stub generation |
| src/nanobind_example/init.py | Changed to absolute imports for proper type checking support |
| pyproject.toml | Updated dependencies, added type checker configurations, and uv tool settings |
| README.md | Added comprehensive development documentation for uv, type checking, and project structure |
| CMakeLists.txt | Added type stub generation, improved build configuration, and nanobind fetching for development |
| .python-version | Added Python version file for uv |
| .github/workflows/pip.yml | Added type checking job with verification tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mrexodia
added a commit
to LLVMParty/llvm-nanobind
that referenced
this pull request
Dec 16, 2025
Reference: wjakob/nanobind_example#73
mrexodia
added a commit
to LLVMParty/llvm-nanobind
that referenced
this pull request
Dec 16, 2025
Reference: wjakob/nanobind_example#73
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.
I noticed that this official example does not support generating type stubs and (IDE) type checking correctly. I switched to uv, which makes building the extension transparent on
uv runand configured things in a way to be much more ergonomic for local development.After running
uv syncand selecting the virtual environment in VSCode the type hints work out of the box:Similarly you can now do
cmake -B build -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ONwithoutnanobindinstalled globally on your system and clangd will function correctly:You can also run type checking locally: