Skip to content

Commit

Permalink
move linting config from pyproject.toml to pre-commit-config
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Apr 19, 2024
1 parent 8e33957 commit 7fd8197
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 64 deletions.
1 change: 0 additions & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ on:
required: false
default: "main"


permissions: read-all

# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
Expand Down
59 changes: 42 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,45 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict
- repo: local
hooks:
- id: black
name: black
entry: black
language: system
types: [python]
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
- id: mypy
name: mypy
entry: mypy
language: system
types: [python]

- repo: https://github.com/dbt-labs/pre-commit-hooks
rev: v0.1.0a1
hooks:
- id: dbt-core-in-adapters-check

- repo: https://github.com/psf/black
rev: 24.4.0
hooks:
- id: black
args:
- --line-length=99
- --target-version=py38
- --target-version=py39
- --target-version=py310
- --target-version=py311

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
exclude: tests/
args:
- --max-line-length=99
- --select=E,F,W
- --ignore=E203,E501,E741,W503,W504
- --per-file-ignores=*/__init__.py:F401

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
args:
- --explicit-package-bases
- --ignore-missing-imports
- --pretty
- --show-error-codes
files: ^dbt/adapters/postgres
additional_dependencies:
- types-PyYAML
- types-protobuf
- types-pytz
49 changes: 3 additions & 46 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,27 @@ path = "dbt/adapters/postgres/__version__.py"
dependencies = [
"dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git",
"dbt-common @ git+https://github.com/dbt-labs/dbt-common.git",
"black>=24.3",
"flake8",
"Flake8-pyproject",
"pre-commit==3.7.0",
"mypy",
"types-protobuf",
"types-pytz",
"types-PyYAML",
]
[tool.hatch.envs.default.scripts]
dev = "pre-commit install"
code-quality = "pre-commit run --all-files" # runs others via hooks
black = "python -m black ."
flake8 = "python -m flake8 ."
mypy = "python -m mypy ."
code-quality = "pre-commit run --all-files"

[tool.hatch.envs.unit-tests]
dependencies = [
extra-dependencies = [
"dbt-core @ git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core",
"freezegun",
"pytest",
"pytest-dotenv",
"pytest-mock",
"pytest-xdist",
]
extra-dependencies = [
"dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git",
"dbt-common @ git+https://github.com/dbt-labs/dbt-common.git",
"dbt-core @ git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core",
]
[tool.hatch.envs.unit-tests.scripts]
all = "python -m pytest {args:tests/unit}"

[tool.hatch.envs.integration-tests]
template = "unit-tests"
extra-dependencies = [
# TODO: remove `dbt-core` dependencies from integration tests
"dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git",
"dbt-common @ git+https://github.com/dbt-labs/dbt-common.git",
"dbt-core @ git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core",
"dbt-tests-adapter @ git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter",
]
Expand Down Expand Up @@ -130,32 +113,6 @@ check-sdist = [
"pip freeze | grep dbt-postgres",
]

[tool.black]
line-length = 99
target-version = ['py38']

[tool.flake8]
select = ["E", "W", "F"]
ignore = ["E203", "E501", "E741", "W503", "W504"]
exclude = ["tests", "venv", ".hatch_venvs"]
per-file-ignores = ["*/__init__.py: F401"]

[tool.mypy]
namespace_packages = true
show_error_codes = true
explicit_package_bases = true
ignore_missing_imports = true
pretty = true
files = [
"dbt/adapters/postgres",
"tests/unit",
]
exclude = [
"tests/functional",
"venv",
".hatch_venvs",
]

[tool.pytest]
env_files = ["test.env"]
testpaths = [
Expand Down

0 comments on commit 7fd8197

Please sign in to comment.