10000 Allow passing arguments to stubgen.main (#13095) · python/mypy@256f1f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 256f1f3

Browse files
Allow passing arguments to stubgen.main (#13095)
Modify signature of stubgen.main to accept a user-provided list of arguments. This allows users to supply their own argument list without monkeying about with sys.argv, which improves the usefulness of embedding stubgen into other projects.
1 parent ccfbfc1 commit 256f1f3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mypy/stubgen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,14 +1704,14 @@ def parse_options(args: List[str]) -> Options:
17041704
export_less=ns.export_less)
17051705

17061706

1707-
def main() -> None:
1707+
def main(args: Optional[List[str]] = None) -> None:
17081708
mypy.util.check_python_version('stubgen')
17091709
# Make sure that the current directory is in sys.path so that
17101710
# stubgen can be run on packages in the current directory.
17111711
if not ('' in sys.path or '.' in sys.path):
17121712
sys.path.insert(0, '')
17131713

1714-
options = parse_options(sys.argv[1:])
1714+
options = parse_options(sys.argv[1:] if args is None else args)
17151715
generate_stubs(options)
17161716

17171717

0 commit comments

Comments
 (0)
0