Skip to content
Open
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
10 changes: 5 additions & 5 deletions scripts/ci/prek/common_prek_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def run_command(*args, **kwargs) -> None:


def read_airflow_version() -> str:
ast_obj = ast.parse((AIRFLOW_CORE_SOURCES_PATH / "airflow" / "__init__.py").read_text())
ast_obj = ast.parse((AIRFLOW_CORE_SOURCES_PATH / "airflow" / "__init__.py").read_text(encoding="utf-8"))
for node in ast_obj.body:
if isinstance(node, ast.Assign):
if node.targets[0].id == "__version__": # type: ignore[attr-defined]
Expand All @@ -139,7 +139,7 @@ def _read_global_constants_assignment(name: str) -> Any:
(``NAME: type = ...``). The value must be a literal so it can be safely
evaluated with ``ast.literal_eval``.
"""
tree = ast.parse(GLOBAL_CONSTANTS_PATH.read_text())
tree = ast.parse(GLOBAL_CONSTANTS_PATH.read_text(encoding="utf-8"))
for node in tree.body:
if isinstance(node, ast.Assign):
for target in node.targets:
Expand Down Expand Up @@ -226,7 +226,7 @@ def insert_documentation(
extra_information: str | None = None,
) -> bool:
found = False
old_content = file_path.read_text()
old_content = file_path.read_text(encoding="utf-8")
lines = old_content.splitlines(keepends=True)
replacing = False
result: list[str] = []
Expand Down Expand Up @@ -274,7 +274,7 @@ def read_uv_required_min_version() -> tuple[str, tuple[int, ...]]:
Parses ``[tool.uv] required-version = ">=X.Y.Z"`` and returns ``(raw, tuple)``.
We parse by regex to avoid pulling a TOML dep into every prek script.
"""
pyproject = (AIRFLOW_ROOT_PATH / "pyproject.toml").read_text()
pyproject = (AIRFLOW_ROOT_PATH / "pyproject.toml").read_text(encoding="utf-8")
# Narrow to the [tool.uv] section so we don't match a different required-version.
match = re.search(r"^\[tool\.uv\]\s*$(?P<body>.*?)(?=^\[|\Z)", pyproject, re.MULTILINE | re.DOTALL)
if not match:
Expand Down Expand Up @@ -789,7 +789,7 @@ def inner():
When only_top_level = False then returns
['os', 'collections.defaultdict', 'numpy', 'pandas.DataFrame', 'json', 'pathlib.Path', 'pathlib.PurePath']
"""
root = ast.parse(file_path.read_text(), file_path.name)
root = ast.parse(file_path.read_text(encoding="utf-8"), file_path.name)
imports: list[str] = []

nodes = ast.iter_child_nodes(root) if only_top_level else ast.walk(root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def _reset_backend_after_fork() -> None:
_backend = None


os.register_at_fork(after_in_child=_reset_backend_after_fork)
if hasattr(os, "register_at_fork"):
os.register_at_fork(after_in_child=_reset_backend_after_fork)


def normalize_name_for_stats(name: str, log_warning: bool = True) -> str:
Expand Down
4 changes: 4 additions & 0 deletions task-sdk/tests/task_sdk/execution_time/test_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@

from airflow.sdk.definitions.context import Context

pytestmark = pytest.mark.skipif(
sys.platform == "win32", reason="Supervisor uses POSIX-only process primitives"
)

log = logging.getLogger(__name__)
TI_ID = uuid7()

Expand Down
5 changes: 5 additions & 0 deletions task-sdk/tests/task_sdk/execution_time/test_task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import functools
import json
import os
import sys
import textwrap
import time
from collections.abc import Iterable
Expand Down Expand Up @@ -192,6 +193,10 @@
from kgb import SpyAgency
import time_machine

pytestmark = pytest.mark.skipif(
sys.platform == "win32", reason="Task runner uses POSIX-only process primitives"
)


def get_inline_dag(dag_id: str, task: BaseOperator) -> DAG:
"""Creates an inline dag and returns it based on dag_id and task."""
Expand Down