Skip to content

Commit

Permalink
check mypy on tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Jul 2, 2023
1 parent 47ec8c5 commit aeae0f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ dependencies = [
"flake8",
"flake8-pyproject",
"reactpy-flake8 >=0.7",
# types
"mypy",
"types-toml",
# publish
"semver >=2, <3",
"twine",
Expand All @@ -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
Expand Down
16 changes: 14 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------------------------

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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

0 comments on commit aeae0f8

Please sign in to comment.