-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed stubgen parsing generics from C extensions (#8939)
pybind11 is capable of producing type signatures that use generics (for example https://github.com/pybind/pybind11/blob/4e3d9fea74ed50a042d98f68fa35a3133482289b/include/pybind11/stl.h#L140). A user may also opt to write a signature in the docstring that uses generics. Currently when stubgen parses one of these generics, it attempts to import a part of it. For example if a docstring had my_func(str, int) -> List[mypackage.module_being_parsed.MyClass], the resulting stub file tries to import List[mypackage.module_being_parsed. This change fixes this behaviour by breaking the found type down into the multiple types around [], characters, adding any imports from those types that are needed, and then stripping out the name of the module being parsed.
- Loading branch information
Showing
2 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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