pybind11-stubgen icon indicating copy to clipboard operation
pybind11-stubgen copied to clipboard

Contribute all good stuff to mypy.stubgenc and freeze this repo

Open sizmailov opened this issue 4 years ago • 8 comments

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)

sizmailov avatar Aug 04 '20 23:08 sizmailov

FWIW, I like the smallness of this dependency. Just copy a single file to a repo and we're good to go. :)

virtuald avatar Aug 24 '20 05:08 virtuald

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.

sizmailov avatar Jan 05 '21 00:01 sizmailov

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 :)

sizmailov avatar Jan 20 '21 17:01 sizmailov

thanks for the good work @sizmailov !! :)

hiaselhans avatar Jan 26 '21 09:01 hiaselhans

Great work. Please keep it on!

allanleal avatar Jun 29 '21 09:06 allanleal

@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.

varunsh-xilinx avatar Apr 29 '22 00:04 varunsh-xilinx

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.

sizmailov avatar May 04 '22 05:05 sizmailov

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

cunnane avatar Sep 08 '22 11:09 cunnane

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.

sizmailov avatar Aug 29 '23 13:08 sizmailov

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 avatar Oct 06 '23 13:10 bluenote10

@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:

  1. an opinionated CLI tool with a handful of options, for the most common use cases
  2. 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.

sizmailov avatar Oct 08 '23 06:10 sizmailov