# Configuration for pre-commit hooks (see https://pre-commit.com/). # Eventually the hooks described here will be run as tests before merging each PR. exclude: ^(core/dbt/docs/build/|core/dbt/common/events/types_pb2.py|core/dbt/adapters/events/adapter_types_pb2.py) # Force all unspecified python hooks to run python 3.10 default_language_version: python: python3 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 exclude: schemas/dbt/manifest/ - id: trailing-whitespace exclude_types: - "markdown" - id: check-case-conflict # local hooks are used to run the hooks in the local environment instead of a pre-commit isolated one. # This ensures that the hooks are run with the same version of the dependencies as the local environment # without having to manually keep them in sync. - repo: local hooks: # Formatter/linter/type-checker pins live in the pyproject.dev optional dependency. - id: isort name: isort entry: python -m isort language: system types: [python] - id: black name: black entry: python -m black language: system types: [python] - id: black-check name: black-check entry: python -m black args: - "--check" - "--diff" language: system stages: [manual] types: [python] - id: flake8 name: flake8 entry: python -m flake8 language: system types: [python] - id: flake8-check name: flake8-check entry: python -m flake8 language: system stages: [manual] types: [python] # 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. - id: mypy name: mypy entry: python -m mypy args: [--show-error-codes] files: ^core/dbt/ language: system types: [python] - id: mypy-check name: mypy-check entry: python -m mypy args: [--show-error-codes, --pretty] files: ^core/dbt/ language: system stages: [manual] types: [python] - id: no_versioned_artifact_resource_imports name: no_versioned_artifact_resource_imports entry: python scripts/pre-commit-hooks/no_versioned_artifact_resource_imports.py language: system files: ^core/dbt/ types: [python] pass_filenames: true