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

Use pyo3-stub-gen to support IDE type hints #329

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cardigan1008
Copy link
Contributor

For #304 .

This PR introduces the use of pyo3-stub-gen to automatically generate .pyi files. These stub files provide type hints for Python IDEs.

Currently, the following modules are supported:

  • Epoch
  • TimeScale
  • TimeSeries
  • Duration
  • LatestLeapSeconds
  • LeapSecondsFile
  • Ut1Provider
  • PyHifitimeError
  • PyDurationError
  • PyParsingError

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 83.94%. Comparing base (93192da) to head (9755059).
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
src/bin/stub_gen.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #329      +/-   ##
==========================================
- Coverage   84.01%   83.94%   -0.07%     
==========================================
  Files          22       23       +1     
  Lines        3691     3694       +3     
==========================================
  Hits         3101     3101              
- Misses        590      593       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -0,0 +1,81 @@
# This file is automatically generated by pyo3_stub_gen
Copy link
Member

Choose a reason for hiding this comment

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

It seems that the stub generator could not find any of the functions in any of the classes, so as-is this new pyi file won't help IDE users in autocompleting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. So maybe we can turn to another way to do this, like dora's?

Copy link
Member

Choose a reason for hiding this comment

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

I like that dora's approach uses the package introspection, but I could not seem to get it to work correctly when I tried a few weeks (months?) ago. It kept on complaining that one of the return types was not defined although I thought I had. Feel free to give it a try of course!

@cardigan1008 cardigan1008 marked this pull request as draft September 8, 2024 08:30
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