Skip to content

Commit

Permalink
improve --help
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Jul 2, 2024
1 parent 541d7ef commit a137357
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -72,17 +73,16 @@ 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
regex to filter projects (matches against location)
-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
Expand All @@ -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
Expand Down
13 changes: 7 additions & 6 deletions mypy_primer/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
)
Expand All @@ -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(
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions mypy_primer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/*")))
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mypy_primer/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
),
Expand Down

0 comments on commit a137357

Please sign in to comment.