Skip to content

Commit

Permalink
Add type annotations for spin utils
Browse files Browse the repository at this point in the history
With this in place, we can progressively add more type annotations.

Closes #177
  • Loading branch information
stefanv committed May 22, 2024
1 parent 0157ef5 commit 66a56cc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: e5ea6670624c24f8321f6328ef3176dbba76db46 # frozen: v1.10.0
hooks:
- id: mypy
2 changes: 1 addition & 1 deletion example_pkg/doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = []
extensions: list[str] = []

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ filterwarnings = [
[tool.ruff]
line-length = 88
target-version = "py38"

[tool.ruff.lint]
select = [
"C",
"E",
Expand Down
10 changes: 5 additions & 5 deletions spin/cmds/meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ def _check_coverage_tool_installation(coverage_type: GcovReportFormat):

# Verify the tools are installed prior to the build
p = _run(["ninja", "-C", build_dir, "-t", "targets", "all"], output=False)
if f"coverage-{coverage_type.value}" not in p.stdout.decode("ascii"):
if f"coverage-{coverage_type}" not in p.stdout.decode("ascii"):
raise click.ClickException(
f"coverage-{coverage_type.value} is not supported... "
f"coverage-{coverage_type} is not supported... "
f"Ensure the following are installed: {', '.join(requirements[coverage_type])} "
"and rerun `spin test --gcov`"
)
Expand Down Expand Up @@ -361,7 +361,7 @@ def _get_configured_command(command_name):
)
@click.option(
"--gcov-format",
type=click.Choice(GcovReportFormat),
type=click.Choice([e.name for e in GcovReportFormat]),
default="html",
help=f"Format of the gcov report. Can be one of {', '.join(e.value for e in GcovReportFormat)}.",
)
Expand Down Expand Up @@ -512,7 +512,7 @@ def test(

# Generate report
click.secho(
f"Generating {gcov_format.value} coverage report...",
f"Generating {gcov_format} coverage report...",
bold=True,
fg="bright_yellow",
)
Expand All @@ -521,7 +521,7 @@ def test(
"ninja",
"-C",
build_dir,
f"coverage-{gcov_format.value.lower()}",
f"coverage-{gcov_format.lower()}",
],
output=False,
)
Expand Down
11 changes: 9 additions & 2 deletions spin/cmds/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@


def run(
cmd, cwd=None, replace=False, sys_exit=True, output=True, echo=True, *args, **kwargs
):
cmd: list[str],
cwd: str | None = None,
replace: bool = False,
sys_exit: bool = True,
output: bool = True,
echo: bool = True,
*args,
**kwargs,
) -> subprocess.CompletedProcess:
"""Run a shell command.
Parameters
Expand Down

0 comments on commit 66a56cc

Please sign in to comment.