-
- Notifications
You must be signed in to change notification settings - Fork 3k
Improve stub generation so it works better with pybind11 wrappers. #5814
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits Select commit Hold shift + click to select a range
87a3656 Improve stub generation so it works better with pybind11 wrappers.
pkerichang 7268b26 fix bug in splitting string.
pkerichang e167720 added support for brackets in type hints (like a: Optional[int])
pkerichang ce094c1 remove pdb debugging.
pkerichang 2e477a1 added support for generating stubs for properties.
pkerichang f9f59b3 added support for inferring property types from docstring.
pkerichang 9ba34b0 Update infer_sig_from_docstring() to infer return type when able.
pkerichang e1401f4 Added unit tests.
pkerichang d293955 fix lint/type hinting errors.
pkerichang e8ba946 added docstring/comments to walk_packages().
pkerichang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I just realized something:
inspect.getmembers()only returns current members. With ordinary Python packages, at least,import pkgdoes not import all the submodules -- only those that are imported by the__init__.pyor have been otherwise imported by other code running before. E.g. I ran this for thehttpmodule and it doesn't return anything.Now this may not be relevant for
pybind11or for your example package -- those seem to be comprised of all C extensions. Is that always the case? Or can a C extension module have a Python submodule? (Perhaps only if it also sets__path__, in which case we should be fine.)Of course with the old way of doing things, no subpackages would be found either, so I guess it's still a net improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I did notice that importing a pybind11 package automatically import all the subpackages too, and was wondering if that's a pybind11 specific detail or it holds true for all C extensions in general. I'll keep this in mind and see if there's a more robust solution.
Thanks for the quick response!