Skip to content

Commit 0cf77a6

Browse files
committed
disable recursive mode when using --no-import
1 parent 3f36721 commit 0cf77a6

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

mypy/stubgen.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@
6767
('doc_dir', str),
6868
('search_path', List[str]),
6969
('interpreter', str),
70-
('modules', List[str])])
70+
('modules', List[str]),
71+
('ignore_errors', bool),
72+
('recursive', bool)])
7173

7274

7375
def generate_stub_for_module(module: str, output_dir: str, quiet: bool = False,
@@ -589,6 +591,8 @@ def main() -> None:
589591
options = parse_options()
590592
if not os.path.isdir('out'):
591593
raise SystemExit('Directory "out" does not exist')
594+
if options.recursive and options.no_import:
595+
raise SystemExit('recursive stub generation without importing is not currently supported')
592596
sigs = {} # type: Any
593597
class_sigs = {} # type: Any
594598
if options.doc_dir:
@@ -611,7 +615,7 @@ def main() -> None:
611615
search_path=options.search_path,
612616
interpreter=options.interpreter)
613617
except Exception as e:
614-
if not options.lenient:
618+
if not options.ignore_errors:
615619
raise e
616620
else:
617621
print("Stub generation failed for : ", module)
@@ -622,7 +626,7 @@ def parse_options() -> Options:
622626
pyversion = defaults.PYTHON3_VERSION
623627
no_import = False
624628
recursive = False
625-
lenient = False
629+
ignore_errors = False
626630
doc_dir = ''
627631
search_path = [] # type: List[str]
628632
interpreter = ''
@@ -640,8 +644,8 @@ def parse_options() -> Options:
640644
args = args[1:]
641645
elif args[0] == '--recursive':
642646
recursive = True
643-
elif args[0] == '--lenient':
644-
lenient = True
647+
elif args[0] == '--ignore-errors':
648+
ignore_errors = True
645649
elif args[0] == '--py2':
646650
pyversion = defaults.PYTHON2_VERSION
647651
elif args[0] == '--no-import':
@@ -660,7 +664,9 @@ def parse_options() -> Options:
660664
doc_dir=doc_dir,
661665
search_path=search_path,
662666
interpreter=interpreter,
663-
modules=args)
667+
modules=args,
668+
ignore_errors=ignore_errors,
669+
recursive=recursive)
664670

665671

666672
def default_python2_interpreter() -> str:
@@ -688,7 +694,7 @@ def usage() -> None:
688694
Options:
689695
--py2 run in Python 2 mode (default: Python 3 mode)
690696
--recursive traverse listed modules to generate inner package modules as well
691-
--lenient ignore exceptions when trying to generate stubs for modules
697+
--ignore-errors ignore errors when trying to generate stubs for modules
692698
--no-import don't import the modules, just parse and analyze them
693699
(doesn't work with C extension modules and doesn't
694700
respect __all__)

0 commit comments

Comments
 (0)