Add stub file for static type checkers - #389
Conversation
c1078dc to
02caffe
Compare
|
Changing to draft as its being finalized. |
02caffe to
c38f62a
Compare
d213f07 to
662ddeb
Compare
|
@dlugoschvincent sorry this took me so long to look at. Do you think this is ready now? |
|
I think there is still a few issues. I will try to work them out in the coming days and align with my current local version! |
build: ship PEP 561 typing metadata
|
Alright @haata I think its ready to merge I removed some complexity. Matched the docstrings to the cython functions and improved accuracy across the board. I also added types for the latest additions to the project. |
|
One question, is there a good way to identify (or have some sort of unit test) to make sure when new APIs are added or changed that these hints are also updated? Even better if it was some sort of compilation error. |
|
Hmm I could add a Test case for that if you want. What do you think? |
…xclude files and symbols
|
Okay I added a separate test using |
|
I hope I fixed the issues with the build failures can you rerun the workflow? |
Summary
This PR adds first-party PEP 561 type stubs for pycapnp.
It includes stubs for the root
capnppackage, the Cython extension module,capnp.types, and version information. Thepy.typedmarker and packaging configuration ensure the stubs are included in wheels and source distributions.Approach
The declarations were audited against the compiled runtime and Cython implementation. The stubs describe existing objects without introducing typing-only classes, generic APIs, inheritance relationships, or modules.
Notable details include:
capnp.AsyncIoStreamcorrectly represents the public alias of the internal runtime class.capnp.typesexposes the real built-in schema descriptors.which()return type remains schema-agnostic; generated schema stubs can refine it usingLiteral[...].Validation
The exported names, inheritance, aliases, signatures, and docstrings were checked against runtime objects. The stubs also pass Ruff, Basedpyright, and the pycapnp test suite.