-
Notifications
You must be signed in to change notification settings - Fork 179
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
Ct 177/add precommit hooks #107
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0b69a36
Add various prechecks.
VersusFacit e07889b
Add commit hooks and get them working.
VersusFacit 9a075f3
Update Makefile for use in this repo.
VersusFacit afea714
Add linecheck recipe (all Python lines over 99).
VersusFacit b03c472
Bring flake8 into compilance with dbt core.
VersusFacit dadbd42
Ct 177/part2 format code over (#108)
VersusFacit a6671b9
Resolve a merge conflict against main to get this passing.
VersusFacit 09ddc1d
Add changelog entry.
VersusFacit fe4bb3e
Merge branch 'main' into CT-177/add_precommit_hooks
VersusFacit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[flake8] | ||
select = | ||
E | ||
W | ||
F | ||
ignore = | ||
W503 # makes Flake8 work like black | ||
W504 | ||
E203 # makes Flake8 work like black | ||
E741 | ||
E501 | ||
exclude = test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ name: Jira Issue Creation | |
on: | ||
issues: | ||
types: [opened, labeled] | ||
|
||
permissions: | ||
issues: write | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# For more on configuring pre-commit hooks (see https://pre-commit.com/) | ||
|
||
# TODO: remove global exclusion of tests when testing overhaul is complete | ||
exclude: '^tests/.*' | ||
|
||
# Force all unspecified python hooks to run python 3.8 | ||
default_language_version: | ||
python: python3.8 | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.2.0 | ||
hooks: | ||
- id: check-yaml | ||
args: [--unsafe] | ||
- id: check-json | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: check-case-conflict | ||
- repo: https://github.com/psf/black | ||
rev: 21.12b0 | ||
hooks: | ||
- id: black | ||
additional_dependencies: ['click==8.0.4'] | ||
args: | ||
- "--line-length=99" | ||
- "--target-version=py38" | ||
- id: black | ||
alias: black-check | ||
stages: [manual] | ||
additional_dependencies: ['click==8.0.4'] | ||
args: | ||
- "--line-length=99" | ||
- "--target-version=py38" | ||
- "--check" | ||
- "--diff" | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 4.0.1 | ||
hooks: | ||
- id: flake8 | ||
- id: flake8 | ||
alias: flake8-check | ||
stages: [manual] | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v0.782 | ||
hooks: | ||
- id: mypy | ||
# N.B.: Mypy is... a bit fragile. | ||
# | ||
# By using `language: system` we run this hook in the local | ||
# environment instead of a pre-commit isolated one. This is needed | ||
# to ensure mypy correctly parses the project. | ||
|
||
# It may cause trouble in that it adds environmental variables out | ||
# of our control to the mix. Unfortunately, there's nothing we can | ||
# do about per pre-commit's author. | ||
# See https://github.com/pre-commit/pre-commit/issues/730 for details. | ||
args: [--show-error-codes, --ignore-missing-imports] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the |
||
files: ^dbt/adapters/.* | ||
language: system | ||
- id: mypy | ||
alias: mypy-check | ||
stages: [manual] | ||
args: [--show-error-codes, --pretty, --ignore-missing-imports] | ||
files: ^dbt/adapters | ||
language: system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
recursive-include dbt/include *.sql *.yml *.md | ||
recursive-include dbt/include *.sql *.yml *.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.DEFAULT_GOAL:=help | ||
|
||
.PHONY: dev | ||
dev: ## Installs adapter in develop mode along with development depedencies | ||
@\ | ||
pip install -r dev_requirements.txt && pre-commit install | ||
|
||
.PHONY: mypy | ||
mypy: ## Runs mypy against staged changes for static type checking. | ||
@\ | ||
pre-commit run --hook-stage manual mypy-check | grep -v "INFO" | ||
|
||
.PHONY: flake8 | ||
flake8: ## Runs flake8 against staged changes to enforce style guide. | ||
@\ | ||
pre-commit run --hook-stage manual flake8-check | grep -v "INFO" | ||
|
||
.PHONY: black | ||
black: ## Runs black against staged changes to enforce style guide. | ||
@\ | ||
pre-commit run --hook-stage manual black-check -v | grep -v "INFO" | ||
|
||
.PHONY: lint | ||
lint: ## Runs flake8 and mypy code checks against staged changes. | ||
@\ | ||
pre-commit run flake8-check --hook-stage manual | grep -v "INFO"; \ | ||
pre-commit run mypy-check --hook-stage manual | grep -v "INFO" | ||
|
||
.PHONY: linecheck | ||
linecheck: ## Checks for all Python lines 100 characters or more | ||
@\ | ||
find dbt -type f -name "*.py" -exec grep -I -r -n '.\{100\}' {} \; | ||
|
||
.PHONY: unit | ||
unit: ## Runs unit tests with py38. | ||
@\ | ||
tox -e py38 | ||
|
||
.PHONY: test | ||
test: ## Runs unit tests with py38 and code checks against staged changes. | ||
@\ | ||
tox -p -e py38; \ | ||
pre-commit run black-check --hook-stage manual | grep -v "INFO"; \ | ||
pre-commit run flake8-check --hook-stage manual | grep -v "INFO"; \ | ||
pre-commit run mypy-check --hook-stage manual | grep -v "INFO" | ||
|
||
.PHONY: integration | ||
integration: ## Runs snowflake integration tests with py38. | ||
@\ | ||
tox -e py38-snowflake -- | ||
|
||
.PHONY: clean | ||
@echo "cleaning repo" | ||
@git clean -f -X | ||
|
||
.PHONY: help | ||
help: ## Show this help message. | ||
@echo 'usage: make [target]' | ||
@echo | ||
@echo 'targets:' | ||
@grep -E '^[7+a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = '1.1.0b1' | ||
version = "1.1.0b1" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per psf/black#2964 (comment)