Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBT-693: Pre-commit checks for code quality and syntax, for python 3.7 plus #171

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
1. [About this document](#about-this-document)
2. [Getting the code](#getting-the-code)
3. [Running `dbt-impala` in development](#running-dbt-impala-in-development)
4. [Testing](#testing)
4. [Submitting a Pull Request](#submitting-a-pull-request)

## About this document
Expand Down Expand Up @@ -49,6 +50,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
Expand Down Expand Up @@ -76,6 +79,9 @@ You may run a specific test or group of tests using `pytest` directly. Activate
```sh
# Note: replace $strings with valid names

# run full tests suite against an environment/endpoint
python -m pytest --profile dwx_endpoint

# run all impala functional tests in a directory
python -m pytest tests/functional/$test_directory --profile dwx_endpoint
python -m pytest tests/functional/adapter/test_basic.py --profile dwx_endpoint
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The `dbt-impala` adapter allows you to use [dbt](https://www.getdbt.com/) along
Current version of dbt-impala work only with dbt-core 1.3 but not with dbt-core >= 1.4.
We are actively working on next release 1.4 which will work with dbt-core 1.4

Python >= 3.8
Python >= 3.7
dbt-core == 1.3.*

For development/testing or contribution to the dbt-impala, please follow [Contributing](CONTRIBUTING.md) guidelines.
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dbt-tests-adapter==1.3.*
pre-commit~=2.21;python_version=="3.7"
pre-commit~=3.2;python_version>="3.8"
pytest
pytest-dotenv
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def _get_dbt_core_version():
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: Apache Software License",
Expand Down