Add recursive and lenient modes to stub generation#2183
Add recursive and lenient modes to stub generation#2183gvanrossum merged 3 commits intopython:masterfrom
Conversation
|
Thanks, these are good ideas. Can you fix the test?
…--Guido (mobile)
|
|
|
||
| def walk_packages(packages: List[str]): | ||
| for package_name in packages: | ||
| package = __import__(package_name) |
There was a problem hiding this comment.
I'm really not happy that this imports the target package name. At the very least you should honor the --no-import flag.
There was a problem hiding this comment.
Oh, good point! I don't believe importing is strictly necessary here, since at this point I'm simply trying to walk the packages. I'll look into re-implementing this function without __import__
mypy/stubgen.py
Outdated
There was a problem hiding this comment.
I think this should have a different name, maybe --ignore-errors.
f9d04f4 to
0cf77a6
Compare
|
I renamed the lenient mode to After looking at |
|
OK. Typically we just use o's.walk(), see e.g. main.py or build.py (I
forget which).
…--Guido (mobile)
|
|
Thanks! If you want to work more on this just open a new PR. I'm looking to seeing more contributions from you. |
This is something I personally use for stub generation: whenever stubgen'ing a packages, you'll often want to generate modules inside of it.
If you pass in
--recursive, then you'll generate stubs for provided modules and its included modules if its a package.Also included is
--lenient. This will ignore exceptions (just printing a warning) when some module gens fail. This will let you stubgen for larger modules, even if they include some issues. I was having trouble using--recursivewithout this.