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 file for Python APIs #235

Merged
merged 2 commits into from
Jan 24, 2025
Merged

stub file for Python APIs #235

merged 2 commits into from
Jan 24, 2025

Conversation

unkcpz
Copy link
Contributor

@unkcpz unkcpz commented Jan 21, 2025

@relf thanks for the tool, I start using it in our project, and it is really nice. I found it would be helpful to have static typing for the IDE for python API. Here is the PR I tried to add the stub file for the python APIs.

python/egobox/egobox.pyi Outdated Show resolved Hide resolved
python/egobox/egobox.pyi Outdated Show resolved Hide resolved
python/egobox/egobox.pyi Outdated Show resolved Hide resolved
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.

Happy to learn the project is useful to you. I am not familiar with typing in Python but open to add support for IDEs.

python/egobox/egobox.pyi Outdated Show resolved Hide resolved
python/egobox/egobox.pyi Outdated Show resolved Hide resolved
python/egobox/egobox.pyi Outdated Show resolved Hide resolved
python/egobox/examples/optim_g24.py Outdated Show resolved Hide resolved
@unkcpz
Copy link
Contributor Author

unkcpz commented Jan 21, 2025

thanks for the quick reply @relf, I'll remove the docstring from the stub file to avoid duplication for now. I also find PyO3/pyo3#2454 which I'll look into a bit. Probably there is easy way to do it better.

@unkcpz
Copy link
Contributor Author

unkcpz commented Jan 22, 2025

I also find PyO3/pyo3#2454 which I'll look into a bit. Probably there is easy way to do it better.

I give it a read on the discussion, the pyo3 didn't yet provide a native way to support generate stub file. There is the crate pyo3-stub-gen mentioned and I think it cover well the case of egobox, I give it a try on #237.

@unkcpz
Copy link
Contributor Author

unkcpz commented Jan 22, 2025

As discussed in #237, I updated the PR with having the stub file auto generated using pyo3-stub-gen. Since it requires a small change on the auto-gen tool. I separate the PR by having this one only have the change with the auto-gen stub file.

@relf
Copy link
Owner

relf commented Jan 24, 2025

Either ruff format manually or configure to exclude egobox.pyi file from ruff formatting as you prefer.

@unkcpz
Copy link
Contributor Author

unkcpz commented Jan 24, 2025

I exclude it from ruff check, and seems works in locally. Could you retrigger the tests? Thanks.

@relf relf merged commit 6d3c5dc into relf:master Jan 24, 2025
13 checks passed
@unkcpz unkcpz deleted the pyi-stub branch January 24, 2025 13:59
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