python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.48k stars 2.83k forks source link

`stubgen` plugin support (via config file) #14428

Open CarlosRDomin opened 1 year ago

CarlosRDomin commented 1 year ago

Feature

Similar to #9193, I'd like to run stubgen with a custom plugin, and more generally, let stubgen take a config file

Pitch

stubgen is a really powerful tool (thanks devs for all the hard work!), but could become even more powerful by extending type support through custom plugins. Currently, there's no way (that I have found) to pass a configuration file (or at the very least extra_plugins to build) to stubgen, while !9203 exposed this option for stubtest.

The idea would be to implement a similar approach inside stubgen so we aren't forced to use the (much slower) interpreted version of mypy

CarlosRDomin commented 1 year ago

Pushed an initial implementation, happy to take feedback on how to add a test for it. Alternatively, I'd be happy to just expose a way to pass extra_plugins to build if that's preferred given that not all options in the Mypy config file will be taken into account by stubgen

CarlosRDomin commented 1 year ago

@AlexWaygood any feedback?

AlexWaygood commented 1 year ago

I'm afraid I've never touched stubgen, so I'm probably not the best reviewer, sorry! (I'm also not a maintainer, only a triager, so I wouldn't have the power to merge your PR either.)

The idea sounds reasonable, though!

CarlosRDomin commented 1 year ago

Thanks for the feedback @AlexWaygood, apologies for tagging you then. Do you happen to know who'd be a maintainer/reviewer to get this merged eventually? Thanks!

AlexWaygood commented 1 year ago

Possibly @hauntsaninja or @sobolevn if either of them has the time — but mypy is maintained by volunteers, so I can't make any promises :)