From aeae0f89f06301773eb01bcc1de06cc3cc6a6816 Mon Sep 17 00:00:00 2001 From: rmorshea Date: Fri, 16 Jun 2023 11:12:42 -0600 Subject: [PATCH] check mypy on tasks --- pyproject.toml | 13 ++++++++++++- tasks.py | 16 ++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a4899a495..27e3a937d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,9 @@ dependencies = [ "flake8", "flake8-pyproject", "reactpy-flake8 >=0.7", + # types + "mypy", + "types-toml", # publish "semver >=2, <3", "twine", @@ -42,7 +45,15 @@ test-docs = "invoke test-docs" target-version = ["py39"] line-length = 88 -# --- Flake8 ---------------------------------------------------------------------------- +# --- MyPy ----------------------------------------------------------------------------- + +[tool.mypy] +ignore_missing_imports = true +warn_unused_configs = true +warn_redundant_casts = true +warn_unused_ignores = true + +# --- Flake8 --------------------------------------------------------------------------- [tool.flake8] select = ["RPY"] # only need to check with reactpy-flake8 diff --git a/tasks.py b/tasks.py index 539044173..65f75b208 100644 --- a/tasks.py +++ b/tasks.py @@ -15,6 +15,7 @@ from invoke import task from invoke.context import Context from invoke.exceptions import Exit +from invoke.runners import Result # --- Typing Preamble ------------------------------------------------------------------ @@ -286,7 +287,9 @@ def get_packages(context: Context) -> dict[str, PackageInfo]: def make_py_pkg_info(context: Context, pkg_dir: Path) -> PackageInfo: with context.cd(pkg_dir): - proj_metadata = json.loads(context.run("hatch project metadata").stdout) + proj_metadata = json.loads( + ensure_result(context, "hatch project metadata").stdout + ) return PackageInfo( name=proj_metadata["name"], path=pkg_dir, @@ -329,7 +332,9 @@ def get_current_tags(context: Context) -> set[str]: line for line in map( str.strip, - context.run("git tag --points-at HEAD", hide=True).stdout.splitlines(), + ensure_result( + context, "git tag --points-at HEAD", hide=True + ).stdout.splitlines(), ) if line } @@ -444,3 +449,10 @@ def install_poetry_project(context: Context, path: Path) -> None: ] context.run("pip install -e .") context.run(f"pip install {' '.join(packages_to_install)}") + + +def ensure_result(context: Context, *args: Any, **kwargs: Any) -> Result: + result = context.run(*args, **kwargs) + if result is None: + raise Exit("Command failed") + return result