diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..61c0d0a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,61 @@ +default_language_version: + python: python3 + +exclude: ^(./.venv/|./build/) +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + # Identify invalid files + - id: check-ast + - id: check-yaml + - id: check-json + - id: check-toml + + # git checks + - id: check-merge-conflict + - id: check-added-large-files + - id: detect-private-key + - id: check-case-conflict + + # Python checks + - id: check-docstring-first + - id: debug-statements + - id: requirements-txt-fixer + - id: fix-byte-order-marker + + # General quality checks + - id: mixed-line-ending + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - id: end-of-file-fixer + + - repo: https://github.com/PyCQA/autoflake + rev: v2.0.1 + hooks: + - id: autoflake + + - repo: https://github.com/asottile/pyupgrade + rev: v3.3.1 + hooks: + - id: pyupgrade + args: + - '--py37-plus' + + - repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + additional_dependencies: ['click~=8.1'] + args: + - "--line-length=99" + - "--target-version=py37" + - id: black + alias: black-check + stages: [manual] + additional_dependencies: ['click~=8.1'] + args: + - "--line-length=99" + - "--target-version=py37" + - "--check" + - "--diff" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 54b3acd..177d7ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,6 +49,8 @@ If you are a member of the `Cloudera` GitHub organization, you will have push ac 4. Install `dbt-impala` and development dependencies in the active `virtualenv`. Run `pip install -e . -r dev-requirements.txt`. +5. Add the pre-commit hook. Run `pre-commit install` + When `dbt-impala` is installed this way, any changes you make to the `dbt-impala` source code will be reflected immediately (i.e. in your next local dbt invocation against a Impala target). ## Testing diff --git a/dev-requirements.txt b/dev-requirements.txt index 651f74a..1d63259 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,3 +1,4 @@ dbt-tests-adapter==1.3.* +precommit pytest pytest-dotenv