CI: add pre-commit config - #172
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a pre-commit configuration and updates developer documentation so contributors can run the same quality checks locally that CI runs (lint/format, type-checking, and security scanning), addressing issue #135.
Changes:
- Added a new
.pre-commit-config.yamldefining Ruff, MyPy, and Bandit hooks. - Documented how to install and run
pre-commithooks inDevelopment.md. - Adjusted a type assertion in the bundled registry adapter to satisfy MyPy.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.pre-commit-config.yaml |
Introduces local pre-commit hooks intended to mirror CI quality gates. |
Development.md |
Documents pre-commit installation and usage for local workflows. |
src/modeldock/adapters/registry/bundled.py |
Adds an explicit cast(...) around ModelSpec.model_validate(...) for type-checking. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.12.7 | ||
| hooks: |
| - id: mypy | ||
| files: ^src/ | ||
| args: | ||
| - --ignore-missing-imports | ||
| - --allow-untyped-decorators | ||
| - --disable-error-code=misc |
|
@himanshu231204 I removed the cast() based on the CI feedback, but my local pre-commit now reports Returning Any from function declared to return "ModelSpec" on the same line. Since the project uses strict MyPy settings and CI previously reported the cast as redundant, could you clarify the expected approach here? I'm happy to update the PR accordingly. |
Summary
Adds a pre-commit configuration to provide local quality checks consistent with the project's CI. Also documents how to install and use pre-commit.
Changes
.pre-commit-config.yamlDevelopment.mdwith pre-commit installation and usage instructionssrc/modeldock/adapters/registry/bundled.pyrequired for MyPy to passTesting
pre-commit run --all-filesChecklist
feature/,fix/,docs/,refactor/,test/,chore/)mainAGENT.mdcoding standards (type hints, Pydantic v2, no genericException, no business logic in CLI)domain/andports/stay pure (no I/O, no framework imports)ruff,mypy --strict,bandit,pytestpyproject.tomlandsrc/modeldock/__init__.pyversions match (if release-related)Closes #135