pybind11-stubgen
pybind11-stubgen copied to clipboard
Contribute all good stuff to mypy.stubgenc and freeze this repo
At the point when mypy.stubgen
(or other) will be able to generate full-featured stubs for pybind11 there would be no need in this tool.
Things to ship:
- [x] function signatures
- [x] default argument parsing
- [x] attribute types
- [x] attribute values
- [x] nested classes
- [ ] functions with positional-only arguments
- [ ] pybind11-specific type transformations (e.g. iterator -> typing.Iterator)
FWIW, I like the smallness of this dependency. Just copy a single file to a repo and we're good to go. :)
Finally I've managed to make some progress here (see https://github.com/sizmailov/mypy/tree/enhance-stubgenc-pybind-compatibility).
Hopefully I'll be able to split mentioned branch into a couple of PRs and make it's way to official mypy repo.
I'll keep this issue update along the progress with PRs. Comments/reviews as always are very welcome.
First PR is merged :tada: https://github.com/python/mypy/pull/9877
A bit more is on the way.
With those two stubgen
will be dangerously really close to pybind11-stubgen
output :)
thanks for the good work @sizmailov !! :)
Great work. Please keep it on!
@sizmailov are you also planning on contributing your docstring parsing? Currently, the stubs from mypy don't have docstrings and there's an open issue suggesting it could be an added option.
Sorry, I don't have time/plans to contribute to mypy in foreseeable future. I'm personally unsatisfied with my docstring parsing implementation to contribute it anywhere, especially to a mature project such as mypy. At the same time, I don't mind if you reuse parts (or even all) of my code to create a PR to mypy or any other project. Feel free to do so without asking, and don't worry about my credits.
Please don't give up :) I'm using your codebase to create documentation stubs: I want to publish docs on readthedocs but don't want to build the pybind binary there (in fact I can't because it's MSVC-only...). Just tweaking a few lines was all that was necessary for this use case
I didn't return to the problem for quite some time and I'm not planning to in foreseeable future. So closing as not planned.
Out of curiosity: What exactly is the relationship between this implementation and mypy.stubgen
? Is one of them using the other, or did they start as a fork of each other or so? The original issue sounded like mypy.stubgen
is the better place to have this functionality. So just curious what made you change your mind -- the amount of work involved, or are there simply too many pybind11 specific features involved that would making an integration into mypy difficult?
@bluenote10 Initially, I was unsatisfied with how mypy.stubgen
performed on my pet project, and I decided to make a tool to get things done quickly.
At some point, I thought it would be nice to avoid the responsibility of solely maintaining a package with long-standing bugs/feature requests, so I've contributed a few features to mypy.stubgen
. It was too slow and time-consuming and I was carried away by other things.
I think there is a need for stubgen
as:
- an opinionated CLI tool with a handful of options, for the most common use cases
- a flexible library, to obtain fine-tuned results
I believe mypy.stubgen
could satisfy the first but not the second. So, pybind11-stubgen
and mypy.stubgen
would co-exist for quite a while.