Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type annotations for spin utils #188

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 10 additions & 2 deletions spin/cmds/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@
import shlex
import subprocess
import sys
from typing import Optional

import click


def run(
cmd, cwd=None, replace=False, sys_exit=True, output=True, echo=True, *args, **kwargs
):
cmd: list[str],
cwd: Optional[str] = None, # in 3.10 and up: str | 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
Loading