diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..52221e6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,46 @@ +default_stages: [ commit ] +repos: + + - repo: local + hooks: + - id: code-format + name: code-format + types: [ python ] + files: "pyproject.toml" + pass_filenames: false + language: system + entry: poetry run nox -s fix + + - repo: local + hooks: + - id: type-check + name: type-check + types: [ python ] + pass_filenames: false + language: system + entry: poetry run nox -s type-check + + - repo: local + hooks: + - id: lint + name: lint + types: [ python ] + pass_filenames: false + language: system + entry: poetry run nox -s lint + + - repo: local + hooks: + - id: generate-api + name: generate-api + types: [ python ] + pass_filenames: false + language: system + entry: poetry run nox -s generate-api + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace diff --git a/doc/changes/changes_0.1.0.md b/doc/changes/changes_0.1.0.md index 3a52d0e..3cfd60a 100644 --- a/doc/changes/changes_0.1.0.md +++ b/doc/changes/changes_0.1.0.md @@ -8,6 +8,9 @@ This is the initial release of the Exasol SaaS API for Python enabling Python ap n/a +## Refactoring + +* #10: Add pre-commit hook ## Feature diff --git a/doc/developer_guide/developer_guide.md b/doc/developer_guide/developer_guide.md index 9574326..fd9aa11 100644 --- a/doc/developer_guide/developer_guide.md +++ b/doc/developer_guide/developer_guide.md @@ -1,5 +1,18 @@ # SaaS API for Python — Developer Guide +## Git Pre-Commit Hooks + +saas-api-python includes a file `.pre-commit-config.yaml`. + +The following command installs the pre-commit hooks, see also [framework pre-commmit](https://pre-commit.com/) and Git +documentation on [Customizing Git Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks): + +```shell +poetry run pre-commit install +``` + +When the hooks are installed, then git will run each of the hooks on the resp. stage, e.g. before executing a commit. + ## Generate the API Model The model layer of this API has been generated from the OpenAPI specification diff --git a/pyproject.toml b/pyproject.toml index 2076eb8..524f3dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,10 @@ ignore = [ "version.py", "noxconfig.py", ] +ignore-paths = [ + ".*/exasol/saas/client/openapi/.*", +] + [[tool.mypy.overrides]] module = [