Skip to content

Commit f065655

Browse files
authored
Fix publish (#1064)
* use env instead of env_dict * check mypy on tasks
1 parent 754a619 commit f065655

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

Diff for: pyproject.toml

+12-1
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

Diff for: tasks.py

+15-3
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

@@ -286,7 +287,9 @@ def get_packages(context: Context) -> dict[str, PackageInfo]:
286287

287288
def make_py_pkg_info(context: Context, pkg_dir: Path) -> PackageInfo:
288289
with context.cd(pkg_dir):
289-
proj_metadata = json.loads(context.run("hatch project metadata").stdout)
290+
proj_metadata = json.loads(
291+
ensure_result(context, "hatch project metadata").stdout
292+
)
290293
return PackageInfo(
291294
name=proj_metadata["name"],
292295
path=pkg_dir,
@@ -329,7 +332,9 @@ def get_current_tags(context: Context) -> set[str]:
329332
line
330333
for line in map(
331334
str.strip,
332-
context.run("git tag --points-at HEAD", hide=True).stdout.splitlines(),
335+
ensure_result(
336+
context, "git tag --points-at HEAD", hide=True
337+
).stdout.splitlines(),
333338
)
334339
if line
335340
}
@@ -418,7 +423,7 @@ def publish(dry_run: bool):
418423

419424
context.run(
420425
"twine upload dist/*",
421-
env_dict={
426+
env={
422427
"TWINE_USERNAME": twine_username,
423428
"TWINE_PASSWORD": twine_password,
424429
},
@@ -444,3 +449,10 @@ def install_poetry_project(context: Context, path: Path) -> None:
444449
]
445450
context.run("pip install -e .")
446451
context.run(f"pip install {' '.join(packages_to_install)}")
452+
453+
454+
def ensure_result(context: Context, *args: Any, **kwargs: Any) -> Result:
455+
result = context.run(*args, **kwargs)
456+
if result is None:
457+
raise Exit("Command failed")
458+
return result

0 commit comments

Comments
 (0)