Skip to content

Commit

Permalink
Allow passing arguments to stubgen.main (#13095)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mwoehlke-kitware committed Jul 8, 2022
1 parent ccfbfc1 commit 256f1f3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mypy/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,14 +1704,14 @@ def parse_options(args: List[str]) -> Options:
export_less=ns.export_less)


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

options = parse_options(sys.argv[1:])
options = parse_options(sys.argv[1:] if args is None else args)
generate_stubs(options)


Expand Down

0 comments on commit 256f1f3

Please sign in to comment.