From 2adb8d5425156aa076580c8c1373417469e21314 Mon Sep 17 00:00:00 2001 From: Daniel Copley Date: Tue, 14 May 2024 18:08:17 -0700 Subject: [PATCH] Add mypy CI job --- .github/workflows/lint.yml | 21 +++++++++++++++++++-- pyproject.toml | 9 +++++++-- src/shelloracle/bootstrap.py | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ef06d34..af177b0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,8 +1,25 @@ -name: Ruff -on: [ push, pull_request ] +name: Lint +on: + push: + pull_request: +permissions: + contents: read + jobs: ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 + mypy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + - uses: pypa/hatch@install + - name: Run mypy + run: hatch run types:check diff --git a/pyproject.toml b/pyproject.toml index 755ce3d..86202c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,12 +61,17 @@ dependencies = [ python = ["3.9", "3.10", "3.11", "3.12"] [tool.hatch.envs.types] +template = "hatch-test" +detached = true extra-dependencies = [ "mypy~=1.0", ] [tool.hatch.envs.types.scripts] -check = "mypy --install-types --non-interactive --explicit-package-bases {args:src/shelloracle tests}" +check = [ + "mypy {args:src/shelloracle}", + "mypy --explicit-package-bases tests" +] [tool.pytest.ini_options] pythonpath = "src" @@ -88,4 +93,4 @@ exclude_lines = [ ] [tool.ruff.lint.extend-per-file-ignores] -"tests/*" = ["INP001", "ARG"] \ No newline at end of file +"tests/*" = ["INP001", "ARG"] diff --git a/src/shelloracle/bootstrap.py b/src/shelloracle/bootstrap.py index 306208e..f00a430 100644 --- a/src/shelloracle/bootstrap.py +++ b/src/shelloracle/bootstrap.py @@ -134,7 +134,7 @@ def user_configure_settings(provider: type[Provider]) -> dict[str, Any]: for name, setting in get_settings(provider): user_input = prompt(f"{name}: ", default=str(setting.default)) type_ = type(setting.default) if setting.default else str - value = type_(user_input) + value = type_(user_input) # type: ignore[operator] settings[name] = value return settings