Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ repos:
stages: ['manual']
name: Run mypy for dev (manual)
language: python
entry: ./scripts/ci/prek/mypy_folder.py dev
entry: ./scripts/ci/prek/mypy_folder.py dev scripts
pass_filenames: false
files: ^.*\.py$
require_serial: true
Expand Down
5 changes: 4 additions & 1 deletion scripts/ci/prek/check_secrets_search_path_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import ast
import sys
from pathlib import Path
from types import EllipsisType

AIRFLOW_ROOT = Path(__file__).parents[3].resolve()
CORE_SECRETS_FILE = AIRFLOW_ROOT / "airflow-core" / "src" / "airflow" / "secrets" / "base_secrets.py"
Expand All @@ -29,7 +30,9 @@
)


def extract_from_file(file_path: Path, constant_name: str) -> list[str] | None:
def extract_from_file(
file_path: Path, constant_name: str
) -> list[str | bytes | int | float | complex | EllipsisType | None] | None:
"""Extract a list constant value from a Python file using AST parsing."""
try:
with open(file_path) as f:
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/prek/check_shared_distributions_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def get_all_shared_modules(shared_dir: Path) -> list[str]:
Get all shared module names from the shared/ directory.
Returns list of package names like 'apache-airflow-shared-configuration'.
"""
shared_modules = []
shared_modules: list[str] = []
if not shared_dir.exists():
return shared_modules

Expand Down Expand Up @@ -495,7 +495,7 @@ def ensure_shared_in_workspace_and_dev(main_pyproject_path: Path, shared_dir: Pa
Also ensures they are sorted alphabetically.
Returns list of errors if any.
"""
errors = []
errors: list[str] = []
shared_modules = get_all_shared_modules(shared_dir)

if not shared_modules:
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/prek/mypy_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"airflow-core",
*[f"providers/{provider_id.replace('.', '/')}" for provider_id in get_all_provider_ids()],
"dev",
"scripts",
"devel-common",
"task-sdk",
"airflow-ctl",
Expand Down
9 changes: 6 additions & 3 deletions scripts/ci/prek/upgrade_important_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def get_latest_image_version(image: str) -> str:

# DockerHub API endpoint for tags
url = f"https://registry.hub.docker.com/v2/repositories/{namespace}/{repository}/tags"
params = {"page_size": 100, "ordering": "last_updated"}
params: dict[str, int | str] = {"page_size": 100, "ordering": "last_updated"}

headers = {"User-Agent": "Python requests"}
response = requests.get(url, headers=headers, params=params)
Expand Down Expand Up @@ -480,7 +480,7 @@ def apply_pattern_replacements(


# Configuration for packages that follow simple version constant patterns
SIMPLE_VERSION_PATTERNS = {
SIMPLE_VERSION_PATTERNS: dict[str, list[tuple[str, str]]] = {
"hatch": [
(r"(HATCH_VERSION = )(\"[0-9.abrc]+\")", 'HATCH_VERSION = "{version}"'),
(r"(HATCH_VERSION=)(\"[0-9.abrc]+\")", 'HATCH_VERSION="{version}"'),
Expand Down Expand Up @@ -609,13 +609,16 @@ def update_file_with_versions(
new_content, latest_python_version, AIRFLOW_IMAGE_PYTHON_PATTERNS, keep_length
)

return _apply_simple_regexp_replacements(new_content, versions)


def _apply_simple_regexp_replacements(new_content: str, versions: dict[str, str]) -> str:
# Apply simple regex replacements
for package_name, patterns in SIMPLE_VERSION_PATTERNS.items():
should_upgrade = globals().get(f"UPGRADE_{package_name.upper()}", False)
version = versions.get(package_name, "")
if should_upgrade and version:
new_content = apply_simple_regex_replacements(new_content, version, patterns)

return new_content


Expand Down