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 dev/airflow_perf/scheduler_dag_execution_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def create_dag_runs(dag, num_runs, session):
"""
Create `num_runs` of dag runs for sub-sequent schedules
"""
from airflow.utils import timezone
from airflow.sdk import timezone
from airflow.utils.state import DagRunState

try:
Expand Down
2 changes: 1 addition & 1 deletion devel-common/src/tests_common/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3211,7 +3211,7 @@ def _import_timezone():
try:
from airflow._shared.timezones import timezone
except ImportError:
from airflow.utils import timezone
from airflow.utils import timezone # noqa: TID251
return timezone


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@
from airflow.dag_processing.dagbag import DagBag
from airflow.models import DagRun
from airflow.models.serialized_dag import SerializedDagModel
from airflow.sdk import timezone
from airflow.serialization.definitions.dag import SerializedDAG
from airflow.utils.session import create_session
from airflow.utils.state import State

from tests_common.test_utils.dag import create_scheduler_dag
from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS, AIRFLOW_V_3_1_PLUS

try:
from airflow.sdk import timezone
except ImportError:
from airflow.utils import timezone # type: ignore[no-redef,attr-defined]

log = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion devel-common/src/tests_common/test_utils/version_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
XCOM_RETURN_KEY = BaseXCom.XCOM_RETURN_KEY
else:
from airflow.sensors.base import PokeReturnValue # type: ignore[no-redef]
from airflow.utils import timezone # type: ignore[attr-defined,no-redef]
from airflow.utils import timezone # type: ignore[attr-defined,no-redef] # noqa: TID251
from airflow.utils.decorators import remove_task_decorator # type: ignore[no-redef]
from airflow.utils.types import NOTSET, ArgNotSet # type: ignore[attr-defined,no-redef]
from airflow.utils.xcom import XCOM_RETURN_KEY # type: ignore[no-redef]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from airflow.providers.cncf.kubernetes.hooks.kubernetes import KubernetesHook
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from airflow.providers.cncf.kubernetes.utils.pod_manager import OnFinishAction, PodManager
from airflow.sdk import timezone
from airflow.sdk.definitions.context import Context
from airflow.utils import timezone # type: ignore[attr-defined]
from airflow.utils.types import DagRunType
from airflow.version import version as airflow_version
from kubernetes_tests.test_base import BaseK8STest, StringContainingId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from datetime import datetime, timedelta
from shutil import copyfile

import airflow
from airflow.sdk import timezone

log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
Expand Down Expand Up @@ -80,9 +80,7 @@ def add_perf_start_date_env_to_conf(performance_dag_conf: dict[str, str]) -> Non
if "PERF_START_DATE" not in performance_dag_conf:
start_ago = get_performance_dag_environment_variable(performance_dag_conf, "PERF_START_AGO")

perf_start_date = airflow.utils.timezone.utcnow - check_and_parse_time_delta(
"PERF_START_AGO", start_ago
)
perf_start_date = timezone.utcnow() - check_and_parse_time_delta("PERF_START_AGO", start_ago)

performance_dag_conf["PERF_START_DATE"] = str(perf_start_date)

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,7 @@ banned-module-level-imports = ["numpy", "pandas", "polars"]

# Note: we have to specify these all here (not in sub pyproject.toml files), else we'd have to duplicate these
# all rules in each project https://github.com/astral-sh/ruff/issues/18723
# Add this once providers are sorted
# "airflow.utils.timezone".msg = "Use airflow.sdk.timezone (or airflow._shared.timezones.timezone from within airflow-core)"
"airflow.utils.timezone".msg = "Use airflow.sdk.timezone (or airflow._shared.timezones.timezone from within airflow-core)"
# "airflow_shared".msg = "Use airflow._shared or airflow.sdk._shared instead"

# Deprecated in Python 3.11, Pending Removal in Python 3.15: https://github.com/python/cpython/issues/90817
Expand Down
Loading