diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7647516 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.7 + hooks: + - id: ruff + - id: ruff-format + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.17.1 + hooks: + - id: mypy + files: ^src/ + args: + - --ignore-missing-imports + - --allow-untyped-decorators + - --disable-error-code=misc + + - repo: https://github.com/PyCQA/bandit + rev: 1.8.6 + hooks: + - id: bandit + args: + - -c + - pyproject.toml + files: ^src/ \ No newline at end of file diff --git a/Development.md b/Development.md index a88ceb9..389b001 100644 --- a/Development.md +++ b/Development.md @@ -100,7 +100,17 @@ bandit -r src -c pyproject.toml # All-in-one via pre-commit pre-commit run --all-files ``` +Install pre-commit hooks: +```bash +pre-commit install +``` + +Run all hooks manually: + +```bash +pre-commit run --all-files +``` Pre-commit is configured to run ruff, mypy, and bandit on every commit. --- diff --git a/src/modeldock/adapters/registry/bundled.py b/src/modeldock/adapters/registry/bundled.py index 9e9eb8f..0989440 100644 --- a/src/modeldock/adapters/registry/bundled.py +++ b/src/modeldock/adapters/registry/bundled.py @@ -63,7 +63,8 @@ def _to_spec(raw: Dict[str, Any]) -> ModelSpec: raw["category"] = Category.from_value(raw["category"]) raw["capabilities"] = [Capability.from_value(c) for c in raw.get("capabilities", [])] raw["backend_hints"] = [RuntimeBackend.from_value(b) for b in raw.get("backend_hints", [])] - return ModelSpec.model_validate(raw) + + return cast(ModelSpec, ModelSpec.model_validate(raw)) # --- RegistryPort -----------------------------------------------------