Skip to content

Commit 5949e17

Browse files
committed
check mypy on tasks
1 parent bfbbe42 commit 5949e17

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ dependencies = [
1818
"flake8",
1919
"flake8-pyproject",
2020
"reactpy-flake8 >=0.7",
21+
# types
22+
"mypy",
23+
"types-toml",
2124
# publish
2225
"semver >=2, <3",
2326
"twine",
@@ -42,7 +45,15 @@ test-docs = "invoke test-docs"
4245
target-version = ["py39"]
4346
line-length = 88
4447

45-
# --- Flake8 ----------------------------------------------------------------------------
48+
# --- MyPy -----------------------------------------------------------------------------
49+
50+
[tool.mypy]
51+
ignore_missing_imports = true
52+
warn_unused_configs = true
53+
warn_redundant_casts = true
54+
warn_unused_ignores = true
55+
56+
# --- Flake8 ---------------------------------------------------------------------------
4657

4758
[tool.flake8]
4859
select = ["RPY"] # only need to check with reactpy-flake8

tasks.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from invoke import task
1616
from invoke.context import Context
1717
from invoke.exceptions import Exit
18+
from invoke.runners import Result
1819

1920
# --- Typing Preamble ------------------------------------------------------------------
2021

@@ -278,7 +279,9 @@ def get_packages(context: Context) -> dict[str, PackageInfo]:
278279

279280
def make_py_pkg_info(context: Context, pkg_dir: Path) -> PackageInfo:
280281
with context.cd(pkg_dir):
281-
proj_metadata = json.loads(context.run("hatch project metadata").stdout)
282+
proj_metadata = json.loads(
283+
ensure_result(context, "hatch project metadata").stdout
284+
)
282285
return PackageInfo(
283286
name=proj_metadata["name"],
284287
path=pkg_dir,
@@ -321,7 +324,9 @@ def get_current_tags(context: Context) -> set[str]:
321324
line
322325
for line in map(
323326
str.strip,
324-
context.run("git tag --points-at HEAD", hide=True).stdout.splitlines(),
327+
ensure_result(
328+
context, "git tag --points-at HEAD", hide=True
329+
).stdout.splitlines(),
325330
)
326331
if line
327332
}
@@ -417,3 +422,10 @@ def publish(dry_run: bool):
417422
)
418423

419424
return publish
425+
426+
427+
def ensure_result(context: Context, *args: Any, **kwargs: Any) -> Result:
428+
result = context.run(*args, **kwargs)
429+
if result is None:
430+
raise Exit("Command failed")
431+
return result

0 commit comments

Comments
 (0)