From a137357392c6a52392941144d2a49e03e4b41629 Mon Sep 17 00:00:00 2001 From: Shantanu Jain Date: Tue, 2 Jul 2024 15:32:12 -0700 Subject: [PATCH] improve --help --- README.md | 17 +++++++++++------ mypy_primer/globals.py | 13 +++++++------ mypy_primer/model.py | 4 ++-- mypy_primer/projects.py | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d20f764..580b8af 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,8 @@ usage: mypy_primer [-h] [--new NEW] [--old OLD] [--type-checker {mypy,pyright}] [-k PROJECT_SELECTOR] [-p LOCAL_PROJECT] [--expected-success] [--project-date PROJECT_DATE] [--num-shards NUM_SHARDS] [--shard-index SHARD_INDEX] [-o {full,diff,concise}] [--old-success] - [--coverage] [--bisect] [--bisect-output BISECT_OUTPUT] [-j CONCURRENCY] + [--coverage] [--bisect] [--bisect-output BISECT_OUTPUT] + [--validate-expected-success] [--measure-project-runtimes] [-j CONCURRENCY] [--debug] [--base-dir BASE_DIR] [--clear] options: @@ -72,7 +73,7 @@ type checker: old typeshed version, defaults to vendored (commit-ish, or isoformatted date) --additional-flags [ADDITIONAL_FLAGS ...] - additional flags to pass to mypy + additional flags to pass to the type checker project selection: -k PROJECT_SELECTOR, --project-selector PROJECT_SELECTOR @@ -80,9 +81,8 @@ project selection: -p LOCAL_PROJECT, --local-project LOCAL_PROJECT run only on the given file or directory. if a single file, supports a '# flags: ...' comment, like mypy unit tests - --expected-success filter to hardcoded subset of projects where some recent mypy version - succeeded aka are committed to the mypy way of life. also look at: --old- - success + --expected-success filter to hardcoded subset of projects marked as having had a recent mypy + version succeed --project-date PROJECT_DATE checkout all projects as they were on a given date, in case of bitrot --num-shards NUM_SHARDS @@ -94,13 +94,18 @@ output: -o {full,diff,concise}, --output {full,diff,concise} 'full' shows both outputs + diff; 'diff' shows only the diff; 'concise' shows only the diff but very compact - --old-success only output a result for a project if the old mypy run was successful + --old-success only output a result for a project if the old type checker run was + successful modes: --coverage count files and lines covered --bisect find first mypy revision to introduce a difference --bisect-output BISECT_OUTPUT find first mypy revision with output matching given regex + --validate-expected-success + check if projects marked as expected success pass cleanly + --measure-project-runtimes + measure project runtimes primer: -j CONCURRENCY, --concurrency CONCURRENCY diff --git a/mypy_primer/globals.py b/mypy_primer/globals.py index 3fda428..9ba32d2 100644 --- a/mypy_primer/globals.py +++ b/mypy_primer/globals.py @@ -110,7 +110,7 @@ def parse_options(argv: list[str]) -> _Args: type_checker_group.add_argument( "--additional-flags", - help="additional flags to pass to mypy", + help="additional flags to pass to the type checker", nargs="*", default=[], ) @@ -131,8 +131,7 @@ def parse_options(argv: list[str]) -> _Args: "--expected-success", action="store_true", help=( - "filter to hardcoded subset of projects where some recent mypy version succeeded " - "aka are committed to the mypy way of life. also look at: --old-success" + "filter to hardcoded subset of projects marked as having had a recent mypy version succeed" ), ) proj_group.add_argument( @@ -160,7 +159,7 @@ def parse_options(argv: list[str]) -> _Args: output_group.add_argument( "--old-success", action="store_true", - help="only output a result for a project if the old mypy run was successful", + help="only output a result for a project if the old type checker run was successful", ) modes_group = parser.add_argument_group("modes") @@ -174,10 +173,12 @@ def parse_options(argv: list[str]) -> _Args: "--bisect-output", help="find first mypy revision with output matching given regex" ) modes_group.add_argument( - "--validate-expected-success", action="store_true", help=argparse.SUPPRESS + "--validate-expected-success", + action="store_true", + help="check if projects marked as expected success pass cleanly", ) modes_group.add_argument( - "--measure-project-runtimes", action="store_true", help=argparse.SUPPRESS + "--measure-project-runtimes", action="store_true", help="measure project runtimes" ) primer_group = parser.add_argument_group("primer") diff --git a/mypy_primer/model.py b/mypy_primer/model.py index 4c40b56..89f8ea3 100644 --- a/mypy_primer/model.py +++ b/mypy_primer/model.py @@ -176,11 +176,11 @@ def get_mypy_cmd(self, mypy: str | Path, additional_flags: Sequence[str] = ()) - return mypy_cmd async def run_mypy(self, mypy: Path, typeshed_dir: Path | None) -> TypeCheckResult: - additional_flags = ctx.get().additional_flags.copy() env = os.environ.copy() env["MYPY_FORCE_COLOR"] = "1" mypy_path = [] # TODO: this used to be exposed, could be useful to expose it again + additional_flags = ctx.get().additional_flags.copy() if typeshed_dir is not None: additional_flags.append(f"--custom-typeshed-dir={quote_path(typeshed_dir)}") mypy_path += list(map(str, typeshed_dir.glob("stubs/*"))) @@ -241,7 +241,7 @@ def get_pyright_cmd(self, pyright: Path, additional_flags: Sequence[str] = ()) - return pyright_cmd async def run_pyright(self, pyright: Path, typeshed_dir: Path | None) -> TypeCheckResult: - additional_flags: list[str] = [] + additional_flags = ctx.get().additional_flags.copy() if typeshed_dir is not None: additional_flags.append(f"--typeshedpath {quote_path(typeshed_dir)}") pyright_cmd = self.get_pyright_cmd(pyright, additional_flags) diff --git a/mypy_primer/projects.py b/mypy_primer/projects.py index 817d2be..6f76c7c 100644 --- a/mypy_primer/projects.py +++ b/mypy_primer/projects.py @@ -905,7 +905,7 @@ def get_projects() -> list[Project]: location="https://github.com/common-workflow-language/schema_salad", mypy_cmd="MYPYPATH=$MYPYPATH:mypy-stubs {mypy} schema_salad", pyright_cmd=None, - install_cmd=("{install} $(grep -v mypy mypy-requirements.txt)" " -r requirements.txt"), + install_cmd="{install} $(grep -v mypy mypy-requirements.txt)" " -r requirements.txt", expected_mypy_success=True, supported_platforms=["linux", "darwin"], ),