Skip to content

Commit 89df9fc

Browse files
authored
Clean up and standardize the pre-commit config (#48758)
* Clean up and standardize the pre-commit config * Update .pre-commit-config.yaml * Remove unneeded entry
1 parent 8e63e3b commit 89df9fc

File tree

1 file changed

+49
-48
lines changed

1 file changed

+49
-48
lines changed

.pre-commit-config.yaml

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
- id: doctoc
3636
name: Add TOC for Markdown and RST files
3737
files:
38-
^README\.md$|^UPDATING.*\.md$|^chart/UPDATING.*\.md$|^dev/.*\.md$|^dev/.*\.rst$|^.github/.*\.md|^airflow-core/tests/system/README.md$
38+
^README\.md$|^UPDATING.*\.md$|^chart/UPDATING.*\.md$|^dev/.*\.md$|^dev/.*\.rst$|^\.github/.*\.md|^airflow-core/tests/system/README\.md$
3939
args:
4040
- "--maxlevel"
4141
- "2"
@@ -125,7 +125,7 @@ repos:
125125
- --fuzzy-match-generates-todo
126126
- id: insert-license
127127
name: Add license for all YAML files except Helm templates
128-
exclude: ^\.github/.*$|^chart/templates/.*|.*reproducible_build.yaml$|^.*/v1-generated.yaml$|^.*/pnpm-lock.yaml$
128+
exclude: ^\.github/.*$|^chart/templates/.*|.*reproducible_build\.yaml$|^.*/v1-generated\.yaml$|^.*/pnpm-lock\.yaml$
129129
types: [yaml]
130130
files: \.ya?ml$
131131
args:
@@ -154,7 +154,7 @@ repos:
154154
- scripts/ci/license-templates/LICENSE.txt
155155
- --fuzzy-match-generates-todo
156156
files: >
157-
\.cfg$|\.conf$|\.ini$|\.ldif$|\.properties$|\.readthedocs$|\.service$|\.tf$|Dockerfile.*$
157+
\.cfg$|\.conf$|\.ini$|\.ldif$|\.properties$|\.service$|\.tf$|Dockerfile.*$
158158
- repo: local
159159
hooks:
160160
- id: check-min-python-version
@@ -175,7 +175,7 @@ repos:
175175
entry: ./scripts/ci/pre_commit/update_black_version.py
176176
stages: ['manual']
177177
language: python
178-
files: ^.pre-commit-config.yaml$
178+
files: ^\.pre-commit-config\.yaml$
179179
additional_dependencies: ['pyyaml>=6.0.2']
180180
pass_filenames: false
181181
require_serial: true
@@ -184,7 +184,7 @@ repos:
184184
entry: ./scripts/ci/pre_commit/update_installers_and_pre_commit.py
185185
stages: ['manual']
186186
language: python
187-
files: ^.pre-commit-config.yaml$|^scripts/ci/pre_commit/update_installers_and_pre_commit.py$
187+
files: ^\.pre-commit-config\.yaml$|^scripts/ci/pre_commit/update_installers_and_pre_commit\.py$
188188
pass_filenames: false
189189
require_serial: true
190190
additional_dependencies: ['pyyaml>=6.0.2', 'rich>=12.4.4', 'requests>=2.31.0']
@@ -194,15 +194,15 @@ repos:
194194
stages: ['manual']
195195
language: python
196196
additional_dependencies: ['pyyaml>=6.0.2', 'rich>=12.4.4', 'requests>=2.31.0']
197-
files: ^.pre-commit-config.yaml$|^scripts/ci/pre_commit/update_build_dependencies.py$
197+
files: ^\.pre-commit-config\.yaml$|^scripts/ci/pre_commit/update_build_dependencies\.py$
198198
pass_filenames: false
199199
require_serial: true
200200
- id: check-taskinstance-tis-attrs
201201
name: Check that TI and TIS have the same attributes
202202
entry: ./scripts/ci/pre_commit/check_ti_vs_tis_attributes.py
203203
language: python
204204
additional_dependencies: ['rich>=12.4.4']
205-
files: ^airflow-core/src/airflow/models/taskinstance.py$|^airflow-core/src/airflow/models/taskinstancehistory.py$
205+
files: ^airflow-core/src/airflow/models/taskinstance\.py$|^airflow-core/src/airflow/models/taskinstancehistory\.py$
206206
pass_filenames: false
207207
require_serial: true
208208
- id: check-deferrable-default
@@ -236,10 +236,10 @@ repos:
236236
name: Require literal syntax when initializing builtins
237237
- id: detect-private-key
238238
name: Detect if private key is added to the repository
239-
exclude: ^providers/ssh/docs/connections/ssh.rst$
239+
exclude: ^providers/ssh/docs/connections/ssh\.rst$
240240
- id: end-of-file-fixer
241241
name: Make sure that there is an empty line at the end
242-
exclude: ^airflow-core/docs/img/.*\.dot|^airflow-core/docs/img/.*\.sha256|.*/dist/.*|LICENSES-ui.txt
242+
exclude: ^airflow-core/docs/img/.*\.dot|^airflow-core/docs/img/.*\.sha256|.*/dist/.*|LICENSES-ui\.txt$
243243
- id: mixed-line-ending
244244
name: Detect if mixed line ending is used (\r vs. \r\n)
245245
- id: check-executables-have-shebangs
@@ -248,7 +248,7 @@ repos:
248248
name: Check XML files with xmllint
249249
- id: trailing-whitespace
250250
name: Remove trailing whitespace at end of line
251-
exclude: ^airflow-core/docs/img/.*\.dot|^dev/breeze/doc/images/output.*$
251+
exclude: ^airflow-core/docs/img/.*\.dot$|^dev/breeze/doc/images/output.*$
252252
- id: fix-encoding-pragma
253253
name: Remove encoding header from Python files
254254
args:
@@ -284,7 +284,7 @@ repos:
284284
.*/v1-generated\.yaml$|
285285
^.*openapi.*\.yaml$|
286286
^\.pre-commit-config\.yaml$|
287-
^.*reproducible_build.yaml$|
287+
^.*reproducible_build\.yaml$|
288288
^.*pnpm-lock\.yaml$
289289
- repo: https://github.com/ikamensh/flynt
290290
rev: '1.0.1'
@@ -319,7 +319,7 @@ repos:
319319
- id: zizmor
320320
name: Run zizmor to check for github workflow syntax errors
321321
types: [yaml]
322-
files: \.github/workflows/.*$|\.github/actions/.*$
322+
files: ^\.github/workflows/.*$|^\.github/actions/.*$
323323
require_serial: true
324324
entry: zizmor
325325
- repo: local
@@ -353,13 +353,13 @@ repos:
353353
pass_filenames: true
354354
files: |
355355
(?x)
356-
^providers/[^\/]*/src/airflow/providers/[^\/]*/__init__.py$|
357-
^providers/[^\/]*/[^\/]*/src/airflow/providers/[^\/]*/[^\/]*/__init__.py$|
356+
^providers/[^\/]*/src/airflow/providers/[^\/]*/__init__\.py$|
357+
^providers/[^\/]*/[^\/]*/src/airflow/providers/[^\/]*/[^\/]*/__init__\.py$|
358358
^providers/.*/pyproject\.toml$|
359-
^providers/.*/provider.yaml$|
360-
^airflow_breeze/templates/PROVIDER__INIT__PY_TEMPLATE.py.jinja2$
361-
^airflow_breeze/templates/get_provider_info_TEMPLATE.py.jinja2$
362-
^airflow_breeze/templates/PROVIDER_README_TEMPLATE.rst.jinja2$
359+
^providers/.*/provider\.yaml$|
360+
^airflow_breeze/templates/PROVIDER__INIT__PY_TEMPLATE\.py\.jinja2$|
361+
^airflow_breeze/templates/get_provider_info_TEMPLATE\.py\.jinja2$|
362+
^airflow_breeze/templates/PROVIDER_README_TEMPLATE\.rst\.jinja2$
363363
additional_dependencies: ['rich>=12.4.4','requests>=2.31.0']
364364
require_serial: true
365365
- id: ruff
@@ -371,7 +371,7 @@ repos:
371371
args: [--fix]
372372
require_serial: true
373373
additional_dependencies: ['ruff==0.11.2']
374-
exclude: ^airflow-core/tests/unit/dags/test_imports.py|^performance/tests/test_.*.py
374+
exclude: ^airflow-core/tests/unit/dags/test_imports\.py$|^performance/tests/test_.*\.py$
375375
- id: ruff-format
376376
name: Run 'ruff format'
377377
description: "Run 'ruff format' for extremely fast Python formatting"
@@ -381,7 +381,7 @@ repos:
381381
args: []
382382
require_serial: true
383383
additional_dependencies: ['ruff==0.11.2']
384-
exclude: ^airflow-core/tests/unit/dags/test_imports.py$
384+
exclude: ^airflow-core/tests/unit/dags/test_imports\.py$
385385
- id: replace-bad-characters
386386
name: Replace bad characters
387387
entry: ./scripts/ci/pre_commit/replace_bad_characters.py
@@ -415,7 +415,7 @@ repos:
415415
- id: check-airflow-providers-bug-report-template
416416
name: Sort airflow-bug-report provider list
417417
language: python
418-
files: ^.github/ISSUE_TEMPLATE/airflow_providers_bug_report\.yml$
418+
files: ^\.github/ISSUE_TEMPLATE/airflow_providers_bug_report\.yml$
419419
require_serial: true
420420
entry: ./scripts/ci/pre_commit/check_airflow_bug_report_template.py
421421
additional_dependencies: ['rich>=12.4.4', 'pyyaml>=6.0.2']
@@ -445,7 +445,7 @@ repos:
445445
name: Checks setup extra packages
446446
description: Checks if all the extras defined in hatch_build.py are listed in extra-packages-ref.rst file
447447
language: python
448-
files: ^airflow-core/docs/extra-packages-ref\.rst$|^hatch_build.py
448+
files: ^airflow-core/docs/extra-packages-ref\.rst$|^hatch_build\.py$
449449
pass_filenames: false
450450
entry: ./scripts/ci/pre_commit/check_extra_packages_ref.py
451451
additional_dependencies: ['rich>=12.4.4', 'hatchling==1.27.0', 'tabulate>=0.9.0']
@@ -467,7 +467,7 @@ repos:
467467
name: Generate volumes for docker compose
468468
entry: ./scripts/ci/pre_commit/generate_volumes_for_sources.py
469469
language: python
470-
files: ^providers/.*/provider.yaml$
470+
files: ^providers/.*/provider\.yaml$
471471
pass_filenames: false
472472
require_serial: true
473473
additional_dependencies: ['rich>=12.4.4']
@@ -488,14 +488,14 @@ repos:
488488
^scripts/ci/pre_commit/version_heads_map\.py$|
489489
^airflow-core/src/airflow/migrations/versions/.*$|^airflow-core/src/airflow/migrations/versions|
490490
^providers/fab/src/airflow/providers/fab/migrations/versions/.*$|^providers/fab/src/airflow/providers/fab/migrations/versions|
491-
^airflow-core/src/airflow/utils/db.py$|
492-
^providers/fab/src/airflow/providers/fab/auth_manager/models/db.py$
491+
^airflow-core/src/airflow/utils/db\.py$|
492+
^providers/fab/src/airflow/providers/fab/auth_manager/models/db\.py$
493493
additional_dependencies: ['packaging>=23.2', 'rich>=12.4.4']
494494
- id: update-version
495495
name: Update versions in docs
496496
entry: ./scripts/ci/pre_commit/update_versions.py
497497
language: python
498-
files: ^docs|^airflow-core/src/airflow/__init__.py$
498+
files: ^docs|^airflow-core/src/airflow/__init__\.py$
499499
pass_filenames: false
500500
additional_dependencies: ['rich>=12.4.4']
501501
- id: check-pydevd-left-in-code
@@ -597,8 +597,8 @@ repos:
597597
^providers/opsgenie/src/airflow/providers/opsgenie/hooks/opsgenie\.py$|
598598
^providers/redis/src/airflow/providers/redis/provider\.yaml$|
599599
^airflow-core/src/airflow/serialization/serialized_objects\.py$|
600-
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/pnpm-lock.yaml|
601-
^airflow-core/src/airflow/ui/pnpm-lock.yaml$|
600+
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/pnpm-lock\.yaml$|
601+
^airflow-core/src/airflow/ui/pnpm-lock\.yaml$|
602602
^airflow-core/src/airflow/utils/db\.py$|
603603
^airflow-core/src/airflow/utils/trigger_rule\.py$|
604604
^chart/values.schema\.json$|
@@ -619,11 +619,11 @@ repos:
619619
^devel-common/src/sphinx_exts/removemarktransform\.py|
620620
^airflow-core/newsfragments/41761.significant\.rst$|
621621
^scripts/ci/pre_commit/vendor_k8s_json_schema\.py$|
622-
^scripts/ci/docker-compose/integration-keycloak.yml$|
623-
^scripts/ci/docker-compose/keycloak/keycloak-entrypoint.sh$|
622+
^scripts/ci/docker-compose/integration-keycloak\.yml$|
623+
^scripts/ci/docker-compose/keycloak/keycloak-entrypoint\.sh$|
624624
^airflow-core/tests/|
625625
^providers/.*/tests/|
626-
^.pre-commit-config\.yaml$|
626+
^\.pre-commit-config\.yaml$|
627627
^.*CHANGELOG\.(rst|txt)$|
628628
^.*changelog\.(rst|txt)$|
629629
^.*commits\.(rst|txt)$|
@@ -814,7 +814,7 @@ repos:
814814
- id: compile-fab-assets
815815
name: Compile FAB provider assets
816816
language: node
817-
'types_or': [ javascript, ts, tsx ]
817+
'types_or': [javascript, ts, tsx]
818818
files: ^providers/fab/.*/www/
819819
entry: ./scripts/ci/pre_commit/compile_fab_assets.py
820820
pass_filenames: false
@@ -850,7 +850,7 @@ repos:
850850
name: Sync integrations list with docs
851851
entry: ./scripts/ci/pre_commit/check_integrations_list.py
852852
language: python
853-
files: ^scripts/ci/docker-compose/integration-.*\.yml$|^contributing-docs/testing/integration_tests.rst$
853+
files: ^scripts/ci/docker-compose/integration-.*\.yml$|^contributing-docs/testing/integration_tests\.rst$
854854
additional_dependencies: ['black==24.10.0', 'tabulate>=0.9.0', 'rich>=12.4.4', 'pyyaml>=6.0.2']
855855
require_serial: true
856856
pass_filenames: false
@@ -866,15 +866,15 @@ repos:
866866
name: Update Airflow's meta-package pyproject.toml
867867
language: python
868868
entry: ./scripts/ci/pre_commit/update_airflow_pyproject_toml.py
869-
files: ^pyproject.toml$
869+
files: ^pyproject\.toml$
870870
pass_filenames: false
871871
require_serial: true
872872
additional_dependencies: ['rich>=12.4.4', 'tomli>=2.0.1']
873873
- id: update-reproducible-source-date-epoch
874874
name: Update Source Date Epoch for reproducible builds
875875
language: python
876876
entry: ./scripts/ci/pre_commit/update_source_date_epoch.py
877-
files: ^RELEASE_NOTES.rst$|^chart/RELEASE_NOTES.rst$
877+
files: ^RELEASE_NOTES\.rst$|^chart/RELEASE_NOTES\.rst$
878878
additional_dependencies: ['rich>=12.4.4', 'pyyaml>=6.0.2']
879879
pass_filenames: false
880880
require_serial: true
@@ -891,7 +891,7 @@ repos:
891891
name: Check if tests are in the right folders
892892
entry: ./scripts/ci/pre_commit/check_tests_in_right_folders.py
893893
language: python
894-
files: ^airflow-core/tests/.*\.py
894+
files: ^airflow-core/tests/.*\.py$
895895
pass_filenames: true
896896
require_serial: true
897897
additional_dependencies: ['rich>=12.4.4']
@@ -950,7 +950,7 @@ repos:
950950
exclude: >
951951
(?x)
952952
^scripts/ci/docker-compose/grafana/.|
953-
^scripts/ci/docker-compose/.+-config\.ya?ml
953+
^scripts/ci/docker-compose/.+-config\.ya?ml$
954954
require_serial: true
955955
additional_dependencies: ['jsonschema>=3.2.0,<5.0', 'pyyaml>=6.0.2', 'requests==2.32.3', 'rich>=12.4.4']
956956
- id: lint-json-schema
@@ -1054,7 +1054,7 @@ repos:
10541054
- id: check-newsfragments-are-valid
10551055
name: Check newsfragments are valid
10561056
language: python
1057-
files: newsfragments/.*\.rst
1057+
files: newsfragments/.*\.rst$
10581058
entry: ./scripts/ci/pre_commit/newsfragments.py
10591059
pass_filenames: true
10601060
# We sometimes won't have newsfragments in the repo, so always run it so `check-hooks-apply` passes
@@ -1064,7 +1064,7 @@ repos:
10641064
name: Check significant newsfragments are valid
10651065
# Significant newsfragments follows a special format so that we can group information easily.
10661066
language: python
1067-
files: airflow-core/newsfragments/.*\.rst
1067+
files: airflow-core/newsfragments/.*\.rst$
10681068
entry: ./scripts/ci/pre_commit/significant_newsfragments_checker.py
10691069
pass_filenames: false
10701070
additional_dependencies: ['docutils>=0.21.2', 'pygments>=2.19.1', 'jinja2>=3.1.5']
@@ -1080,8 +1080,8 @@ repos:
10801080
(?x)
10811081
^dev/breeze/.*$|
10821082
^\.pre-commit-config\.yaml$|
1083-
^scripts/ci/pre_commit/breeze_cmd_line.py$|
1084-
^generated/provider_dependencies.json$
1083+
^scripts/ci/pre_commit/breeze_cmd_line\.py$|
1084+
^generated/provider_dependencies\.json$
10851085
require_serial: true
10861086
pass_filenames: false
10871087
additional_dependencies: ['rich>=12.4.4']
@@ -1125,7 +1125,7 @@ repos:
11251125
name: Validate provider doc files
11261126
entry: ./scripts/ci/pre_commit/check_provider_docs.py
11271127
language: python
1128-
files: ^providers/.*/provider\.yaml|^.*/docs/.*
1128+
files: ^providers/.*/provider\.yaml$|^.*/docs/.*
11291129
additional_dependencies: ['rich>=12.4.4', 'pyyaml>=6.0.2', 'jinja2']
11301130
require_serial: true
11311131
pass_filenames: false
@@ -1135,7 +1135,7 @@ repos:
11351135
entry: bandit
11361136
language: python
11371137
language_version: python3
1138-
types: [ python ]
1138+
types: [python]
11391139
additional_dependencies: ['bandit==1.7.6']
11401140
require_serial: true
11411141
files: ^airflow-core/src/airflow/.*
@@ -1152,7 +1152,7 @@ repos:
11521152
entry: pylint
11531153
language: python
11541154
language_version: python3
1155-
types: [ python ]
1155+
types: [python]
11561156
additional_dependencies: ['pylint==3.1.0']
11571157
require_serial: true
11581158
files: ^airflow-core/src/airflow/.*
@@ -1274,7 +1274,7 @@ repos:
12741274
name: Run mypy for airflow-ctl
12751275
language: python
12761276
entry: ./scripts/ci/pre_commit/mypy.py
1277-
files: ^airflow-ctl/src/airflowctl/.*\.py$|^airflow-ctl/tests//.*\.py$
1277+
files: ^airflow-ctl/src/airflowctl/.*\.py$|^airflow-ctl/tests/.*\.py$
12781278
require_serial: true
12791279
additional_dependencies: ['rich>=12.4.4']
12801280
- id: mypy-airflow-ctl
@@ -1301,8 +1301,9 @@ repos:
13011301
types_or: [javascript, ts, tsx, yaml, css, json]
13021302
files: |
13031303
(?x)
1304-
^airflow-core/src/airflow/ui/|^airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-generated\.yaml$ |
1305-
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/ |
1304+
^airflow-core/src/airflow/ui/|
1305+
^airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-generated\.yaml$|
1306+
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/|
13061307
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/openapi/v1-generated\.yaml$
13071308
entry: ./scripts/ci/pre_commit/compile_lint_ui.py
13081309
additional_dependencies: ['[email protected]']
@@ -1350,5 +1351,5 @@ repos:
13501351
additional_dependencies: ['rich>=12.4.4']
13511352
require_serial: true
13521353
pass_filenames: false
1353-
files: ^airflow-core/src/airflow/config_templates/config.yml
1354+
files: ^airflow-core/src/airflow/config_templates/config\.yml$
13541355
## ONLY ADD PRE-COMMITS HERE THAT REQUIRE CI IMAGE

0 commit comments

Comments
 (0)