Skip to content
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

Stub pyi file autogen using pyo3-stub-gen #237

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

unkcpz
Copy link
Contributor

@unkcpz unkcpz commented Jan 22, 2025

derived from #235, I think this way is a bit more elegant and can avoid duplicating the docstring.
It require extra proc-macros to be added (unavoidable because pyo3-stub-gen not part of PyO3).

Since in egobox, it use the PyReadonlyArray which not cover by pyo3-stub-gen, the conversion would fail. I open a PR with the change of Jij-Inc/pyo3-stub-gen#142 to support it.

@relf what do you think? I just did without change any docstring in Rust side, but if the auto stub gen framework is there, the change can only happened for the rust docstring, then out the scope of this PR.

EDIT: this one should wait until Jij-Inc/pyo3-stub-gen#142 adapted and back port to with 0.6.x

@@ -48,3 +48,8 @@ serde_json.workspace = true
ctrlc.workspace = true

argmin_testfunctions.workspace = true
pyo3-stub-gen = { path = "../../pyo3-stub-gen/pyo3-stub-gen", features = ["numpy"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change in Jij-Inc/pyo3-stub-gen#142 required.

@@ -21,7 +21,8 @@ build-backend = "maturin"
requires = ["maturin>=1.0, <2.0"]

[tool.maturin]
python-source = "./"
python-source = "egobox"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will make pyo3-stub-gen to put egobox.pyi inside python/egobox, I hope it is corrected?

@unkcpz unkcpz mentioned this pull request Jan 22, 2025
Copy link
Owner

@relf relf left a comment

Choose a reason for hiding this comment

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

Thank you for the research. Indeed, it's even better if we can generate the pyi file. At the moment, maybe we can use #235 to commit the generated egobox.pyi and wait for pyo3-stub-gen being "fixed" to merge this PR?

@unkcpz
Copy link
Contributor Author

unkcpz commented Jan 22, 2025

At the moment, maybe we can use #235 to commit the generated egobox.pyi and wait for pyo3-stub-gen being "fixed" to merge this PR?

Sure, I think that is a feasible plan. I'll move the auto-gen part into another PR and keep this one with only the pyi and py.typed (or the other way around by open one with only the stub files, I think that is easier.).

@unkcpz unkcpz marked this pull request as draft January 22, 2025 19:33
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.

2 participants