def main(): if not os.path.isdir('out'): raise SystemExit('Directory "out" does not exist') args = sys.argv[1:] sigs = {} class_sigs = {} pyversion = defaults.PYTHON3_VERSION while args and args[0].startswith('--'): if args[0] == '--docpath': docpath = args[1] args = args[2:] all_sigs = [] # type: Any all_class_sigs = [] # type: Any for path in glob.glob('%s/*.rst' % docpath): func_sigs, class_sigs = parse_all_signatures(open(path).readlines()) all_sigs += func_sigs all_class_sigs += class_sigs sigs = dict(find_unique_signatures(all_sigs)) class_sigs = dict(find_unique_signatures(all_class_sigs)) elif args[0] == '--py2': pyversion = defaults.PYTHON2_VERSION else: raise SystemExit('Unrecognized option %s' % args[0]) args = args[1:] if not args: usage() for module in args: generate_stub_for_module(module, 'out', add_header=True, sigs=sigs, class_sigs=class_sigs, pyversion=pyversion)
def main(): if not os.path.isdir('out'): raise SystemExit('Directory "out" does not exist') args = sys.argv[1:] if not args: raise SystemExit( 'usage: python3 -m mypy.stubgen [--docpath path] module ...') if args[0] == '--docpath': docpath = args[1] args = args[2:] all_sigs = [] # type: Any all_class_sigs = [] # type: Any for path in glob.glob('%s/*.rst' % docpath): func_sigs, class_sigs = parse_all_signatures( open(path).readlines()) all_sigs += func_sigs all_class_sigs += class_sigs sigs = dict(find_unique_signatures(all_sigs)) class_sigs = dict(find_unique_signatures(all_class_sigs)) else: sigs = {} class_sigs = {} for module in args: generate_stub_for_module(module, 'out', add_header=True, sigs=sigs, class_sigs=class_sigs)
def main() -> None: options = parse_options(sys.argv[1:]) if not os.path.isdir(options.output_dir): raise SystemExit('Directory "{}" does not exist'.format(options.output_dir)) if options.recursive and options.no_import: raise SystemExit('recursive stub generation without importing is not currently supported') sigs = {} # type: Any class_sigs = {} # type: Any if options.doc_dir: all_sigs = [] # type: Any all_class_sigs = [] # type: Any for path in glob.glob('%s/*.rst' % options.doc_dir): with open(path) as f: func_sigs, class_sigs = parse_all_signatures(f.readlines()) all_sigs += func_sigs all_class_sigs += class_sigs sigs = dict(find_unique_signatures(all_sigs)) class_sigs = dict(find_unique_signatures(all_class_sigs)) for module in (options.modules if not options.recursive else walk_packages(options.modules)): try: generate_stub_for_module(module, output_dir=options.output_dir, add_header=True, sigs=sigs, class_sigs=class_sigs, pyversion=options.pyversion, no_import=options.no_import, search_path=options.search_path, interpreter=options.interpreter, include_private=options.include_private) except Exception as e: if not options.ignore_errors: raise e else: print("Stub generation failed for", module, file=sys.stderr)
def main(): if not os.path.isdir('out'): raise SystemExit('Directory "out" does not exist') args = sys.argv[1:] sigs = {} class_sigs = {} pyversion = defaults.PYTHON3_VERSION while args and args[0].startswith('--'): if args[0] == '--docpath': docpath = args[1] args = args[2:] all_sigs = [] # type: Any all_class_sigs = [] # type: Any for path in glob.glob('%s/*.rst' % docpath): func_sigs, class_sigs = parse_all_signatures( open(path).readlines()) all_sigs += func_sigs all_class_sigs += class_sigs sigs = dict(find_unique_signatures(all_sigs)) class_sigs = dict(find_unique_signatures(all_class_sigs)) elif args[0] == '--py2': pyversion = defaults.PYTHON2_VERSION else: raise SystemExit('Unrecognized option %s' % args[0]) args = args[1:] if not args: usage() for module in args: generate_stub_for_module(module, 'out', add_header=True, sigs=sigs, class_sigs=class_sigs, pyversion=pyversion)
def main() -> None: options = parse_options() if not os.path.isdir('out'): raise SystemExit('Directory "out" does not exist') sigs = {} # type: Any class_sigs = {} # type: Any if options.doc_dir: all_sigs = [] # type: Any all_class_sigs = [] # type: Any for path in glob.glob('%s/*.rst' % options.doc_dir): func_sigs, class_sigs = parse_all_signatures( open(path).readlines()) all_sigs += func_sigs all_class_sigs += class_sigs sigs = dict(find_unique_signatures(all_sigs)) class_sigs = dict(find_unique_signatures(all_class_sigs)) for module in options.modules: generate_stub_for_module(module, 'out', add_header=True, sigs=sigs, class_sigs=class_sigs, pyversion=options.pyversion, no_import=options.no_import, search_path=options.search_path, interpreter=options.interpreter)
def main(): if not os.path.isdir('out'): raise SystemExit('Directory "out" does not exist') args = sys.argv[1:] if not args: raise SystemExit('usage: python3 -m mypy.stubgen [--docpath path] module ...') if args[0] == '--docpath': docpath = args[1] args = args[2:] all_sigs = [] # type: Any all_class_sigs = [] # type: Any for path in glob.glob('%s/*.rst' % docpath): func_sigs, class_sigs = parse_all_signatures(open(path).readlines()) all_sigs += func_sigs all_class_sigs += class_sigs sigs = dict(find_unique_signatures(all_sigs)) class_sigs = dict(find_unique_signatures(all_class_sigs)) else: sigs = {} class_sigs = {} for module in args: generate_stub_for_module(module, 'out', add_header=True, sigs=sigs, class_sigs=class_sigs)
def main() -> None: if not os.path.isdir('out'): raise SystemExit('Directory "out" does not exist') options = parse_options() sigs = {} # type: Any class_sigs = {} # type: Any if options.doc_dir: all_sigs = [] # type: Any all_class_sigs = [] # type: Any for path in glob.glob('%s/*.rst' % options.doc_dir): func_sigs, class_sigs = parse_all_signatures(open(path).readlines()) all_sigs += func_sigs all_class_sigs += class_sigs sigs = dict(find_unique_signatures(all_sigs)) class_sigs = dict(find_unique_signatures(all_class_sigs)) for module in options.modules: generate_stub_for_module(module, 'out', add_header=True, sigs=sigs, class_sigs=class_sigs, pyversion=options.pyversion, no_import=options.no_import, search_path=options.search_path, interpreter=options.interpreter)