Skip to content

Commit 5c77949

Browse files
authored
Auto-upgrade sphinx-airflow-theme version in prek hook (#63763)
Add sphinx-airflow-theme to the upgrade-important-versions prek hook so it automatically fetches the latest version from https://airflow.apache.org/sphinx-airflow-theme/LATEST_VERSION.txt and updates the whl URL in devel-common/pyproject.toml. Also fix selective checks tests (add update-uv-lock to skip-prek-hooks expectations) and resolve mypy errors in selective_checks.py.
1 parent 9f30000 commit 5c77949

16 files changed

Lines changed: 459 additions & 463 deletions

File tree

.github/actions/install-prek/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ inputs:
2727
default: "0.10.10" # Keep this comment to allow automatic replacement of uv version
2828
prek-version:
2929
description: 'prek version to use'
30-
default: "0.3.5" # Keep this comment to allow automatic replacement of prek version
30+
default: "0.3.6" # Keep this comment to allow automatic replacement of prek version
3131
save-cache:
3232
description: "Whether to save prek cache"
3333
required: true

.pre-commit-config.yaml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -259,24 +259,6 @@ repos:
259259
^scripts/ci/prek/update_installers_and_prek\.py$
260260
pass_filenames: false
261261
require_serial: true
262-
- id: uv-sync
263-
name: Run uv sync
264-
entry: uv sync
265-
language: system
266-
files: (^|/)pyproject\.toml$
267-
pass_filenames: false
268-
require_serial: true
269-
- id: update-uv-lock
270-
name: Update uv.lock (manual)
271-
entry: ./scripts/ci/prek/update_uv_lock.py
272-
stages: ['manual']
273-
language: python
274-
files: >
275-
(?x)
276-
^pyproject\.toml$|
277-
^uv\.lock$
278-
pass_filenames: false
279-
require_serial: true
280262
- repo: https://github.com/adamchainz/blacken-docs
281263
rev: fda77690955e9b63c6687d8806bafd56a526e45f # frozen: 1.20.0
282264
hooks:
@@ -998,8 +980,22 @@ repos:
998980
pass_filenames: false
999981
files: ^dev/breeze/src/airflow_breeze/global_constants\.py$
1000982
require_serial: true
983+
# This is a fast regular hook that runs when any pyproject.toml changes
984+
# It runs locally and usually will not result in modifying the lock unnecessarily
985+
# Unless there is a conflict and uv will determine that the lock needs to be updated to resolve it
986+
- id: update-uv-lock
987+
name: Update uv.lock
988+
entry: uv sync
989+
language: system
990+
files: >
991+
(?x)
992+
(^|/)pyproject\.toml$|
993+
^uv\.lock$
994+
pass_filenames: false
995+
require_serial: true
1001996
## ADD MOST PREK HOOK ABOVE THAT LINE
1002997
# The below prek hooks are those requiring CI image to be built
998+
## ONLY ADD PREK HOOKS HERE THAT REQUIRE CI IMAGE
1003999
- id: mypy-dev
10041000
stages: ['pre-push']
10051001
name: Run mypy for dev
@@ -1063,10 +1059,23 @@ repos:
10631059
^airflow-core/src/airflow/api_fastapi/core_api/datamodels/.*\.py$|
10641060
^airflow-core/src/airflow/api_fastapi/auth/managers/simple/(datamodels|routes|services|openapi)/.*\.py$
10651061
require_serial: true
1066-
## ONLY ADD PREK HOOKS HERE THAT REQUIRE CI IMAGE
10671062
- id: check-contextmanager-class-decorators
10681063
name: Check for problematic context manager class decorators
10691064
entry: ./scripts/ci/prek/check_contextmanager_class_decorators.py
10701065
language: python
10711066
files: .*test.*\.py$
10721067
pass_filenames: true
1068+
# This is a manual hook, run by `breeze ci upgrade` - upgrading all dependencies inside the
1069+
# Breeze CI image - which allows checking all dependencies for all providers.
1070+
# ALWAYS keep it at the end so that it can take into account all the other hook's changes.
1071+
- id: update-uv-lock
1072+
stages: ['manual']
1073+
name: Update uv.lock (manual)
1074+
entry: breeze run uv lock --upgrade
1075+
language: system
1076+
files: >
1077+
(?x)
1078+
(^|/)pyproject\.toml$|
1079+
^uv\.lock$
1080+
pass_filenames: false
1081+
require_serial: true

Dockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,7 @@ COPY --from=scripts common.sh install_packaging_tools.sh install_additional_depe
17491749
ARG AIRFLOW_PIP_VERSION=26.0.1
17501750
# ARG AIRFLOW_PIP_VERSION="git+https://github.com/pypa/pip.git@main"
17511751
ARG AIRFLOW_UV_VERSION=0.10.10
1752-
ARG AIRFLOW_PREK_VERSION="0.3.5"
1752+
ARG AIRFLOW_PREK_VERSION="0.3.6"
17531753

17541754
# UV_LINK_MODE=copy is needed since we are using cache mounted from the host
17551755
ENV AIRFLOW_PIP_VERSION=${AIRFLOW_PIP_VERSION} \

contributing-docs/07_local_virtualenv.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ in editable mode.
246246
The dependencies for providers are configured in ``providers/PROVIDER/pyproject.toml`` files -
247247
separately for each provider. You can find there two types of ``dependencies`` - production runtime
248248
dependencies, and sometimes ``development dependencies`` (in ``dev`` dependency group) which are needed
249-
to run tests and are installed automatically when you install environment with ``uv-sync``.
249+
to run tests and are installed automatically when you install environment with ``uv sync``.
250250

251251
If you want to add another dependency to a provider, you should add it to corresponding ``pyproject.toml``,
252252
add the files to your commit with ``git add`` and run ``prek`` to update generated dependencies.

contributing-docs/testing/unit_tests.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ or run the ``--force-lowest-dependencies`` switch directly from the breeze comma
12591259
breeze shell --force-lowest-dependencies --test-type "Core"
12601260
12611261
1262-
The way it works: after you enter the breeze container, you run ``uv-sync`` in the airflow-core
1262+
The way it works: after you enter the breeze container, you run ``uv sync`` in the airflow-core
12631263
folder to downgrade the dependencies to the lowest version that is compatible
12641264
with the dependencies specified in airflow-core dependencies. You will see it in the output of the breeze
12651265
command as a sequence of downgrades like this:

dev/breeze/doc/ci/02_images.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ can be used for CI images:
444444
| `ADDITIONAL_DEV_APT_ENV` | | Additional env variables defined when installing dev deps |
445445
| `AIRFLOW_PIP_VERSION` | `26.0.1` | `pip` version used. |
446446
| `AIRFLOW_UV_VERSION` | `0.10.10` | `uv` version used. |
447-
| `AIRFLOW_PREK_VERSION` | `0.3.5` | `prek` version used. |
447+
| `AIRFLOW_PREK_VERSION` | `0.3.6` | `prek` version used. |
448448
| `AIRFLOW_USE_UV` | `true` | Whether to use UV for installation. |
449449
| `PIP_PROGRESS_BAR` | `on` | Progress bar for PIP installation |
450450

dev/breeze/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ dependencies = [
5757
"jinja2>=3.1.5",
5858
"jsonschema>=4.19.1",
5959
"packaging>=25.0",
60-
"prek>=0.3.5",
60+
"prek>=0.3.6",
6161
"psutil>=5.9.6",
6262
"pygithub>=2.1.1",
6363
"pytest-xdist>=3.3.1",

dev/breeze/src/airflow_breeze/commands/ci_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ def upgrade(
794794
),
795795
(
796796
"update-uv-lock",
797-
"prek --all-files --show-diff-on-failure --color always --verbose --stage manual update-uv-lock",
797+
"prek --all-files --show-diff-on-failure --color always --verbose update-uv-lock --stage manual",
798798
),
799799
]
800800
step_enabled = {

dev/breeze/src/airflow_breeze/commands/release_management_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class VersionedFile(NamedTuple):
264264
AIRFLOW_USE_UV = False
265265
GITPYTHON_VERSION = "3.1.46"
266266
RICH_VERSION = "14.3.3"
267-
PREK_VERSION = "0.3.5"
267+
PREK_VERSION = "0.3.6"
268268
HATCH_VERSION = "1.16.5"
269269
PYYAML_VERSION = "6.0.3"
270270

dev/breeze/src/airflow_breeze/utils/selective_checks.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
SelectiveCoreTestType,
5858
SelectiveProvidersTestType,
5959
SelectiveTaskSdkTestType,
60+
SelectiveTestType,
6061
all_helm_test_packages,
6162
all_selective_core_test_types,
6263
providers_test_type,
@@ -145,7 +146,7 @@ class AllProvidersSentinel:
145146

146147
ALL_PROVIDERS_SENTINEL = AllProvidersSentinel()
147148

148-
T = TypeVar("T", FileGroupForCi, SelectiveCoreTestType)
149+
T = TypeVar("T", FileGroupForCi, SelectiveTestType)
149150

150151

151152
class HashableDict(dict[T, list[str]]):
@@ -351,7 +352,7 @@ def __hash__(self):
351352
r"^providers/tests/standard/operators/test_python.py",
352353
]
353354

354-
TEST_TYPE_MATCHES: HashableDict[SelectiveCoreTestType] = HashableDict(
355+
TEST_TYPE_MATCHES: HashableDict[SelectiveTestType] = HashableDict(
355356
{
356357
SelectiveCoreTestType.API: [
357358
r"^airflow-core/src/airflow/api/",
@@ -423,7 +424,7 @@ def _exclude_files_with_regexps(files: tuple[str, ...], matched_files, exclude_r
423424

424425
@clearable_cache
425426
def _matching_files(
426-
files: tuple[str, ...], match_group: FileGroupForCi, match_dict: HashableDict
427+
files: tuple[str, ...], match_group: FileGroupForCi | SelectiveTestType, match_dict: HashableDict
427428
) -> list[str]:
428429
matched_files: list[str] = []
429430
match_regexps = match_dict[match_group]
@@ -819,7 +820,9 @@ def kubernetes_combos(self) -> list[str]:
819820
def kubernetes_combos_list_as_string(self) -> str:
820821
return " ".join(self.kubernetes_combos)
821822

822-
def _matching_files(self, match_group: FileGroupForCi, match_dict: HashableDict) -> list[str]:
823+
def _matching_files(
824+
self, match_group: FileGroupForCi | SelectiveTestType, match_dict: HashableDict
825+
) -> list[str]:
823826
return _matching_files(self._files, match_group, match_dict)
824827

825828
def _should_be_run(self, source_area: FileGroupForCi) -> bool:
@@ -1027,9 +1030,7 @@ def prod_image_build(self) -> bool:
10271030
or self.run_ui_e2e_tests
10281031
)
10291032

1030-
def _select_test_type_if_matching(
1031-
self, test_types: set[str], test_type: SelectiveCoreTestType
1032-
) -> list[str]:
1033+
def _select_test_type_if_matching(self, test_types: set[str], test_type: SelectiveTestType) -> list[str]:
10331034
matched_files = self._matching_files(test_type, TEST_TYPE_MATCHES)
10341035
count = len(matched_files)
10351036
if count > 0:
@@ -1308,7 +1309,7 @@ def pyproject_toml_changed(self) -> bool:
13081309
try:
13091310
import tomllib
13101311
except ImportError:
1311-
import tomli as tomllib
1312+
import tomli as tomllib # type: ignore[no-redef]
13121313

13131314
self._new_toml = tomllib.loads(new_result.stdout)
13141315
self._old_toml = tomllib.loads(old_result.stdout)
@@ -1382,6 +1383,7 @@ def docs_list_as_string(self) -> str | None:
13821383
def skip_prek_hooks(self) -> str:
13831384
prek_hooks_to_skip = set()
13841385
prek_hooks_to_skip.add("identity")
1386+
prek_hooks_to_skip.add("update-uv-lock")
13851387
if self._default_branch != "main":
13861388
# Skip those tests on all "release" branches
13871389
prek_hooks_to_skip.update(
@@ -1480,7 +1482,7 @@ def selected_providers_list_as_string(self) -> str | None:
14801482
return " ".join(sorted(p for p in affected_providers if p not in suspended))
14811483

14821484
def get_job_label(self, event_type: str, branch: str):
1483-
import requests
1485+
import requests # type: ignore[import-untyped]
14841486

14851487
job_name = "Basic tests"
14861488
workflow_name = "ci-amd-arm.yml"
@@ -1728,7 +1730,7 @@ def provider_dependency_bump(self) -> bool:
17281730
try:
17291731
import tomllib
17301732
except ImportError:
1731-
import tomli as tomllib
1733+
import tomli as tomllib # type: ignore[no-redef]
17321734

17331735
violations = []
17341736
for pyproject_file in pyproject_files:

0 commit comments

Comments
 (0)