From 599af7fc878a555a0bbcee1ed4363097cfcd8351 Mon Sep 17 00:00:00 2001 From: Jingchen Ye <11172084+97littleleaf11@users.noreply.github.com> Date: Mon, 15 Aug 2022 02:40:05 +0800 Subject: [PATCH] Remove useless parameter script_path of mypy.main() (#13399) `script_path` was entirely useless since `bin_dir` had been dropped long time ago by #5690. This PR also makes arguments of mypy.main keyword-only. --- mypy/__main__.py | 2 +- mypy/api.py | 2 +- mypy/main.py | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mypy/__main__.py b/mypy/__main__.py index f06a705668ac..b1263c734730 100644 --- a/mypy/__main__.py +++ b/mypy/__main__.py @@ -9,7 +9,7 @@ def console_entry() -> None: try: - main(None, sys.stdout, sys.stderr) + main() sys.stdout.flush() sys.stderr.flush() except BrokenPipeError: diff --git a/mypy/api.py b/mypy/api.py index 30a3739a52ac..9ea6eb34ee5a 100644 --- a/mypy/api.py +++ b/mypy/api.py @@ -67,7 +67,7 @@ def run(args: List[str]) -> Tuple[str, str, int]: from mypy.main import main return _run( - lambda stdout, stderr: main(None, args=args, stdout=stdout, stderr=stderr, clean_exit=True) + lambda stdout, stderr: main(args=args, stdout=stdout, stderr=stderr, clean_exit=True) ) diff --git a/mypy/main.py b/mypy/main.py index 366b7b813879..33751b235702 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -39,16 +39,15 @@ def stat_proxy(path: str) -> os.stat_result: def main( - script_path: Optional[str], - stdout: TextIO, - stderr: TextIO, + *, args: Optional[List[str]] = None, + stdout: TextIO = sys.stdout, + stderr: TextIO = sys.stderr, clean_exit: bool = False, ) -> None: """Main entry point to the type checker. Args: - script_path: Path to the 'mypy' script (used for finding data files). args: Custom command-line arguments. If not given, sys.argv[1:] will be used. clean_exit: Don't hard kill the process on exit. This allows catching