Skip to content

add a stub type file#9

Open
rambip wants to merge 5 commits intoSkielex:masterfrom
rambip:master
Open

add a stub type file#9
rambip wants to merge 5 commits intoSkielex:masterfrom
rambip:master

Conversation

@rambip
Copy link
Copy Markdown

@rambip rambip commented Apr 10, 2025

This should close #8

The type annotations are not perfect (for example, boolean types for labels, and no return type), but it should be ok for most uses.

@Skielex
Copy link
Copy Markdown
Owner

Skielex commented Apr 11, 2025

Thanks for the PR. I'll take a look as soon as I've got time.

@Skielex
Copy link
Copy Markdown
Owner

Skielex commented Apr 12, 2025

Exactly which command did you use to generate this stub file?

@rambip
Copy link
Copy Markdown
Author

rambip commented Apr 12, 2025

pybind11-stubgen thinqpbo

And then I edited the result manually.

https://pypi.org/project/pybind11-stubgen/

@Skielex
Copy link
Copy Markdown
Owner

Skielex commented Apr 21, 2025

I haven't created stubs before, so I'm not what the best approach is for Cython projects like this, where we distribute both wheels and sdist.

As far as I can tell this PR does not currently add working stubs to the project. The immediate issue is that the _qbpo.pyi will not be included in any wheels, as the src folder isn't a part of the wheel. When building the Cython extension, the src folder is compiled to a .pyd/.so file.

I've tried moving _qbpo.pyi to the thinqpbo folder so that it's distributed with the package, however, it doesn't seem to work correctly with VS Code.

@Skielex
Copy link
Copy Markdown
Owner

Skielex commented Apr 21, 2025

Is this solution working for you? Would you be willing to fix the stubs so that they will be correctly included in the package and provide working stubs in applications like VS Code?

@rambip
Copy link
Copy Markdown
Author

rambip commented Apr 21, 2025

It's also my first time packaging a library, so I'm not 100% sure of what I'm doing.
Yet, I think I made it work (minor changes to setup.py)

I also heard that you can add zip_safe=False in the setup.py options (see here)
I don't know if it is needed in our case.

Comment thread setup.py Outdated
@Skielex
Copy link
Copy Markdown
Owner

Skielex commented May 13, 2025

@rambip , I made some changes and it appears that the stub is now correctly included and it seems to work when I install the package. Could you please check that it works as intended for you?

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.

Provide type stubs for library

2 participants