diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 12bb1270066d5..adcd46f6244ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1189,7 +1189,13 @@ repos: files: \.py$ exclude: | (?x) + ^airflow/configuration.py$ | + ^airflow/metrics/validators.py$ | + ^airflow/models/dag.py$ | + ^airflow/serialization/serde.py$ | + ^airflow/utils/file.py$ | ^airflow/utils/helpers.py$ | + ^airflow/utils/log/secrets_masker.py$ | ^providers/src/airflow/providers/ | ^(providers/)?tests/ | task_sdk/src/airflow/sdk/definitions/dag.py$ | diff --git a/airflow/api/common/mark_tasks.py b/airflow/api/common/mark_tasks.py index 65cda6723d178..7c55c3527d154 100644 --- a/airflow/api/common/mark_tasks.py +++ b/airflow/api/common/mark_tasks.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Collection, Iterable +from collections.abc import Collection, Iterable +from typing import TYPE_CHECKING from sqlalchemy import and_, or_, select from sqlalchemy.orm import lazyload diff --git a/airflow/api_connexion/endpoints/dag_endpoint.py b/airflow/api_connexion/endpoints/dag_endpoint.py index 352bf9cfd4c11..bb5d419691592 100644 --- a/airflow/api_connexion/endpoints/dag_endpoint.py +++ b/airflow/api_connexion/endpoints/dag_endpoint.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Collection from http import HTTPStatus -from typing import TYPE_CHECKING, Collection +from typing import TYPE_CHECKING from connexion import NoContent from flask import g, request diff --git a/airflow/api_connexion/endpoints/dag_parsing.py b/airflow/api_connexion/endpoints/dag_parsing.py index 8c48888629b2b..da0cd7a7e8776 100644 --- a/airflow/api_connexion/endpoints/dag_parsing.py +++ b/airflow/api_connexion/endpoints/dag_parsing.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from http import HTTPStatus -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from flask import Response, current_app from itsdangerous import BadSignature, URLSafeSerializer diff --git a/airflow/api_connexion/endpoints/dag_run_endpoint.py b/airflow/api_connexion/endpoints/dag_run_endpoint.py index 00dd8ca907193..316ab2b8a7de7 100644 --- a/airflow/api_connexion/endpoints/dag_run_endpoint.py +++ b/airflow/api_connexion/endpoints/dag_run_endpoint.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Collection from http import HTTPStatus -from typing import TYPE_CHECKING, Collection +from typing import TYPE_CHECKING import pendulum from connexion import NoContent diff --git a/airflow/api_connexion/endpoints/dag_source_endpoint.py b/airflow/api_connexion/endpoints/dag_source_endpoint.py index e53ffe89c73ea..1c6e34fc2b1a7 100644 --- a/airflow/api_connexion/endpoints/dag_source_endpoint.py +++ b/airflow/api_connexion/endpoints/dag_source_endpoint.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from http import HTTPStatus -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from flask import Response, request from sqlalchemy import select diff --git a/airflow/api_connexion/endpoints/import_error_endpoint.py b/airflow/api_connexion/endpoints/import_error_endpoint.py index 633dd0bebde52..76fad6cb92d4e 100644 --- a/airflow/api_connexion/endpoints/import_error_endpoint.py +++ b/airflow/api_connexion/endpoints/import_error_endpoint.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from sqlalchemy import func, select diff --git a/airflow/api_connexion/endpoints/pool_endpoint.py b/airflow/api_connexion/endpoints/pool_endpoint.py index a6ccd3a4aa9b9..3babe3370e3d3 100644 --- a/airflow/api_connexion/endpoints/pool_endpoint.py +++ b/airflow/api_connexion/endpoints/pool_endpoint.py @@ -119,8 +119,8 @@ def patch_pool( update_mask = [i.strip() for i in update_mask] _patch_body = {} try: - # MyPy infers a List[Optional[str]] type here but it should be a List[str] - # there is no way field is None here (UpdateMask is a List[str]) + # MyPy infers a list[Optional[str]] type here but it should be a list[str] + # there is no way field is None here (UpdateMask is a list[str]) # so if pool_schema.declared_fields[field].attribute is None file is returned update_mask = [ ( diff --git a/airflow/api_connexion/endpoints/request_dict.py b/airflow/api_connexion/endpoints/request_dict.py index b07e06c0b63f8..f0e78a41bd041 100644 --- a/airflow/api_connexion/endpoints/request_dict.py +++ b/airflow/api_connexion/endpoints/request_dict.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import Any, Mapping, cast +from collections.abc import Mapping +from typing import Any, cast def get_json_request_dict() -> Mapping[str, Any]: diff --git a/airflow/api_connexion/endpoints/task_instance_endpoint.py b/airflow/api_connexion/endpoints/task_instance_endpoint.py index 95c824656ff27..3256f6998b080 100644 --- a/airflow/api_connexion/endpoints/task_instance_endpoint.py +++ b/airflow/api_connexion/endpoints/task_instance_endpoint.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Iterable, Sequence, TypeVar +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING, Any, TypeVar from flask import g from marshmallow import ValidationError diff --git a/airflow/api_connexion/endpoints/update_mask.py b/airflow/api_connexion/endpoints/update_mask.py index 38fd255f51b3a..d6ff005d8aea5 100644 --- a/airflow/api_connexion/endpoints/update_mask.py +++ b/airflow/api_connexion/endpoints/update_mask.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import Any, Mapping, Sequence +from collections.abc import Mapping, Sequence +from typing import Any from airflow.api_connexion.exceptions import BadRequest diff --git a/airflow/api_connexion/parameters.py b/airflow/api_connexion/parameters.py index a05ded37614d4..c6d10b8a29e81 100644 --- a/airflow/api_connexion/parameters.py +++ b/airflow/api_connexion/parameters.py @@ -17,8 +17,9 @@ from __future__ import annotations import logging +from collections.abc import Container from functools import wraps -from typing import TYPE_CHECKING, Any, Callable, Container, TypeVar, cast +from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast from pendulum.parsing import ParserError from sqlalchemy import text diff --git a/airflow/api_connexion/types.py b/airflow/api_connexion/types.py index 3a6f89d9bb52a..f17f2a0d2712b 100644 --- a/airflow/api_connexion/types.py +++ b/airflow/api_connexion/types.py @@ -16,13 +16,14 @@ # under the License. from __future__ import annotations -from typing import Any, Mapping, Optional, Sequence, Tuple, Union +from collections.abc import Mapping, Sequence +from typing import Any, Optional, Union from flask import Response APIResponse = Union[ Response, - Tuple[object, int], # For '(NoContent, 201)'. + tuple[object, int], # For '(NoContent, 201)'. Mapping[str, Any], # JSON. ] diff --git a/airflow/api_fastapi/common/db/common.py b/airflow/api_fastapi/common/db/common.py index 2d7da4bff7376..1621ee6f9bab2 100644 --- a/airflow/api_fastapi/common/db/common.py +++ b/airflow/api_fastapi/common/db/common.py @@ -22,7 +22,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Literal, Sequence, overload +from collections.abc import Sequence +from typing import TYPE_CHECKING, Literal, overload from sqlalchemy.ext.asyncio import AsyncSession diff --git a/airflow/api_fastapi/common/headers.py b/airflow/api_fastapi/common/headers.py index 7e0bd5aae3d29..7d1a0fa69613b 100644 --- a/airflow/api_fastapi/common/headers.py +++ b/airflow/api_fastapi/common/headers.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from typing import Annotated + from fastapi import Depends, Header, HTTPException, status -from typing_extensions import Annotated from airflow.api_fastapi.common.types import Mimetype diff --git a/airflow/api_fastapi/common/parameters.py b/airflow/api_fastapi/common/parameters.py index 7554ee88450bb..17e59c3e197a5 100644 --- a/airflow/api_fastapi/common/parameters.py +++ b/airflow/api_fastapi/common/parameters.py @@ -18,6 +18,7 @@ from __future__ import annotations from abc import ABC, abstractmethod +from collections.abc import Iterable from datetime import datetime from typing import ( TYPE_CHECKING, @@ -25,8 +26,6 @@ Any, Callable, Generic, - Iterable, - List, Optional, TypeVar, Union, @@ -288,7 +287,7 @@ def inner(order_by: str = default or self.get_primary_key_string()) -> SortParam return inner -class _TagsFilter(BaseParam[List[str]]): +class _TagsFilter(BaseParam[list[str]]): """Filter on tags.""" def to_orm(self, select: Select) -> Select: @@ -305,7 +304,7 @@ def depends(self, tags: list[str] = Query(default_factory=list)) -> _TagsFilter: return self.set_value(tags) -class _OwnersFilter(BaseParam[List[str]]): +class _OwnersFilter(BaseParam[list[str]]): """Filter on owners.""" def to_orm(self, select: Select) -> Select: @@ -322,7 +321,7 @@ def depends(self, owners: list[str] = Query(default_factory=list)) -> _OwnersFil return self.set_value(owners) -class DagRunStateFilter(BaseParam[List[Optional[DagRunState]]]): +class DagRunStateFilter(BaseParam[list[Optional[DagRunState]]]): """Filter on Dag Run state.""" def to_orm(self, select: Select) -> Select: @@ -352,7 +351,7 @@ def depends(self, state: list[str] = Query(default_factory=list)) -> DagRunState return self.set_value(states) -class TIStateFilter(BaseParam[List[Optional[TaskInstanceState]]]): +class TIStateFilter(BaseParam[list[Optional[TaskInstanceState]]]): """Filter on task instance state.""" def to_orm(self, select: Select) -> Select: @@ -376,7 +375,7 @@ def depends(self, state: list[str] = Query(default_factory=list)) -> TIStateFilt return self.set_value(states) -class TIPoolFilter(BaseParam[List[str]]): +class TIPoolFilter(BaseParam[list[str]]): """Filter on task instance pool.""" def to_orm(self, select: Select) -> Select: @@ -393,7 +392,7 @@ def depends(self, pool: list[str] = Query(default_factory=list)) -> TIPoolFilter return self.set_value(pool) -class TIQueueFilter(BaseParam[List[str]]): +class TIQueueFilter(BaseParam[list[str]]): """Filter on task instance queue.""" def to_orm(self, select: Select) -> Select: @@ -410,7 +409,7 @@ def depends(self, queue: list[str] = Query(default_factory=list)) -> TIQueueFilt return self.set_value(queue) -class TIExecutorFilter(BaseParam[List[str]]): +class TIExecutorFilter(BaseParam[list[str]]): """Filter on task instance executor.""" def to_orm(self, select: Select) -> Select: diff --git a/airflow/api_fastapi/common/router.py b/airflow/api_fastapi/common/router.py index 5bf07e0fe834a..aeb1fb22452b5 100644 --- a/airflow/api_fastapi/common/router.py +++ b/airflow/api_fastapi/common/router.py @@ -17,8 +17,9 @@ from __future__ import annotations +from collections.abc import Sequence from enum import Enum -from typing import Any, Callable, Sequence +from typing import Any, Callable from fastapi import APIRouter, params from fastapi.datastructures import Default diff --git a/airflow/api_fastapi/core_api/datamodels/dags.py b/airflow/api_fastapi/core_api/datamodels/dags.py index fc7bdcebe242b..f1dd7bd798044 100644 --- a/airflow/api_fastapi/core_api/datamodels/dags.py +++ b/airflow/api_fastapi/core_api/datamodels/dags.py @@ -18,8 +18,9 @@ from __future__ import annotations from collections import abc +from collections.abc import Iterable from datetime import datetime, timedelta -from typing import Any, Iterable +from typing import Any from itsdangerous import URLSafeSerializer from pendulum.tz.timezone import FixedTimezone, Timezone diff --git a/airflow/api_fastapi/core_api/routes/public/xcom.py b/airflow/api_fastapi/core_api/routes/public/xcom.py index dff2933940c62..3a8e6130e452c 100644 --- a/airflow/api_fastapi/core_api/routes/public/xcom.py +++ b/airflow/api_fastapi/core_api/routes/public/xcom.py @@ -17,11 +17,11 @@ from __future__ import annotations import copy +from typing import Annotated from fastapi import Depends, HTTPException, Query, status from sqlalchemy import and_, select from sqlalchemy.orm import Session -from typing_extensions import Annotated from airflow.api_fastapi.common.db.common import get_session from airflow.api_fastapi.common.router import AirflowRouter diff --git a/airflow/api_fastapi/core_api/security.py b/airflow/api_fastapi/core_api/security.py index ede628e04aa70..30470e9b5da55 100644 --- a/airflow/api_fastapi/core_api/security.py +++ b/airflow/api_fastapi/core_api/security.py @@ -17,12 +17,11 @@ from __future__ import annotations from functools import cache -from typing import Any, Callable +from typing import Annotated, Any, Callable from fastapi import Depends, HTTPException from fastapi.security import OAuth2PasswordBearer from jwt import InvalidTokenError -from typing_extensions import Annotated from airflow.api_fastapi.app import get_auth_manager from airflow.auth.managers.base_auth_manager import ResourceMethod diff --git a/airflow/auth/managers/base_auth_manager.py b/airflow/auth/managers/base_auth_manager.py index 028d4dadb1326..ea0c921c98c00 100644 --- a/airflow/auth/managers/base_auth_manager.py +++ b/airflow/auth/managers/base_auth_manager.py @@ -18,8 +18,9 @@ from __future__ import annotations from abc import abstractmethod +from collections.abc import Container, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Container, Generic, Literal, Sequence, TypeVar +from typing import TYPE_CHECKING, Any, Generic, Literal, TypeVar from flask_appbuilder.menu import MenuItem from sqlalchemy import select diff --git a/airflow/cli/cli_config.py b/airflow/cli/cli_config.py index 00dd68041cbd2..780cf20b95671 100644 --- a/airflow/cli/cli_config.py +++ b/airflow/cli/cli_config.py @@ -24,7 +24,8 @@ import json import os import textwrap -from typing import Callable, Iterable, NamedTuple, Union +from collections.abc import Iterable +from typing import Callable, NamedTuple, Union import lazy_object_proxy diff --git a/airflow/cli/cli_parser.py b/airflow/cli/cli_parser.py index 9380692687b3c..a48e6b438d390 100644 --- a/airflow/cli/cli_parser.py +++ b/airflow/cli/cli_parser.py @@ -29,8 +29,9 @@ import sys from argparse import Action from collections import Counter -from functools import lru_cache -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from functools import cache +from typing import TYPE_CHECKING import lazy_object_proxy from rich_argparse import RawTextRichHelpFormatter, RichHelpFormatter @@ -138,7 +139,7 @@ def add_argument(self, action: Action) -> None: return super().add_argument(action) -@lru_cache(maxsize=None) +@cache def get_parser(dag_parser: bool = False) -> argparse.ArgumentParser: """Create and returns command line argument parser.""" parser = DefaultHelpParser(prog="airflow", formatter_class=AirflowHelpFormatter) diff --git a/airflow/cli/commands/cheat_sheet_command.py b/airflow/cli/commands/cheat_sheet_command.py index 9b8b78718bbc5..f8889d139e15d 100644 --- a/airflow/cli/commands/cheat_sheet_command.py +++ b/airflow/cli/commands/cheat_sheet_command.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING from airflow.cli.cli_parser import GroupCommand, airflow_commands from airflow.cli.simple_table import AirflowConsole, SimpleTable diff --git a/airflow/cli/commands/task_command.py b/airflow/cli/commands/task_command.py index 2b5a6c18a8089..55c1662d35d24 100644 --- a/airflow/cli/commands/task_command.py +++ b/airflow/cli/commands/task_command.py @@ -26,8 +26,9 @@ import os import sys import textwrap +from collections.abc import Generator from contextlib import contextmanager, redirect_stderr, redirect_stdout, suppress -from typing import TYPE_CHECKING, Generator, Protocol, Union, cast +from typing import TYPE_CHECKING, Protocol, Union, cast import pendulum from pendulum.parsing.exceptions import ParserError diff --git a/airflow/cli/commands/triggerer_command.py b/airflow/cli/commands/triggerer_command.py index eba4328e7e702..7b935e160ca5e 100644 --- a/airflow/cli/commands/triggerer_command.py +++ b/airflow/cli/commands/triggerer_command.py @@ -18,10 +18,10 @@ from __future__ import annotations +from collections.abc import Generator from contextlib import contextmanager from functools import partial from multiprocessing import Process -from typing import Generator from airflow import settings from airflow.cli.commands.daemon_utils import run_command_with_daemon_option diff --git a/airflow/cli/simple_table.py b/airflow/cli/simple_table.py index 72750fbdc4415..b8e4c6a7a41a0 100644 --- a/airflow/cli/simple_table.py +++ b/airflow/cli/simple_table.py @@ -18,7 +18,8 @@ import inspect import json -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from rich.box import ASCII_DOUBLE_HEAD from rich.console import Console diff --git a/airflow/cli/utils.py b/airflow/cli/utils.py index eb37b502d4346..d132deeb373a9 100644 --- a/airflow/cli/utils.py +++ b/airflow/cli/utils.py @@ -19,7 +19,8 @@ import io import sys -from typing import TYPE_CHECKING, Collection +from collections.abc import Collection +from typing import TYPE_CHECKING if TYPE_CHECKING: from io import IOBase diff --git a/airflow/configuration.py b/airflow/configuration.py index 521af6cbe320d..c2f8455125065 100644 --- a/airflow/configuration.py +++ b/airflow/configuration.py @@ -31,12 +31,14 @@ import sys import warnings from base64 import b64encode +from collections.abc import Generator, Iterable from configparser import ConfigParser, NoOptionError, NoSectionError from contextlib import contextmanager from copy import deepcopy from io import StringIO from json.decoder import JSONDecodeError -from typing import IO, TYPE_CHECKING, Any, Dict, Generator, Iterable, Pattern, Set, Tuple, Union +from re import Pattern +from typing import IO, TYPE_CHECKING, Any, Union from urllib.parse import urlsplit import re2 @@ -65,9 +67,9 @@ _SQLITE3_VERSION_PATTERN = re2.compile(r"(?P^\d+(?:\.\d+)*)\D?.*$") ConfigType = Union[str, int, float, bool] -ConfigOptionsDictType = Dict[str, ConfigType] -ConfigSectionSourcesType = Dict[str, Union[str, Tuple[str, str]]] -ConfigSourcesType = Dict[str, ConfigSectionSourcesType] +ConfigOptionsDictType = dict[str, ConfigType] +ConfigSectionSourcesType = dict[str, Union[str, tuple[str, str]]] +ConfigSourcesType = dict[str, ConfigSectionSourcesType] ENV_VAR_PREFIX = "AIRFLOW__" @@ -300,7 +302,7 @@ def get_default_pre_2_7_value(self, section: str, key: str, **kwargs) -> Any: # These configs can also be fetched from Secrets backend # following the "{section}__{name}__secret" pattern @functools.cached_property - def sensitive_config_values(self) -> Set[tuple[str, str]]: # noqa: UP006 + def sensitive_config_values(self) -> set[tuple[str, str]]: if self.configuration_description is None: return ( _get_empty_set_for_configuration() diff --git a/airflow/dag_processing/manager.py b/airflow/dag_processing/manager.py index 3056a7fc1f4db..bf0c41cf3b68b 100644 --- a/airflow/dag_processing/manager.py +++ b/airflow/dag_processing/manager.py @@ -31,10 +31,11 @@ import time import zipfile from collections import defaultdict, deque +from collections.abc import Iterator from datetime import datetime, timedelta from importlib import import_module from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Iterator, NamedTuple, cast +from typing import TYPE_CHECKING, Any, Callable, NamedTuple, cast from setproctitle import setproctitle from sqlalchemy import delete, select, update diff --git a/airflow/dag_processing/processor.py b/airflow/dag_processing/processor.py index 219c7aa9776af..c44da8c857083 100644 --- a/airflow/dag_processing/processor.py +++ b/airflow/dag_processing/processor.py @@ -23,9 +23,10 @@ import threading import time import zipfile +from collections.abc import Generator, Iterable from contextlib import contextmanager, redirect_stderr, redirect_stdout, suppress from dataclasses import dataclass -from typing import TYPE_CHECKING, Generator, Iterable +from typing import TYPE_CHECKING from setproctitle import setproctitle from sqlalchemy import delete, event, select @@ -189,9 +190,11 @@ def _handle_dag_file_processing(): # The following line ensures that stdout goes to the same destination as the logs. If stdout # gets sent to logs and logs are sent to stdout, this leads to an infinite loop. This # necessitates this conditional based on the value of DAG_PROCESSOR_LOG_TARGET. - with redirect_stdout(StreamLogWriter(log, logging.INFO)), redirect_stderr( - StreamLogWriter(log, logging.WARNING) - ), Stats.timer() as timer: + with ( + redirect_stdout(StreamLogWriter(log, logging.INFO)), + redirect_stderr(StreamLogWriter(log, logging.WARNING)), + Stats.timer() as timer, + ): _handle_dag_file_processing() log.info("Processing %s took %.3f seconds", file_path, timer.duration) except Exception: diff --git a/airflow/decorators/__init__.pyi b/airflow/decorators/__init__.pyi index 7dd887431c6f5..c483d010d32a7 100644 --- a/airflow/decorators/__init__.pyi +++ b/airflow/decorators/__init__.pyi @@ -20,8 +20,9 @@ # documentation for more details. from __future__ import annotations +from collections.abc import Collection, Container, Iterable, Mapping from datetime import timedelta -from typing import Any, Callable, Collection, Container, Iterable, Mapping, TypeVar, overload +from typing import Any, Callable, TypeVar, overload from docker.types import Mount from kubernetes.client import models as k8s diff --git a/airflow/decorators/base.py b/airflow/decorators/base.py index 4f40c6ad3b478..9a9498d49c307 100644 --- a/airflow/decorators/base.py +++ b/airflow/decorators/base.py @@ -20,17 +20,14 @@ import itertools import textwrap import warnings +from collections.abc import Collection, Iterator, Mapping, Sequence from functools import cached_property, update_wrapper from typing import ( TYPE_CHECKING, Any, Callable, ClassVar, - Collection, Generic, - Iterator, - Mapping, - Sequence, TypeVar, cast, overload, diff --git a/airflow/decorators/bash.py b/airflow/decorators/bash.py index e4dc19745e0ab..ae5b0a9e0c153 100644 --- a/airflow/decorators/bash.py +++ b/airflow/decorators/bash.py @@ -18,7 +18,8 @@ from __future__ import annotations import warnings -from typing import Any, Callable, ClassVar, Collection, Mapping, Sequence +from collections.abc import Collection, Mapping, Sequence +from typing import Any, Callable, ClassVar from airflow.decorators.base import DecoratedOperator, TaskDecorator, task_decorator_factory from airflow.providers.standard.operators.bash import BashOperator diff --git a/airflow/decorators/python.py b/airflow/decorators/python.py index b65a4a9667009..26172f7c45400 100644 --- a/airflow/decorators/python.py +++ b/airflow/decorators/python.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Callable from airflow.decorators.base import DecoratedOperator, task_decorator_factory from airflow.providers.standard.operators.python import PythonOperator diff --git a/airflow/decorators/sensor.py b/airflow/decorators/sensor.py index 5d409c2d599d8..1601f5d308ea8 100644 --- a/airflow/decorators/sensor.py +++ b/airflow/decorators/sensor.py @@ -17,7 +17,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable, ClassVar, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Callable, ClassVar from airflow.decorators.base import get_unique_task_id, task_decorator_factory from airflow.providers.standard.sensors.python import PythonSensor diff --git a/airflow/decorators/task_group.py b/airflow/decorators/task_group.py index daaa81e1ce62a..591ba39018e1d 100644 --- a/airflow/decorators/task_group.py +++ b/airflow/decorators/task_group.py @@ -28,7 +28,8 @@ import functools import inspect import warnings -from typing import TYPE_CHECKING, Any, Callable, ClassVar, Generic, Mapping, Sequence, TypeVar, overload +from collections.abc import Mapping, Sequence +from typing import TYPE_CHECKING, Any, Callable, ClassVar, Generic, TypeVar, overload import attr diff --git a/airflow/example_dags/example_params_ui_tutorial.py b/airflow/example_dags/example_params_ui_tutorial.py index 133df85d07b5c..5d21e6b774d84 100644 --- a/airflow/example_dags/example_params_ui_tutorial.py +++ b/airflow/example_dags/example_params_ui_tutorial.py @@ -31,222 +31,224 @@ from airflow.models.dag import DAG from airflow.models.param import Param, ParamsDict -with DAG( - dag_id=Path(__file__).stem, - dag_display_name="Params UI tutorial", - description=__doc__.partition(".")[0], - doc_md=__doc__, - schedule=None, - start_date=datetime.datetime(2022, 3, 4), - catchup=False, - tags=["example", "params", "ui"], - # [START section_1] - params={ - # Let's start simple: Standard dict values are detected from type and offered as entry form fields. - # Detected types are numbers, text, boolean, lists and dicts. - # Note that such auto-detected parameters are treated as optional (not required to contain a value) - "x": 3, - "text": "Hello World!", - "flag": False, - "a_simple_list": ["one", "two", "three", "actually one value is made per line"], - # But of course you might want to have it nicer! Let's add some description to parameters. - # Note if you can add any Markdown formatting to the description, you need to use the description_md - # attribute. - "most_loved_number": Param( - 42, - type="integer", - title="Your favorite number", - description_md="Everybody should have a **favorite** number. Not only _math teachers_. " - "If you can not think of any at the moment please think of the 42 which is very famous because" - "of the book [The Hitchhiker's Guide to the Galaxy]" - "(https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#" - "The_Answer_to_the_Ultimate_Question_of_Life,_the_Universe,_and_Everything_is_42).", - ), - # If you want to have a selection list box then you can use the enum feature of JSON schema - "pick_one": Param( - "value 42", - type="string", - title="Select one Value", - description="You can use JSON schema enum's to generate drop down selection boxes.", - enum=[f"value {i}" for i in range(16, 64)], - ), - # [END section_1] - # You can also label the selected values via values_display attribute - "pick_with_label": Param( - 3, - type="number", - title="Select one Number", - description="With drop down selections you can also have nice display labels for the values.", - enum=[*range(1, 10)], - values_display={ - 1: "One", - 2: "Two", - 3: "Three", - 4: "Four - is like you take three and get one for free!", - 5: "Five", - 6: "Six", - 7: "Seven", - 8: "Eight", - 9: "Nine", - }, - ), - # If you want to have a list box with proposals but not enforcing a fixed list - # then you can use the examples feature of JSON schema - "proposals": Param( - "some value", - type="string", - title="Field with proposals", - description="You can use JSON schema examples's to generate drop down selection boxes " - "but allow also to enter custom values. Try typing an 'a' and see options.", - examples=( - "Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,Golf,Hotel,India,Juliett,Kilo,Lima,Mike,November,Oscar,Papa," - "Quebec,Romeo,Sierra,Tango,Uniform,Victor,Whiskey,X-ray,Yankee,Zulu" - ).split(","), - ), - # If you want to select multiple items from a fixed list JSON schema does not allow to use enum - # In this case the type "array" is being used together with "examples" as pick list - "multi_select": Param( - ["two", "three"], - "Select from the list of options.", - type="array", - title="Multi Select", - examples=["one", "two", "three", "four", "five"], - ), - # A multiple options selection can also be combined with values_display - "multi_select_with_label": Param( - ["2", "3"], - "Select from the list of options. See that options can have nicer text and still technical values" - "are propagated as values during trigger to the DAG.", - type="array", - title="Multi Select with Labels", - examples=["1", "2", "3", "4", "5"], - values_display={ - "1": "One box of choccolate", - "2": "Two bananas", - "3": "Three apples", - # Note: Value display mapping does not need to be complete - }, - ), - # An array of numbers - "array_of_numbers": Param( - [1, 2, 3], - "Only integers are accepted in this array", - type="array", - title="Array of numbers", - items={"type": "number"}, - ), - # Boolean as proper parameter with description - "bool": Param( - True, - type="boolean", - title="Please confirm", - description="A On/Off selection with a proper description.", - ), - # Dates and Times are also supported - "date_time": Param( - f"{datetime.date.today()}T{datetime.time(hour=12, minute=17, second=00)}+00:00", - type="string", - format="date-time", - title="Date-Time Picker", - description="Please select a date and time, use the button on the left for a pop-up calendar.", - ), - "date": Param( - f"{datetime.date.today()}", - type="string", - format="date", - title="Date Picker", - description="Please select a date, use the button on the left for a pop-up calendar. " - "See that here are no times!", - ), - "time": Param( - f"{datetime.time(hour=12, minute=13, second=14)}", - type=["string", "null"], - format="time", - title="Time Picker", - description="Please select a time, use the button on the left for a pop-up tool.", - ), - "multiline_text": Param( - "A multiline text Param\nthat will keep the newline\ncharacters in its value.", - description="This field allows for multiline text input. The returned value will be a single with newline (\\n) characters kept intact.", - type=["string", "null"], - format="multiline", - ), - # Fields can be required or not. If the defined fields are typed they are getting required by default - # (else they would not pass JSON schema validation) - to make typed fields optional you must - # permit the optional "null" type. - # You can omit a default value if the DAG is triggered manually - # [START section_2] - "required_field": Param( - # In this example we have no default value - # Form will enforce a value supplied by users to be able to trigger - type="string", - title="Required text field", - description="This field is required. You can not submit without having text in here.", - ), - "optional_field": Param( - "optional text, you can trigger also w/o text", - type=["null", "string"], - title="Optional text field", - description_md="This field is optional. As field content is JSON schema validated you must " - "allow the `null` type.", - ), - # [END section_2] - # You can arrange the entry fields in sections so that you can have a better overview for the user - # Therefore you can add the "section" attribute. - # The benefit of the Params class definition is that the full scope of JSON schema validation - # can be leveraged for form fields and they will be validated before DAG submission. - "checked_text": Param( - "length-checked-field", - type="string", - title="Text field with length check", - description_md="""This field is required. And you need to provide something between 10 and 30 +with ( + DAG( + dag_id=Path(__file__).stem, + dag_display_name="Params UI tutorial", + description=__doc__.partition(".")[0], + doc_md=__doc__, + schedule=None, + start_date=datetime.datetime(2022, 3, 4), + catchup=False, + tags=["example", "params", "ui"], + # [START section_1] + params={ + # Let's start simple: Standard dict values are detected from type and offered as entry form fields. + # Detected types are numbers, text, boolean, lists and dicts. + # Note that such auto-detected parameters are treated as optional (not required to contain a value) + "x": 3, + "text": "Hello World!", + "flag": False, + "a_simple_list": ["one", "two", "three", "actually one value is made per line"], + # But of course you might want to have it nicer! Let's add some description to parameters. + # Note if you can add any Markdown formatting to the description, you need to use the description_md + # attribute. + "most_loved_number": Param( + 42, + type="integer", + title="Your favorite number", + description_md="Everybody should have a **favorite** number. Not only _math teachers_. " + "If you can not think of any at the moment please think of the 42 which is very famous because" + "of the book [The Hitchhiker's Guide to the Galaxy]" + "(https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#" + "The_Answer_to_the_Ultimate_Question_of_Life,_the_Universe,_and_Everything_is_42).", + ), + # If you want to have a selection list box then you can use the enum feature of JSON schema + "pick_one": Param( + "value 42", + type="string", + title="Select one Value", + description="You can use JSON schema enum's to generate drop down selection boxes.", + enum=[f"value {i}" for i in range(16, 64)], + ), + # [END section_1] + # You can also label the selected values via values_display attribute + "pick_with_label": Param( + 3, + type="number", + title="Select one Number", + description="With drop down selections you can also have nice display labels for the values.", + enum=[*range(1, 10)], + values_display={ + 1: "One", + 2: "Two", + 3: "Three", + 4: "Four - is like you take three and get one for free!", + 5: "Five", + 6: "Six", + 7: "Seven", + 8: "Eight", + 9: "Nine", + }, + ), + # If you want to have a list box with proposals but not enforcing a fixed list + # then you can use the examples feature of JSON schema + "proposals": Param( + "some value", + type="string", + title="Field with proposals", + description="You can use JSON schema examples's to generate drop down selection boxes " + "but allow also to enter custom values. Try typing an 'a' and see options.", + examples=( + "Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,Golf,Hotel,India,Juliett,Kilo,Lima,Mike,November,Oscar,Papa," + "Quebec,Romeo,Sierra,Tango,Uniform,Victor,Whiskey,X-ray,Yankee,Zulu" + ).split(","), + ), + # If you want to select multiple items from a fixed list JSON schema does not allow to use enum + # In this case the type "array" is being used together with "examples" as pick list + "multi_select": Param( + ["two", "three"], + "Select from the list of options.", + type="array", + title="Multi Select", + examples=["one", "two", "three", "four", "five"], + ), + # A multiple options selection can also be combined with values_display + "multi_select_with_label": Param( + ["2", "3"], + "Select from the list of options. See that options can have nicer text and still technical values" + "are propagated as values during trigger to the DAG.", + type="array", + title="Multi Select with Labels", + examples=["1", "2", "3", "4", "5"], + values_display={ + "1": "One box of choccolate", + "2": "Two bananas", + "3": "Three apples", + # Note: Value display mapping does not need to be complete + }, + ), + # An array of numbers + "array_of_numbers": Param( + [1, 2, 3], + "Only integers are accepted in this array", + type="array", + title="Array of numbers", + items={"type": "number"}, + ), + # Boolean as proper parameter with description + "bool": Param( + True, + type="boolean", + title="Please confirm", + description="A On/Off selection with a proper description.", + ), + # Dates and Times are also supported + "date_time": Param( + f"{datetime.date.today()}T{datetime.time(hour=12, minute=17, second=00)}+00:00", + type="string", + format="date-time", + title="Date-Time Picker", + description="Please select a date and time, use the button on the left for a pop-up calendar.", + ), + "date": Param( + f"{datetime.date.today()}", + type="string", + format="date", + title="Date Picker", + description="Please select a date, use the button on the left for a pop-up calendar. " + "See that here are no times!", + ), + "time": Param( + f"{datetime.time(hour=12, minute=13, second=14)}", + type=["string", "null"], + format="time", + title="Time Picker", + description="Please select a time, use the button on the left for a pop-up tool.", + ), + "multiline_text": Param( + "A multiline text Param\nthat will keep the newline\ncharacters in its value.", + description="This field allows for multiline text input. The returned value will be a single with newline (\\n) characters kept intact.", + type=["string", "null"], + format="multiline", + ), + # Fields can be required or not. If the defined fields are typed they are getting required by default + # (else they would not pass JSON schema validation) - to make typed fields optional you must + # permit the optional "null" type. + # You can omit a default value if the DAG is triggered manually + # [START section_2] + "required_field": Param( + # In this example we have no default value + # Form will enforce a value supplied by users to be able to trigger + type="string", + title="Required text field", + description="This field is required. You can not submit without having text in here.", + ), + "optional_field": Param( + "optional text, you can trigger also w/o text", + type=["null", "string"], + title="Optional text field", + description_md="This field is optional. As field content is JSON schema validated you must " + "allow the `null` type.", + ), + # [END section_2] + # You can arrange the entry fields in sections so that you can have a better overview for the user + # Therefore you can add the "section" attribute. + # The benefit of the Params class definition is that the full scope of JSON schema validation + # can be leveraged for form fields and they will be validated before DAG submission. + "checked_text": Param( + "length-checked-field", + type="string", + title="Text field with length check", + description_md="""This field is required. And you need to provide something between 10 and 30 characters. See the JSON [schema description (string)](https://json-schema.org/understanding-json-schema/reference/string.html) for more details""", - minLength=10, - maxLength=20, - section="JSON Schema validation options", - ), - "checked_number": Param( - 100, - type="number", - title="Number field with value check", - description_md="""This field is required. You need to provide any number between 64 and 128. + minLength=10, + maxLength=20, + section="JSON Schema validation options", + ), + "checked_number": Param( + 100, + type="number", + title="Number field with value check", + description_md="""This field is required. You need to provide any number between 64 and 128. See the JSON [schema description (numbers)](https://json-schema.org/understanding-json-schema/reference/numeric.html) for more details""", - minimum=64, - maximum=128, - section="JSON Schema validation options", - ), - # Some further cool stuff as advanced options are also possible - # You can have the user entering a dict object as a JSON with validation - "object": Param( - {"key": "value"}, - type=["object", "null"], - title="JSON entry field", - section="Special advanced stuff with form fields", - ), - "array_of_objects": Param( - [{"name": "account_name", "country": "country_name"}], - description_md="Array with complex objects and validation rules. " - "See [JSON Schema validation options in specs]" - "(https://json-schema.org/understanding-json-schema/reference/array.html#items).", - type="array", - title="JSON array field", - items={ - "type": "object", - "properties": {"name": {"type": "string"}, "country_name": {"type": "string"}}, - "required": ["name"], - }, - section="Special advanced stuff with form fields", - ), - # If you want to have static parameters which are always passed and not editable by the user - # then you can use the JSON schema option of passing constant values. These parameters - # will not be displayed but passed to the DAG - "hidden_secret_field": Param("constant value", const="constant value"), - }, -) as dag: + minimum=64, + maximum=128, + section="JSON Schema validation options", + ), + # Some further cool stuff as advanced options are also possible + # You can have the user entering a dict object as a JSON with validation + "object": Param( + {"key": "value"}, + type=["object", "null"], + title="JSON entry field", + section="Special advanced stuff with form fields", + ), + "array_of_objects": Param( + [{"name": "account_name", "country": "country_name"}], + description_md="Array with complex objects and validation rules. " + "See [JSON Schema validation options in specs]" + "(https://json-schema.org/understanding-json-schema/reference/array.html#items).", + type="array", + title="JSON array field", + items={ + "type": "object", + "properties": {"name": {"type": "string"}, "country_name": {"type": "string"}}, + "required": ["name"], + }, + section="Special advanced stuff with form fields", + ), + # If you want to have static parameters which are always passed and not editable by the user + # then you can use the JSON schema option of passing constant values. These parameters + # will not be displayed but passed to the DAG + "hidden_secret_field": Param("constant value", const="constant value"), + }, + ) as dag +): # [START section_3] @task(task_display_name="Show used parameters") def show_params(**kwargs) -> None: diff --git a/airflow/executors/base_executor.py b/airflow/executors/base_executor.py index d24fd4f151691..3e406e3d74d10 100644 --- a/airflow/executors/base_executor.py +++ b/airflow/executors/base_executor.py @@ -21,8 +21,9 @@ import logging import sys from collections import defaultdict, deque +from collections.abc import Sequence from dataclasses import dataclass, field -from typing import TYPE_CHECKING, Any, List, Optional, Sequence, Tuple +from typing import TYPE_CHECKING, Any, Optional import pendulum from deprecated import deprecated @@ -55,20 +56,20 @@ # Command to execute - list of strings # the first element is always "airflow". # It should be result of TaskInstance.generate_command method. - CommandType = List[str] + CommandType = list[str] # Task that is queued. It contains all the information that is # needed to run the task. # # Tuple of: command, priority, queue name, TaskInstance - QueuedTaskInstanceType = Tuple[CommandType, int, Optional[str], TaskInstance] + QueuedTaskInstanceType = tuple[CommandType, int, Optional[str], TaskInstance] # Event_buffer dict value type # Tuple of: state, info - EventBufferValueType = Tuple[Optional[str], Any] + EventBufferValueType = tuple[Optional[str], Any] # Task tuple to send to be executed - TaskTuple = Tuple[TaskInstanceKey, CommandType, Optional[str], Optional[Any]] + TaskTuple = tuple[TaskInstanceKey, CommandType, Optional[str], Optional[Any]] log = logging.getLogger(__name__) diff --git a/airflow/executors/executor_loader.py b/airflow/executors/executor_loader.py index 7fc0bd63e9802..06697c645dc13 100644 --- a/airflow/executors/executor_loader.py +++ b/airflow/executors/executor_loader.py @@ -298,7 +298,7 @@ def import_default_executor_cls(cls, validate: bool = True) -> tuple[type[BaseEx return executor, source @classmethod - @functools.lru_cache(maxsize=None) + @functools.cache def validate_database_executor_compatibility(cls, executor: type[BaseExecutor]) -> None: """ Validate database and executor compatibility. diff --git a/airflow/executors/local_executor.py b/airflow/executors/local_executor.py index 3b8b52176db5b..02e201f7b5bfb 100644 --- a/airflow/executors/local_executor.py +++ b/airflow/executors/local_executor.py @@ -32,7 +32,7 @@ import os import subprocess from multiprocessing import Queue, SimpleQueue -from typing import TYPE_CHECKING, Any, Optional, Tuple +from typing import TYPE_CHECKING, Any, Optional from setproctitle import setproctitle @@ -49,8 +49,8 @@ # This is a work to be executed by a worker. # It can Key and Command - but it can also be None, None which is actually a # "Poison Pill" - worker seeing Poison Pill should take the pill and ... die instantly. - ExecutorWorkType = Optional[Tuple[TaskInstanceKey, CommandType]] - TaskInstanceStateType = Tuple[TaskInstanceKey, TaskInstanceState, Optional[Exception]] + ExecutorWorkType = Optional[tuple[TaskInstanceKey, CommandType]] + TaskInstanceStateType = tuple[TaskInstanceKey, TaskInstanceState, Optional[Exception]] def _run_worker( diff --git a/airflow/io/__init__.py b/airflow/io/__init__.py index 49f2711c3c6cd..3229b83101616 100644 --- a/airflow/io/__init__.py +++ b/airflow/io/__init__.py @@ -18,11 +18,11 @@ import inspect import logging +from collections.abc import Mapping from functools import cache from typing import ( TYPE_CHECKING, Callable, - Mapping, ) from fsspec.implementations.local import LocalFileSystem diff --git a/airflow/io/path.py b/airflow/io/path.py index 3526050d12883..5a68789f8ebac 100644 --- a/airflow/io/path.py +++ b/airflow/io/path.py @@ -20,7 +20,8 @@ import os import shutil import typing -from typing import Any, Mapping +from collections.abc import Mapping +from typing import Any from urllib.parse import urlsplit from fsspec.utils import stringify_path diff --git a/airflow/io/typedef.py b/airflow/io/typedef.py index 3fd92564fc1c3..f1a3f8e1ce5f0 100644 --- a/airflow/io/typedef.py +++ b/airflow/io/typedef.py @@ -16,6 +16,4 @@ # under the License. from __future__ import annotations -from typing import Dict - -Properties = Dict[str, str] +Properties = dict[str, str] diff --git a/airflow/jobs/scheduler_job_runner.py b/airflow/jobs/scheduler_job_runner.py index 96a09eb99bb28..bc23a365b410f 100644 --- a/airflow/jobs/scheduler_job_runner.py +++ b/airflow/jobs/scheduler_job_runner.py @@ -25,12 +25,13 @@ import sys import time from collections import Counter, defaultdict, deque +from collections.abc import Collection, Iterable, Iterator from contextlib import suppress from datetime import timedelta from functools import lru_cache, partial from itertools import groupby from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Collection, Iterable, Iterator +from typing import TYPE_CHECKING, Any, Callable from deprecated import deprecated from sqlalchemy import and_, delete, exists, func, not_, select, text, update @@ -1073,9 +1074,10 @@ def _run_scheduler_loop(self) -> None: ) for loop_count in itertools.count(start=1): - with Trace.start_span( - span_name="scheduler_job_loop", component="SchedulerJobRunner" - ) as span, Stats.timer("scheduler.scheduler_loop_duration") as timer: + with ( + Trace.start_span(span_name="scheduler_job_loop", component="SchedulerJobRunner") as span, + Stats.timer("scheduler.scheduler_loop_duration") as timer, + ): span.set_attributes( { "category": "scheduler", diff --git a/airflow/metrics/otel_logger.py b/airflow/metrics/otel_logger.py index c3633212cd278..d8eeedeada764 100644 --- a/airflow/metrics/otel_logger.py +++ b/airflow/metrics/otel_logger.py @@ -20,8 +20,9 @@ import logging import random import warnings +from collections.abc import Iterable from functools import partial -from typing import TYPE_CHECKING, Callable, Iterable, Union +from typing import TYPE_CHECKING, Callable, Union from opentelemetry import metrics from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter diff --git a/airflow/metrics/validators.py b/airflow/metrics/validators.py index b47cdac1be551..a570721ffe2b4 100644 --- a/airflow/metrics/validators.py +++ b/airflow/metrics/validators.py @@ -23,8 +23,10 @@ import logging import string import warnings +from collections.abc import Iterable from functools import partial, wraps -from typing import Callable, Iterable, Pattern, cast +from re import Pattern +from typing import Callable, cast import re2 diff --git a/airflow/models/abstractoperator.py b/airflow/models/abstractoperator.py index d8a000352f40b..aa23bf33e131a 100644 --- a/airflow/models/abstractoperator.py +++ b/airflow/models/abstractoperator.py @@ -19,8 +19,9 @@ import datetime import inspect +from collections.abc import Iterable, Iterator, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, Sequence +from typing import TYPE_CHECKING, Any, Callable import methodtools from sqlalchemy import select diff --git a/airflow/models/asset.py b/airflow/models/asset.py index 126bc5dc2d3fb..d47986a85e560 100644 --- a/airflow/models/asset.py +++ b/airflow/models/asset.py @@ -42,7 +42,7 @@ from airflow.utils.sqlalchemy import UtcDateTime if TYPE_CHECKING: - from typing import Sequence + from collections.abc import Sequence from sqlalchemy.orm import Session diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py index 169fd548afe08..13eb787b4f86b 100644 --- a/airflow/models/baseoperator.py +++ b/airflow/models/baseoperator.py @@ -28,6 +28,7 @@ import copy import functools import logging +from collections.abc import Collection, Iterable, Sequence from datetime import datetime, timedelta from functools import wraps from threading import local @@ -36,10 +37,7 @@ TYPE_CHECKING, Any, Callable, - Collection, - Iterable, NoReturn, - Sequence, TypeVar, ) diff --git a/airflow/models/dag.py b/airflow/models/dag.py index 8177025c2d8ed..dfde57d9d3154 100644 --- a/airflow/models/dag.py +++ b/airflow/models/dag.py @@ -25,18 +25,15 @@ import sys import time from collections import defaultdict +from collections.abc import Collection, Container, Iterable, Sequence from contextlib import ExitStack from datetime import datetime, timedelta from functools import cache +from re import Pattern from typing import ( TYPE_CHECKING, Any, Callable, - Collection, - Container, - Iterable, - Pattern, - Sequence, Union, cast, overload, diff --git a/airflow/models/dagrun.py b/airflow/models/dagrun.py index b535d8729ea7b..e7fa37c82f93a 100644 --- a/airflow/models/dagrun.py +++ b/airflow/models/dagrun.py @@ -20,7 +20,8 @@ import itertools import os from collections import defaultdict -from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, NamedTuple, Sequence, TypeVar, overload +from collections.abc import Iterable, Iterator, Sequence +from typing import TYPE_CHECKING, Any, Callable, NamedTuple, TypeVar, overload import re2 from sqlalchemy import ( @@ -875,8 +876,9 @@ def recalculate(self) -> _UnfinishedStates: start_dttm = timezone.utcnow() self.last_scheduling_decision = start_dttm - with Stats.timer(f"dagrun.dependency-check.{self.dag_id}"), Stats.timer( - "dagrun.dependency-check", tags=self.stats_tags + with ( + Stats.timer(f"dagrun.dependency-check.{self.dag_id}"), + Stats.timer("dagrun.dependency-check", tags=self.stats_tags), ): dag = self.get_dag() info = self.task_instance_scheduling_decisions(session) diff --git a/airflow/models/expandinput.py b/airflow/models/expandinput.py index 7feb7f76a602e..8d86ec193eb4d 100644 --- a/airflow/models/expandinput.py +++ b/airflow/models/expandinput.py @@ -20,8 +20,8 @@ import collections.abc import functools import operator -from collections.abc import Sized -from typing import TYPE_CHECKING, Any, Dict, Iterable, Mapping, NamedTuple, Sequence, Union +from collections.abc import Iterable, Mapping, Sequence, Sized +from typing import TYPE_CHECKING, Any, NamedTuple, Union import attr @@ -41,7 +41,7 @@ # Each keyword argument to expand() can be an XComArg, sequence, or dict (not # any mapping since we need the value to be ordered). -OperatorExpandArgument = Union["MappedArgument", "XComArg", Sequence, Dict[str, Any]] +OperatorExpandArgument = Union["MappedArgument", "XComArg", Sequence, dict[str, Any]] # The single argument of expand_kwargs() can be an XComArg, or a list with each # element being either an XComArg or a dict. diff --git a/airflow/models/mappedoperator.py b/airflow/models/mappedoperator.py index 9a5c1b563ce4d..524415b848f62 100644 --- a/airflow/models/mappedoperator.py +++ b/airflow/models/mappedoperator.py @@ -21,7 +21,8 @@ import contextlib import copy import warnings -from typing import TYPE_CHECKING, Any, ClassVar, Collection, Iterable, Iterator, Mapping, Sequence, Union +from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence +from typing import TYPE_CHECKING, Any, ClassVar, Union import attr import methodtools @@ -61,7 +62,6 @@ if TYPE_CHECKING: import datetime - from typing import List import jinja2 # Slow import. import pendulum @@ -87,7 +87,7 @@ from airflow.utils.task_group import TaskGroup from airflow.utils.trigger_rule import TriggerRule - TaskStateChangeCallbackAttrType = Union[None, TaskStateChangeCallback, List[TaskStateChangeCallback]] + TaskStateChangeCallbackAttrType = Union[None, TaskStateChangeCallback, list[TaskStateChangeCallback]] ValidationSource = Union[Literal["expand"], Literal["partial"]] diff --git a/airflow/models/param.py b/airflow/models/param.py index 55b4ad0f2b6b4..e6150ee50cba5 100644 --- a/airflow/models/param.py +++ b/airflow/models/param.py @@ -20,7 +20,8 @@ import copy import json import logging -from typing import TYPE_CHECKING, Any, ClassVar, ItemsView, Iterable, MutableMapping, ValuesView +from collections.abc import ItemsView, Iterable, MutableMapping, ValuesView +from typing import TYPE_CHECKING, Any, ClassVar from airflow.exceptions import AirflowException, ParamValidationError from airflow.utils.mixins import ResolveMixin diff --git a/airflow/models/skipmixin.py b/airflow/models/skipmixin.py index a67c7cf310ba4..87cd4b2d931e7 100644 --- a/airflow/models/skipmixin.py +++ b/airflow/models/skipmixin.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Iterable, Sequence from types import GeneratorType -from typing import TYPE_CHECKING, Iterable, Sequence +from typing import TYPE_CHECKING from sqlalchemy import update diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py index a176e0282b603..6c8798bdec5fb 100644 --- a/airflow/models/taskinstance.py +++ b/airflow/models/taskinstance.py @@ -27,11 +27,12 @@ import os import signal from collections import defaultdict +from collections.abc import Collection, Generator, Iterable, Mapping from contextlib import nullcontext from datetime import timedelta from enum import Enum from functools import cache -from typing import TYPE_CHECKING, Any, Callable, Collection, Generator, Iterable, Mapping, Tuple +from typing import TYPE_CHECKING, Any, Callable from urllib.parse import quote import dill @@ -2891,8 +2892,9 @@ def signal_handler(signum, frame): if not self.next_method: self.clear_xcom_data() - with Stats.timer(f"dag.{self.task.dag_id}.{self.task.task_id}.duration"), Stats.timer( - "task.duration", tags=self.stats_tags + with ( + Stats.timer(f"dag.{self.task.dag_id}.{self.task.task_id}.duration"), + Stats.timer("task.duration", tags=self.stats_tags), ): # Set the validated/merged params on the task object. self.task.params = context["params"] @@ -3742,7 +3744,7 @@ def _is_further_mapped_inside(operator: Operator, container: TaskGroup) -> bool: # State of the task instance. # Stores string version of the task state. -TaskInstanceStateType = Tuple[TaskInstanceKey, TaskInstanceState] +TaskInstanceStateType = tuple[TaskInstanceKey, TaskInstanceState] class SimpleTaskInstance: diff --git a/airflow/models/taskmap.py b/airflow/models/taskmap.py index 061f3b22d4805..478f09e0f1148 100644 --- a/airflow/models/taskmap.py +++ b/airflow/models/taskmap.py @@ -21,7 +21,8 @@ import collections.abc import enum -from typing import TYPE_CHECKING, Any, Collection +from collections.abc import Collection +from typing import TYPE_CHECKING, Any from sqlalchemy import CheckConstraint, Column, ForeignKeyConstraint, Integer, String diff --git a/airflow/models/trigger.py b/airflow/models/trigger.py index 27868daf083f6..8b1e7ec2e180b 100644 --- a/airflow/models/trigger.py +++ b/airflow/models/trigger.py @@ -17,8 +17,9 @@ from __future__ import annotations import datetime +from collections.abc import Iterable from traceback import format_exception -from typing import TYPE_CHECKING, Any, Iterable +from typing import TYPE_CHECKING, Any from sqlalchemy import Column, Integer, String, Text, delete, func, or_, select, update from sqlalchemy.orm import relationship, selectinload diff --git a/airflow/models/xcom.py b/airflow/models/xcom.py index 5b6f83f4d59b2..098d2d64db5f9 100644 --- a/airflow/models/xcom.py +++ b/airflow/models/xcom.py @@ -20,7 +20,8 @@ import inspect import json import logging -from typing import TYPE_CHECKING, Any, Iterable, cast +from collections.abc import Iterable +from typing import TYPE_CHECKING, Any, cast from sqlalchemy import ( JSON, diff --git a/airflow/models/xcom_arg.py b/airflow/models/xcom_arg.py index bd8f4555b50c8..df643d22b2167 100644 --- a/airflow/models/xcom_arg.py +++ b/airflow/models/xcom_arg.py @@ -20,7 +20,8 @@ import contextlib import inspect import itertools -from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, Mapping, Sequence, Union, overload +from collections.abc import Iterable, Iterator, Mapping, Sequence +from typing import TYPE_CHECKING, Any, Callable, Union, overload from sqlalchemy import func, or_, select diff --git a/airflow/notifications/basenotifier.py b/airflow/notifications/basenotifier.py index 11d7ee17fe939..eaac6d11df36d 100644 --- a/airflow/notifications/basenotifier.py +++ b/airflow/notifications/basenotifier.py @@ -18,7 +18,8 @@ from __future__ import annotations from abc import abstractmethod -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.template.templater import Templater from airflow.utils.context import context_merge diff --git a/airflow/operators/branch.py b/airflow/operators/branch.py index 0085bfa5af108..088aea23fd338 100644 --- a/airflow/operators/branch.py +++ b/airflow/operators/branch.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING from airflow.models.baseoperator import BaseOperator from airflow.models.skipmixin import SkipMixin diff --git a/airflow/operators/email.py b/airflow/operators/email.py index 98af60afe4afc..e2ae26739c10f 100644 --- a/airflow/operators/email.py +++ b/airflow/operators/email.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.models.baseoperator import BaseOperator from airflow.utils.email import send_email diff --git a/airflow/operators/latest_only.py b/airflow/operators/latest_only.py index 6f2c0288d90d6..ae15ee017b046 100644 --- a/airflow/operators/latest_only.py +++ b/airflow/operators/latest_only.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING import pendulum diff --git a/airflow/plugins_manager.py b/airflow/plugins_manager.py index 881e07a81ed67..3e34f29cc1070 100644 --- a/airflow/plugins_manager.py +++ b/airflow/plugins_manager.py @@ -27,8 +27,9 @@ import os import sys import types +from collections.abc import Iterable from pathlib import Path -from typing import TYPE_CHECKING, Any, Iterable +from typing import TYPE_CHECKING, Any from airflow import settings from airflow.configuration import conf @@ -47,8 +48,8 @@ import importlib_metadata as metadata except ImportError: from importlib import metadata # type: ignore[no-redef] + from collections.abc import Generator from types import ModuleType - from typing import Generator from airflow.listeners.listener import ListenerManager from airflow.timetables.base import Timetable diff --git a/airflow/providers_manager.py b/airflow/providers_manager.py index 5d38454b18917..8d9f93734d7eb 100644 --- a/airflow/providers_manager.py +++ b/airflow/providers_manager.py @@ -27,11 +27,12 @@ import os import traceback import warnings +from collections.abc import MutableMapping from dataclasses import dataclass from functools import wraps from importlib.resources import files as resource_files from time import perf_counter -from typing import TYPE_CHECKING, Any, Callable, MutableMapping, NamedTuple, TypeVar +from typing import TYPE_CHECKING, Any, Callable, NamedTuple, TypeVar from packaging.utils import canonicalize_name diff --git a/airflow/sensors/base.py b/airflow/sensors/base.py index 3e5a8565e50c0..f117b97d0ce5a 100644 --- a/airflow/sensors/base.py +++ b/airflow/sensors/base.py @@ -22,8 +22,9 @@ import hashlib import time import traceback +from collections.abc import Iterable from datetime import timedelta -from typing import TYPE_CHECKING, Any, Callable, Iterable +from typing import TYPE_CHECKING, Any, Callable from sqlalchemy import select @@ -56,7 +57,7 @@ _MYSQL_TIMESTAMP_MAX = datetime.datetime(2038, 1, 19, 3, 14, 7, tzinfo=timezone.utc) -@functools.lru_cache(maxsize=None) +@functools.cache def _is_metadatabase_mysql() -> bool: if InternalApiConfig.get_use_internal_api(): return False diff --git a/airflow/sensors/external_task.py b/airflow/sensors/external_task.py index d5504ab2e9fb9..0b5793f06ced7 100644 --- a/airflow/sensors/external_task.py +++ b/airflow/sensors/external_task.py @@ -20,7 +20,8 @@ import datetime import os import warnings -from typing import TYPE_CHECKING, Any, Callable, ClassVar, Collection, Iterable +from collections.abc import Collection, Iterable +from typing import TYPE_CHECKING, Any, Callable, ClassVar from airflow.configuration import conf from airflow.exceptions import AirflowException, AirflowSkipException diff --git a/airflow/serialization/json_schema.py b/airflow/serialization/json_schema.py index 32f3b9e0d108c..c4412a49ffcfc 100644 --- a/airflow/serialization/json_schema.py +++ b/airflow/serialization/json_schema.py @@ -20,7 +20,8 @@ from __future__ import annotations import pkgutil -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.settings import json diff --git a/airflow/serialization/pydantic/asset.py b/airflow/serialization/pydantic/asset.py index 611730dd92e47..0e5623099ea49 100644 --- a/airflow/serialization/pydantic/asset.py +++ b/airflow/serialization/pydantic/asset.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. from datetime import datetime -from typing import List, Optional +from typing import Optional from pydantic import BaseModel as BaseModelPydantic, ConfigDict @@ -52,8 +52,8 @@ class AssetPydantic(BaseModelPydantic): created_at: datetime updated_at: datetime - consuming_dags: List[DagScheduleAssetReferencePydantic] - producing_tasks: List[TaskOutletAssetReferencePydantic] + consuming_dags: list[DagScheduleAssetReferencePydantic] + producing_tasks: list[TaskOutletAssetReferencePydantic] model_config = ConfigDict(from_attributes=True) diff --git a/airflow/serialization/pydantic/dag.py b/airflow/serialization/pydantic/dag.py index f222808c3d0bc..5a1199887f99f 100644 --- a/airflow/serialization/pydantic/dag.py +++ b/airflow/serialization/pydantic/dag.py @@ -18,7 +18,7 @@ import pathlib from datetime import datetime -from typing import Annotated, Any, List, Optional +from typing import Annotated, Any, Optional from pydantic import ( BaseModel as BaseModelPydantic, @@ -87,8 +87,8 @@ class DagModelPydantic(BaseModelPydantic): default_view: Optional[str] timetable_summary: Optional[str] timetable_description: Optional[str] - tags: List[DagTagPydantic] # noqa: UP006 - dag_owner_links: List[DagOwnerAttributesPydantic] # noqa: UP006 + tags: list[DagTagPydantic] + dag_owner_links: list[DagOwnerAttributesPydantic] max_active_tasks: int max_active_runs: Optional[int] diff --git a/airflow/serialization/pydantic/dag_run.py b/airflow/serialization/pydantic/dag_run.py index c06f098766584..e9409e3a8ac19 100644 --- a/airflow/serialization/pydantic/dag_run.py +++ b/airflow/serialization/pydantic/dag_run.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Iterable from datetime import datetime -from typing import TYPE_CHECKING, Iterable, List, Optional +from typing import TYPE_CHECKING, Optional from uuid import UUID from pydantic import BaseModel as BaseModelPydantic, ConfigDict @@ -56,7 +57,7 @@ class DagRunPydantic(BaseModelPydantic): dag_version_id: Optional[UUID] updated_at: Optional[datetime] dag: Optional[PydanticDag] - consumed_asset_events: List[AssetEventPydantic] # noqa: UP006 + consumed_asset_events: list[AssetEventPydantic] log_template_id: Optional[int] triggered_by: Optional[DagRunTriggeredByType] diff --git a/airflow/serialization/pydantic/taskinstance.py b/airflow/serialization/pydantic/taskinstance.py index 685334426d8bc..87d6f48f111b8 100644 --- a/airflow/serialization/pydantic/taskinstance.py +++ b/airflow/serialization/pydantic/taskinstance.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Iterable from datetime import datetime -from typing import TYPE_CHECKING, Annotated, Any, Iterable, Optional +from typing import TYPE_CHECKING, Annotated, Any, Optional from uuid import UUID from pydantic import ( diff --git a/airflow/serialization/pydantic/trigger.py b/airflow/serialization/pydantic/trigger.py index 19a8f6b70c007..010da6b9ffe48 100644 --- a/airflow/serialization/pydantic/trigger.py +++ b/airflow/serialization/pydantic/trigger.py @@ -16,7 +16,7 @@ # under the License. import datetime -from typing import Any, Dict, Optional +from typing import Any, Optional from pydantic import BaseModel as BaseModelPydantic, ConfigDict @@ -49,14 +49,14 @@ def __init__(self, **kwargs) -> None: super().__init__(**kwargs) @property - def kwargs(self) -> Dict[str, Any]: + def kwargs(self) -> dict[str, Any]: """Return the decrypted kwargs of the trigger.""" from airflow.models import Trigger return Trigger._decrypt_kwargs(self.encrypted_kwargs) @kwargs.setter - def kwargs(self, kwargs: Dict[str, Any]) -> None: + def kwargs(self, kwargs: dict[str, Any]) -> None: """Set the encrypted kwargs of the trigger.""" from airflow.models import Trigger diff --git a/airflow/serialization/serde.py b/airflow/serialization/serde.py index ec779c631c994..7d1b583ce9a65 100644 --- a/airflow/serialization/serde.py +++ b/airflow/serialization/serde.py @@ -24,7 +24,8 @@ import sys from fnmatch import fnmatch from importlib import import_module -from typing import TYPE_CHECKING, Any, Pattern, TypeVar, Union, cast +from re import Pattern +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast import attr import re2 @@ -301,14 +302,14 @@ def _match(classname: str) -> bool: return _match_glob(classname) or _match_regexp(classname) -@functools.lru_cache(maxsize=None) +@functools.cache def _match_glob(classname: str): """Check if the given classname matches a pattern from allowed_deserialization_classes using glob syntax.""" patterns = _get_patterns() return any(fnmatch(classname, p.pattern) for p in patterns) -@functools.lru_cache(maxsize=None) +@functools.cache def _match_regexp(classname: str): """Check if the given classname matches a pattern from allowed_deserialization_classes_regexp using regexp.""" patterns = _get_regexp_patterns() @@ -393,12 +394,12 @@ def _register(): log.debug("loading serializers took %.3f seconds", timer.duration) -@functools.lru_cache(maxsize=None) +@functools.cache def _get_patterns() -> list[Pattern]: return [re2.compile(p) for p in conf.get("core", "allowed_deserialization_classes").split()] -@functools.lru_cache(maxsize=None) +@functools.cache def _get_regexp_patterns() -> list[Pattern]: return [re2.compile(p) for p in conf.get("core", "allowed_deserialization_classes_regexp").split()] diff --git a/airflow/serialization/serialized_objects.py b/airflow/serialization/serialized_objects.py index 21fa575676a57..e51836036814d 100644 --- a/airflow/serialization/serialized_objects.py +++ b/airflow/serialization/serialized_objects.py @@ -24,10 +24,11 @@ import itertools import logging import weakref +from collections.abc import Collection, Iterable, Mapping from functools import cache from inspect import signature from textwrap import dedent -from typing import TYPE_CHECKING, Any, Collection, Iterable, Mapping, NamedTuple, Union, cast +from typing import TYPE_CHECKING, Any, NamedTuple, Union, cast import attrs import lazy_object_proxy diff --git a/airflow/settings.py b/airflow/settings.py index 76b3e948964f3..d4d6346f3f131 100644 --- a/airflow/settings.py +++ b/airflow/settings.py @@ -134,7 +134,7 @@ } -@functools.lru_cache(maxsize=None) +@functools.cache def _get_rich_console(file): # Delay imports until we need it import rich.console diff --git a/airflow/template/templater.py b/airflow/template/templater.py index ff0a4e51c1958..e81c0877c23d5 100644 --- a/airflow/template/templater.py +++ b/airflow/template/templater.py @@ -17,8 +17,9 @@ from __future__ import annotations +from collections.abc import Collection, Iterable, Sequence from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, Collection, Iterable, Sequence +from typing import TYPE_CHECKING, Any from airflow.io.path import ObjectStoragePath from airflow.utils.helpers import render_template_as_native, render_template_to_string diff --git a/airflow/ti_deps/deps/base_ti_dep.py b/airflow/ti_deps/deps/base_ti_dep.py index f2fe5ee89fd32..0e8a6bd395d74 100644 --- a/airflow/ti_deps/deps/base_ti_dep.py +++ b/airflow/ti_deps/deps/base_ti_dep.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Iterator, NamedTuple +from collections.abc import Iterator +from typing import TYPE_CHECKING, Any, NamedTuple from airflow.ti_deps.dep_context import DepContext from airflow.utils.session import provide_session diff --git a/airflow/ti_deps/deps/trigger_rule_dep.py b/airflow/ti_deps/deps/trigger_rule_dep.py index 76291c8a057f9..ccd11ab303e66 100644 --- a/airflow/ti_deps/deps/trigger_rule_dep.py +++ b/airflow/ti_deps/deps/trigger_rule_dep.py @@ -20,7 +20,8 @@ import collections.abc import functools from collections import Counter -from typing import TYPE_CHECKING, Iterator, KeysView, NamedTuple +from collections.abc import Iterator, KeysView +from typing import TYPE_CHECKING, NamedTuple from sqlalchemy import and_, func, or_, select diff --git a/airflow/timetables/base.py b/airflow/timetables/base.py index 1a076747ec597..60b1c141209fe 100644 --- a/airflow/timetables/base.py +++ b/airflow/timetables/base.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Iterator, NamedTuple, Sequence +from collections.abc import Iterator, Sequence +from typing import TYPE_CHECKING, Any, NamedTuple from airflow.sdk.definitions.asset import BaseAsset from airflow.typing_compat import Protocol, runtime_checkable diff --git a/airflow/timetables/events.py b/airflow/timetables/events.py index c8fd65c2a9884..567a0e351e437 100644 --- a/airflow/timetables/events.py +++ b/airflow/timetables/events.py @@ -17,7 +17,8 @@ from __future__ import annotations import itertools -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING import pendulum diff --git a/airflow/timetables/simple.py b/airflow/timetables/simple.py index 8ce498c9e0491..f282c7fe67f8a 100644 --- a/airflow/timetables/simple.py +++ b/airflow/timetables/simple.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Collection, Sequence +from collections.abc import Collection, Sequence +from typing import TYPE_CHECKING, Any from airflow.sdk.definitions.asset import AssetAlias, AssetAliasCondition from airflow.timetables.base import DagRunInfo, DataInterval, Timetable diff --git a/airflow/triggers/base.py b/airflow/triggers/base.py index bc1da861f3c2d..43b7443a635ce 100644 --- a/airflow/triggers/base.py +++ b/airflow/triggers/base.py @@ -18,9 +18,10 @@ import abc import logging +from collections.abc import AsyncIterator from dataclasses import dataclass from datetime import timedelta -from typing import TYPE_CHECKING, Any, AsyncIterator +from typing import TYPE_CHECKING, Any from airflow.callbacks.callback_requests import TaskCallbackRequest from airflow.callbacks.database_callback_sink import DatabaseCallbackSink diff --git a/airflow/triggers/temporal.py b/airflow/triggers/temporal.py index 64c3afe8162c3..e5a3ca1be00df 100644 --- a/airflow/triggers/temporal.py +++ b/airflow/triggers/temporal.py @@ -18,7 +18,8 @@ import asyncio import datetime -from typing import Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import Any import pendulum diff --git a/airflow/utils/context.py b/airflow/utils/context.py index b954a5e1f2f91..90232e7b2efd8 100644 --- a/airflow/utils/context.py +++ b/airflow/utils/context.py @@ -23,17 +23,11 @@ import copy import functools import warnings +from collections.abc import Container, ItemsView, Iterator, KeysView, Mapping, MutableMapping, ValuesView from typing import ( TYPE_CHECKING, Any, - Container, - ItemsView, - Iterator, - KeysView, - Mapping, - MutableMapping, SupportsIndex, - ValuesView, ) import attrs diff --git a/airflow/utils/context.pyi b/airflow/utils/context.pyi index 069dba2f8f191..d0ea2132f1c95 100644 --- a/airflow/utils/context.pyi +++ b/airflow/utils/context.pyi @@ -26,7 +26,8 @@ # declare "these are defined, but don't error if others are accessed" someday. from __future__ import annotations -from typing import Any, Collection, Container, Iterable, Iterator, Mapping, Sequence, overload +from collections.abc import Collection, Container, Iterable, Iterator, Mapping, Sequence +from typing import Any, overload from pendulum import DateTime from sqlalchemy.orm import Session diff --git a/airflow/utils/db.py b/airflow/utils/db.py index c899ebf615d06..3c657fd447fd1 100644 --- a/airflow/utils/db.py +++ b/airflow/utils/db.py @@ -27,16 +27,13 @@ import sys import time import warnings +from collections.abc import Generator, Iterable, Iterator, Sequence from tempfile import gettempdir from typing import ( TYPE_CHECKING, Any, Callable, - Generator, - Iterable, - Iterator, Protocol, - Sequence, TypeVar, overload, ) @@ -858,10 +855,13 @@ def _configured_alembic_environment() -> Generator[EnvironmentContext, None, Non config = _get_alembic_config() script = _get_script_object(config) - with EnvironmentContext( - config, - script, - ) as env, settings.engine.connect() as connection: + with ( + EnvironmentContext( + config, + script, + ) as env, + settings.engine.connect() as connection, + ): alembic_logger = logging.getLogger("alembic") level = alembic_logger.level alembic_logger.setLevel(logging.WARNING) diff --git a/airflow/utils/email.py b/airflow/utils/email.py index 3a63b4180472b..455b135c23e6c 100644 --- a/airflow/utils/email.py +++ b/airflow/utils/email.py @@ -22,11 +22,12 @@ import os import smtplib import ssl +from collections.abc import Iterable from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.utils import formatdate -from typing import Any, Iterable +from typing import Any import re2 diff --git a/airflow/utils/entry_points.py b/airflow/utils/entry_points.py index 443d3e13f588e..55e7dc789dacb 100644 --- a/airflow/utils/entry_points.py +++ b/airflow/utils/entry_points.py @@ -20,7 +20,7 @@ import logging import sys from collections import defaultdict -from typing import Iterator, Tuple +from collections.abc import Iterator if sys.version_info >= (3, 12): from importlib import metadata @@ -29,10 +29,10 @@ log = logging.getLogger(__name__) -EPnD = Tuple[metadata.EntryPoint, metadata.Distribution] +EPnD = tuple[metadata.EntryPoint, metadata.Distribution] -@functools.lru_cache(maxsize=None) +@functools.cache def _get_grouped_entry_points() -> dict[str, list[EPnD]]: mapping: dict[str, list[EPnD]] = defaultdict(list) for dist in metadata.distributions(): diff --git a/airflow/utils/file.py b/airflow/utils/file.py index 09b39e98ccf99..5c3e454e294af 100644 --- a/airflow/utils/file.py +++ b/airflow/utils/file.py @@ -22,9 +22,11 @@ import logging import os import zipfile +from collections.abc import Generator from io import TextIOWrapper from pathlib import Path -from typing import Generator, NamedTuple, Pattern, Protocol, overload +from re import Pattern +from typing import NamedTuple, Protocol, overload import re2 from pathspec.patterns import GitWildMatchPattern diff --git a/airflow/utils/helpers.py b/airflow/utils/helpers.py index 1a6b7396e3225..4cfc62acdd21a 100644 --- a/airflow/utils/helpers.py +++ b/airflow/utils/helpers.py @@ -21,9 +21,10 @@ import itertools import re import signal +from collections.abc import Generator, Iterable, Mapping, MutableMapping from datetime import datetime from functools import reduce -from typing import TYPE_CHECKING, Any, Callable, Generator, Iterable, Mapping, MutableMapping, TypeVar, cast +from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast from lazy_object_proxy import Proxy diff --git a/airflow/utils/log/file_task_handler.py b/airflow/utils/log/file_task_handler.py index c5b60b762d4b1..9ec14c98dbbd2 100644 --- a/airflow/utils/log/file_task_handler.py +++ b/airflow/utils/log/file_task_handler.py @@ -21,11 +21,12 @@ import logging import os +from collections.abc import Iterable from contextlib import suppress from enum import Enum from functools import cached_property from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Iterable +from typing import TYPE_CHECKING, Any, Callable from urllib.parse import urljoin import pendulum diff --git a/airflow/utils/log/log_reader.py b/airflow/utils/log/log_reader.py index c99efc350bb19..cc60500532fb1 100644 --- a/airflow/utils/log/log_reader.py +++ b/airflow/utils/log/log_reader.py @@ -18,8 +18,9 @@ import logging import time +from collections.abc import Iterator from functools import cached_property -from typing import TYPE_CHECKING, Iterator +from typing import TYPE_CHECKING from airflow.configuration import conf from airflow.utils.helpers import render_log_filename diff --git a/airflow/utils/log/secrets_masker.py b/airflow/utils/log/secrets_masker.py index 4f9604aced7f4..12019fbad6dcd 100644 --- a/airflow/utils/log/secrets_masker.py +++ b/airflow/utils/log/secrets_masker.py @@ -21,20 +21,15 @@ import collections.abc import logging import sys +from collections.abc import Generator, Iterable, Iterator from enum import Enum from functools import cache, cached_property +from re import Pattern from typing import ( TYPE_CHECKING, Any, Callable, - Dict, - Generator, - Iterable, - Iterator, - List, - Pattern, TextIO, - Tuple, TypeVar, Union, ) @@ -48,7 +43,7 @@ from airflow.typing_compat import TypeGuard -Redactable = TypeVar("Redactable", str, "V1EnvVar", Dict[Any, Any], Tuple[Any, ...], List[Any]) +Redactable = TypeVar("Redactable", str, "V1EnvVar", dict[Any, Any], tuple[Any, ...], list[Any]) Redacted = Union[Redactable, str] log = logging.getLogger(__name__) diff --git a/airflow/utils/net.py b/airflow/utils/net.py index 9fc79b3842c3a..efdc509a7f505 100644 --- a/airflow/utils/net.py +++ b/airflow/utils/net.py @@ -18,11 +18,11 @@ from __future__ import annotations import socket -from functools import lru_cache +from functools import cache # patched version of socket.getfqdn() - see https://github.com/python/cpython/issues/49254 -@lru_cache(maxsize=None) +@cache def getfqdn(name=""): """ Get fully qualified domain name from name. diff --git a/airflow/utils/operator_helpers.py b/airflow/utils/operator_helpers.py index f841d968ad6e4..e5e304bb4a414 100644 --- a/airflow/utils/operator_helpers.py +++ b/airflow/utils/operator_helpers.py @@ -19,8 +19,9 @@ import inspect import logging +from collections.abc import Collection, Mapping from datetime import datetime -from typing import TYPE_CHECKING, Any, Callable, Collection, Mapping, Protocol, TypeVar +from typing import TYPE_CHECKING, Any, Callable, Protocol, TypeVar from airflow import settings from airflow.sdk.definitions.asset.metadata import Metadata diff --git a/airflow/utils/process_utils.py b/airflow/utils/process_utils.py index 7120bd5df860e..99d0034975b61 100644 --- a/airflow/utils/process_utils.py +++ b/airflow/utils/process_utils.py @@ -35,8 +35,8 @@ import termios import tty +from collections.abc import Generator from contextlib import contextmanager -from typing import Generator import psutil from lockfile.pidlockfile import PIDLockFile diff --git a/airflow/utils/session.py b/airflow/utils/session.py index 49383cdf4a8bf..fde56354b4782 100644 --- a/airflow/utils/session.py +++ b/airflow/utils/session.py @@ -18,9 +18,10 @@ import contextlib import os +from collections.abc import Generator from functools import wraps from inspect import signature -from typing import Callable, Generator, TypeVar, cast +from typing import Callable, TypeVar, cast from sqlalchemy.orm import Session as SASession diff --git a/airflow/utils/sqlalchemy.py b/airflow/utils/sqlalchemy.py index c81ecf037a62e..14dd7cee1b231 100644 --- a/airflow/utils/sqlalchemy.py +++ b/airflow/utils/sqlalchemy.py @@ -21,8 +21,9 @@ import copy import datetime import logging +from collections.abc import Generator, Iterable from importlib import metadata -from typing import TYPE_CHECKING, Any, Generator, Iterable, overload +from typing import TYPE_CHECKING, Any, overload from packaging import version from sqlalchemy import TIMESTAMP, PickleType, event, nullsfirst, tuple_ diff --git a/airflow/utils/task_group.py b/airflow/utils/task_group.py index 1f94880902c93..3597c7f893cd2 100644 --- a/airflow/utils/task_group.py +++ b/airflow/utils/task_group.py @@ -21,7 +21,8 @@ import functools import operator -from typing import TYPE_CHECKING, Iterator +from collections.abc import Iterator +from typing import TYPE_CHECKING import airflow.sdk.definitions.taskgroup diff --git a/airflow/utils/timeout.py b/airflow/utils/timeout.py index 59330e7c0784a..11a5e1bfa1e22 100644 --- a/airflow/utils/timeout.py +++ b/airflow/utils/timeout.py @@ -19,14 +19,14 @@ import os import signal +from contextlib import AbstractContextManager from threading import Timer -from typing import ContextManager from airflow.exceptions import AirflowTaskTimeout from airflow.utils.log.logging_mixin import LoggingMixin from airflow.utils.platform import IS_WINDOWS -_timeout = ContextManager[None] +_timeout = AbstractContextManager[None] class TimeoutWindows(_timeout, LoggingMixin): diff --git a/airflow/utils/weekday.py b/airflow/utils/weekday.py index d148858cc5fef..a8782a9e436be 100644 --- a/airflow/utils/weekday.py +++ b/airflow/utils/weekday.py @@ -19,7 +19,7 @@ from __future__ import annotations import enum -from typing import Iterable +from collections.abc import Iterable @enum.unique diff --git a/airflow/www/auth.py b/airflow/www/auth.py index d4b8ad619e6e5..2b864273e5fa0 100644 --- a/airflow/www/auth.py +++ b/airflow/www/auth.py @@ -18,8 +18,9 @@ import functools import logging +from collections.abc import Sequence from functools import wraps -from typing import TYPE_CHECKING, Callable, Sequence, TypeVar, cast +from typing import TYPE_CHECKING, Callable, TypeVar, cast from flask import flash, redirect, render_template, request, url_for from flask_appbuilder._compat import as_unicode diff --git a/airflow/www/extensions/init_wsgi_middlewares.py b/airflow/www/extensions/init_wsgi_middlewares.py index 27368e71eed9b..922d06ff8004a 100644 --- a/airflow/www/extensions/init_wsgi_middlewares.py +++ b/airflow/www/extensions/init_wsgi_middlewares.py @@ -17,7 +17,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING from urllib.parse import urlsplit from werkzeug.middleware.dispatcher import DispatcherMiddleware diff --git a/airflow/www/forms.py b/airflow/www/forms.py index 57b4fde3a6e6e..7028e2026e449 100644 --- a/airflow/www/forms.py +++ b/airflow/www/forms.py @@ -20,8 +20,8 @@ import datetime import json import operator +from collections.abc import Iterator from functools import cache -from typing import Iterator import pendulum from flask_appbuilder.fieldwidgets import ( diff --git a/airflow/www/utils.py b/airflow/www/utils.py index ce8174253f1ab..8a74a74d5a8d9 100644 --- a/airflow/www/utils.py +++ b/airflow/www/utils.py @@ -21,7 +21,8 @@ import logging import textwrap import time -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from urllib.parse import urlencode from flask import request, url_for diff --git a/airflow/www/views.py b/airflow/www/views.py index 363b743c6749c..35cfa45a85a11 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -32,10 +32,11 @@ import warnings from bisect import insort_left from collections import defaultdict +from collections.abc import Collection, Iterator, Mapping, MutableMapping, Sequence from functools import cache, cached_property from json import JSONDecodeError from pathlib import Path -from typing import TYPE_CHECKING, Any, Collection, Iterator, Mapping, MutableMapping, Sequence +from typing import TYPE_CHECKING, Any from urllib.parse import unquote, urlencode, urljoin, urlparse, urlsplit import configupdater diff --git a/docker_tests/test_examples_of_prod_image_building.py b/docker_tests/test_examples_of_prod_image_building.py index a10fcb1c654c2..9424379fb9db9 100644 --- a/docker_tests/test_examples_of_prod_image_building.py +++ b/docker_tests/test_examples_of_prod_image_building.py @@ -19,7 +19,7 @@ import glob import os import re -from functools import lru_cache +from functools import cache from pathlib import Path import pytest @@ -40,7 +40,7 @@ } -@lru_cache(maxsize=None) +@cache def get_latest_airflow_image(): response = requests.get("https://pypi.org/pypi/apache-airflow/json") response.raise_for_status() diff --git a/docs/build_docs.py b/docs/build_docs.py index 82edc9d1632d3..f8004ebc3dc47 100755 --- a/docs/build_docs.py +++ b/docs/build_docs.py @@ -29,7 +29,8 @@ import os import sys from collections import defaultdict -from typing import Any, Callable, Iterable, NamedTuple, TypeVar +from collections.abc import Iterable +from typing import Any, Callable, NamedTuple, TypeVar from rich.console import Console from tabulate import tabulate diff --git a/docs/exts/docs_build/fetch_inventories.py b/docs/exts/docs_build/fetch_inventories.py index 9576a82b32c4e..04c64bc3e0e36 100644 --- a/docs/exts/docs_build/fetch_inventories.py +++ b/docs/exts/docs_build/fetch_inventories.py @@ -24,8 +24,8 @@ import shutil import sys import traceback +from collections.abc import Iterator from tempfile import NamedTemporaryFile -from typing import Iterator import requests import urllib3.exceptions diff --git a/docs/exts/docs_build/lint_checks.py b/docs/exts/docs_build/lint_checks.py index e536feb680881..7a4561062feed 100644 --- a/docs/exts/docs_build/lint_checks.py +++ b/docs/exts/docs_build/lint_checks.py @@ -20,8 +20,8 @@ import itertools import os import re +from collections.abc import Iterable from glob import glob -from typing import Iterable from docs.exts.docs_build.docs_builder import ALL_PROVIDER_YAMLS from docs.exts.docs_build.errors import DocBuildError diff --git a/docs/exts/operators_and_hooks_ref.py b/docs/exts/operators_and_hooks_ref.py index 82dac517bd139..f9ddcc50ec894 100644 --- a/docs/exts/operators_and_hooks_ref.py +++ b/docs/exts/operators_and_hooks_ref.py @@ -18,9 +18,10 @@ import ast import os -from functools import lru_cache +from collections.abc import Iterable, Iterator +from functools import cache from pathlib import Path -from typing import TYPE_CHECKING, Any, Iterable, Iterator +from typing import TYPE_CHECKING, Any import jinja2 import rich_click as click @@ -56,7 +57,7 @@ DOCS_DIR = os.path.join(ROOT_DIR, "docs") -@lru_cache(maxsize=None) +@cache def _get_jinja_env(): loader = jinja2.FileSystemLoader(TEMPLATE_DIR, followlinks=True) env = jinja2.Environment(loader=loader, undefined=jinja2.StrictUndefined) diff --git a/docs/exts/providers_extensions.py b/docs/exts/providers_extensions.py index 816ada6931bd5..61f4ce6e7dde2 100644 --- a/docs/exts/providers_extensions.py +++ b/docs/exts/providers_extensions.py @@ -20,9 +20,10 @@ import ast import os +from collections.abc import Iterable from functools import partial from pathlib import Path -from typing import Any, Callable, Iterable +from typing import Any, Callable # No stub exists for docutils.parsers.rst.directives. See https://github.com/python/typeshed/issues/5755. from provider_yaml_utils import load_package_data diff --git a/docs/exts/sphinx_script_update.py b/docs/exts/sphinx_script_update.py index b31e0be1fd0de..f7114d9d81963 100644 --- a/docs/exts/sphinx_script_update.py +++ b/docs/exts/sphinx_script_update.py @@ -22,7 +22,7 @@ import shutil import sys import tempfile -from functools import lru_cache +from functools import cache import requests from sphinx.builders import html as builders @@ -55,7 +55,7 @@ def _user_cache_dir(appname=None): return path -@lru_cache(maxsize=None) +@cache def fetch_and_cache(script_url: str, output_filename: str): """Fetch URL to local cache and returns path.""" cache_key = _gethash(script_url) diff --git a/hatch_build.py b/hatch_build.py index 5eefe231fdb15..61cf1563f969c 100644 --- a/hatch_build.py +++ b/hatch_build.py @@ -22,9 +22,10 @@ import os import re import sys +from collections.abc import Iterable from pathlib import Path from subprocess import run -from typing import Any, Callable, Iterable +from typing import Any, Callable from hatchling.builders.config import BuilderConfig from hatchling.builders.hooks.plugin.interface import BuildHookInterface diff --git a/performance/src/performance_dags/performance_dag/performance_dag_utils.py b/performance/src/performance_dags/performance_dag/performance_dag_utils.py index 8dc1ae49fa650..665b12e3987d5 100644 --- a/performance/src/performance_dags/performance_dag/performance_dag_utils.py +++ b/performance/src/performance_dags/performance_dag/performance_dag_utils.py @@ -426,7 +426,7 @@ def generate_copies_of_performance_dag( :yields: a pair consisting of path to the temporary directory and a list with paths to copies of performance DAG - :type: Tuple[str, List[str]] + :type: tuple[str, list[str]] """ dag_files_count = int( get_performance_dag_environment_variable(performance_dag_conf, "PERF_DAG_FILES_COUNT") @@ -665,7 +665,7 @@ def parse_start_date(date, start_ago): Returns the start date for the performance DAGs and string to be used as part of their ids. - :return Tuple[datetime.datetime, str]: A tuple of datetime.datetime object to be used + :return tuple[datetime.datetime, str]: A tuple of datetime.datetime object to be used as a start_date and a string that should be used as part of the dag_id. """ if date: diff --git a/providers/pyproject.toml b/providers/pyproject.toml index 51886fb3fbce3..29cbbbb016053 100644 --- a/providers/pyproject.toml +++ b/providers/pyproject.toml @@ -23,7 +23,7 @@ build-backend = "hatchling.build" name = "local-providers" version = "0.1.0" description = "Placeholder package for local/from-sources providers." -requires-python = ">=3.8, <3.13" +requires-python = ">=3.9, <3.13" classifiers = [ "Private :: Do Not Upload", ] diff --git a/providers/src/airflow/providers/airbyte/operators/airbyte.py b/providers/src/airflow/providers/airbyte/operators/airbyte.py index 51764029dfd6c..757de75352876 100644 --- a/providers/src/airflow/providers/airbyte/operators/airbyte.py +++ b/providers/src/airflow/providers/airbyte/operators/airbyte.py @@ -18,7 +18,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airbyte_api.models import JobStatusEnum diff --git a/providers/src/airflow/providers/airbyte/sensors/airbyte.py b/providers/src/airflow/providers/airbyte/sensors/airbyte.py index 1dc5a805e9362..ad658ef47e376 100644 --- a/providers/src/airflow/providers/airbyte/sensors/airbyte.py +++ b/providers/src/airflow/providers/airbyte/sensors/airbyte.py @@ -21,7 +21,8 @@ import time import warnings -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airbyte_api.models import JobStatusEnum diff --git a/providers/src/airflow/providers/airbyte/triggers/airbyte.py b/providers/src/airflow/providers/airbyte/triggers/airbyte.py index 1184b42d812ed..641b0062c7fc8 100644 --- a/providers/src/airflow/providers/airbyte/triggers/airbyte.py +++ b/providers/src/airflow/providers/airbyte/triggers/airbyte.py @@ -18,7 +18,8 @@ import asyncio import time -from typing import Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import Any from airbyte_api.models import JobStatusEnum diff --git a/providers/src/airflow/providers/alibaba/cloud/hooks/analyticdb_spark.py b/providers/src/airflow/providers/alibaba/cloud/hooks/analyticdb_spark.py index e40b892aea8e7..071b634b8c186 100644 --- a/providers/src/airflow/providers/alibaba/cloud/hooks/analyticdb_spark.py +++ b/providers/src/airflow/providers/alibaba/cloud/hooks/analyticdb_spark.py @@ -18,8 +18,9 @@ from __future__ import annotations import json +from collections.abc import Sequence from enum import Enum -from typing import Any, Sequence +from typing import Any from alibabacloud_adb20211201.client import Client from alibabacloud_adb20211201.models import ( diff --git a/providers/src/airflow/providers/alibaba/cloud/operators/analyticdb_spark.py b/providers/src/airflow/providers/alibaba/cloud/operators/analyticdb_spark.py index 345cf5d27ea13..324b715ddff33 100644 --- a/providers/src/airflow/providers/alibaba/cloud/operators/analyticdb_spark.py +++ b/providers/src/airflow/providers/alibaba/cloud/operators/analyticdb_spark.py @@ -18,8 +18,9 @@ from __future__ import annotations import time +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from deprecated.classic import deprecated diff --git a/providers/src/airflow/providers/alibaba/cloud/sensors/analyticdb_spark.py b/providers/src/airflow/providers/alibaba/cloud/sensors/analyticdb_spark.py index 02bab417b6d7a..afbbeef4d9275 100644 --- a/providers/src/airflow/providers/alibaba/cloud/sensors/analyticdb_spark.py +++ b/providers/src/airflow/providers/alibaba/cloud/sensors/analyticdb_spark.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from deprecated.classic import deprecated diff --git a/providers/src/airflow/providers/alibaba/cloud/sensors/oss_key.py b/providers/src/airflow/providers/alibaba/cloud/sensors/oss_key.py index c9336581ec774..cf09006252bd4 100644 --- a/providers/src/airflow/providers/alibaba/cloud/sensors/oss_key.py +++ b/providers/src/airflow/providers/alibaba/cloud/sensors/oss_key.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from urllib.parse import urlsplit from deprecated.classic import deprecated diff --git a/providers/src/airflow/providers/amazon/aws/auth_manager/avp/facade.py b/providers/src/airflow/providers/amazon/aws/auth_manager/avp/facade.py index 4bb9515004cf6..581932f0bc81f 100644 --- a/providers/src/airflow/providers/amazon/aws/auth_manager/avp/facade.py +++ b/providers/src/airflow/providers/amazon/aws/auth_manager/avp/facade.py @@ -17,9 +17,10 @@ from __future__ import annotations import json +from collections.abc import Sequence from functools import cached_property from pathlib import Path -from typing import TYPE_CHECKING, Sequence, TypedDict +from typing import TYPE_CHECKING, TypedDict from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/auth_manager/aws_auth_manager.py b/providers/src/airflow/providers/amazon/aws/auth_manager/aws_auth_manager.py index 8271aad330229..fb32a37f57386 100644 --- a/providers/src/airflow/providers/amazon/aws/auth_manager/aws_auth_manager.py +++ b/providers/src/airflow/providers/amazon/aws/auth_manager/aws_auth_manager.py @@ -19,8 +19,9 @@ import argparse import warnings from collections import defaultdict +from collections.abc import Container, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Container, Sequence, cast +from typing import TYPE_CHECKING, cast from flask import session, url_for diff --git a/providers/src/airflow/providers/amazon/aws/executors/batch/batch_executor.py b/providers/src/airflow/providers/amazon/aws/executors/batch/batch_executor.py index b38688defbba7..f7226fbed7158 100644 --- a/providers/src/airflow/providers/amazon/aws/executors/batch/batch_executor.py +++ b/providers/src/airflow/providers/amazon/aws/executors/batch/batch_executor.py @@ -21,9 +21,10 @@ import time from collections import deque +from collections.abc import Sequence from contextlib import suppress from copy import deepcopy -from typing import TYPE_CHECKING, Any, Dict, List, Sequence +from typing import TYPE_CHECKING, Any from botocore.exceptions import ClientError, NoCredentialsError @@ -55,8 +56,8 @@ ) from airflow.utils.state import State -CommandType = List[str] -ExecutorConfigType = Dict[str, Any] +CommandType = list[str] +ExecutorConfigType = dict[str, Any] INVALID_CREDENTIALS_EXCEPTIONS = [ "ExpiredTokenException", diff --git a/providers/src/airflow/providers/amazon/aws/executors/batch/utils.py b/providers/src/airflow/providers/amazon/aws/executors/batch/utils.py index 3901c170bad84..abcc16ec321fb 100644 --- a/providers/src/airflow/providers/amazon/aws/executors/batch/utils.py +++ b/providers/src/airflow/providers/amazon/aws/executors/batch/utils.py @@ -19,7 +19,7 @@ import datetime from collections import defaultdict from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, Dict, List +from typing import TYPE_CHECKING, Any from airflow.providers.amazon.aws.executors.utils.base_config_keys import BaseConfigKeys from airflow.utils.state import State @@ -27,8 +27,8 @@ if TYPE_CHECKING: from airflow.models.taskinstance import TaskInstanceKey -CommandType = List[str] -ExecutorConfigType = Dict[str, Any] +CommandType = list[str] +ExecutorConfigType = dict[str, Any] CONFIG_GROUP_NAME = "aws_batch_executor" diff --git a/providers/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py b/providers/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py index d8c5cea941dae..6233d46aa2909 100644 --- a/providers/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py +++ b/providers/src/airflow/providers/amazon/aws/executors/ecs/ecs_executor.py @@ -25,9 +25,10 @@ import time from collections import defaultdict, deque +from collections.abc import Sequence from contextlib import suppress from copy import deepcopy -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from botocore.exceptions import ClientError, NoCredentialsError diff --git a/providers/src/airflow/providers/amazon/aws/executors/ecs/utils.py b/providers/src/airflow/providers/amazon/aws/executors/ecs/utils.py index 10d9162d5a6b5..39b266253ce05 100644 --- a/providers/src/airflow/providers/amazon/aws/executors/ecs/utils.py +++ b/providers/src/airflow/providers/amazon/aws/executors/ecs/utils.py @@ -26,7 +26,7 @@ import datetime from collections import defaultdict from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, Callable, Dict, List +from typing import TYPE_CHECKING, Any, Callable from inflection import camelize @@ -36,9 +36,9 @@ if TYPE_CHECKING: from airflow.models.taskinstance import TaskInstanceKey -CommandType = List[str] +CommandType = list[str] ExecutorConfigFunctionType = Callable[[CommandType], dict] -ExecutorConfigType = Dict[str, Any] +ExecutorConfigType = dict[str, Any] ECS_LAUNCH_TYPE_EC2 = "EC2" ECS_LAUNCH_TYPE_FARGATE = "FARGATE" diff --git a/providers/src/airflow/providers/amazon/aws/fs/s3.py b/providers/src/airflow/providers/amazon/aws/fs/s3.py index 128e225815131..e0c28d923c4bb 100644 --- a/providers/src/airflow/providers/amazon/aws/fs/s3.py +++ b/providers/src/airflow/providers/amazon/aws/fs/s3.py @@ -19,7 +19,7 @@ import asyncio import logging from functools import partial -from typing import TYPE_CHECKING, Any, Callable, Dict +from typing import TYPE_CHECKING, Any, Callable import requests from botocore import UNSIGNED @@ -32,7 +32,7 @@ from fsspec import AbstractFileSystem -Properties = Dict[str, str] +Properties = dict[str, str] S3_PROXY_URI = "proxy-uri" diff --git a/providers/src/airflow/providers/amazon/aws/hooks/appflow.py b/providers/src/airflow/providers/amazon/aws/hooks/appflow.py index 0444a1f1a11ff..2a2f0d945406a 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/appflow.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/appflow.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence, cast +from collections.abc import Sequence +from typing import TYPE_CHECKING, cast from mypy_boto3_appflow.type_defs import ( DestinationFlowConfigTypeDef, diff --git a/providers/src/airflow/providers/amazon/aws/hooks/athena.py b/providers/src/airflow/providers/amazon/aws/hooks/athena.py index 60405a863999f..b6ef37325c1cf 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/athena.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/athena.py @@ -25,7 +25,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Collection +from collections.abc import Collection +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook diff --git a/providers/src/airflow/providers/amazon/aws/hooks/dynamodb.py b/providers/src/airflow/providers/amazon/aws/hooks/dynamodb.py index 29707b3f495d9..53980a1f93308 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/dynamodb.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/dynamodb.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Iterable from functools import cached_property -from typing import TYPE_CHECKING, Iterable +from typing import TYPE_CHECKING from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/hooks/eks.py b/providers/src/airflow/providers/amazon/aws/hooks/eks.py index 40f1fe6193673..2b31f5afb66d3 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/eks.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/eks.py @@ -22,10 +22,11 @@ import json import sys import tempfile +from collections.abc import Generator from contextlib import contextmanager from enum import Enum from functools import partial -from typing import Callable, Generator +from typing import Callable from botocore.exceptions import ClientError from botocore.signers import RequestSigner diff --git a/providers/src/airflow/providers/amazon/aws/hooks/kinesis.py b/providers/src/airflow/providers/amazon/aws/hooks/kinesis.py index 72e3e73d9c053..2601527ea5a7c 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/kinesis.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/kinesis.py @@ -19,7 +19,7 @@ from __future__ import annotations -from typing import Iterable +from collections.abc import Iterable from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook diff --git a/providers/src/airflow/providers/amazon/aws/hooks/logs.py b/providers/src/airflow/providers/amazon/aws/hooks/logs.py index e3f34e33bd919..32047e81dc8f4 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/logs.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/logs.py @@ -18,7 +18,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncGenerator, Generator +from collections.abc import AsyncGenerator, Generator +from typing import Any from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/hooks/redshift_cluster.py b/providers/src/airflow/providers/amazon/aws/hooks/redshift_cluster.py index ee365e0ab4d13..d9a8a29584413 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/redshift_cluster.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/redshift_cluster.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook diff --git a/providers/src/airflow/providers/amazon/aws/hooks/redshift_data.py b/providers/src/airflow/providers/amazon/aws/hooks/redshift_data.py index b2f46c0ef6049..309b35448e7d7 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/redshift_data.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/redshift_data.py @@ -18,9 +18,10 @@ from __future__ import annotations import time +from collections.abc import Iterable from dataclasses import dataclass from pprint import pformat -from typing import TYPE_CHECKING, Any, Iterable +from typing import TYPE_CHECKING, Any from uuid import UUID from pendulum import duration diff --git a/providers/src/airflow/providers/amazon/aws/hooks/s3.py b/providers/src/airflow/providers/amazon/aws/hooks/s3.py index 5f9fe62d3e9d6..fcbb1c1c720c5 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/s3.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/s3.py @@ -28,6 +28,7 @@ import re import shutil import time +from collections.abc import AsyncIterator from contextlib import suppress from copy import deepcopy from datetime import datetime @@ -36,7 +37,7 @@ from io import BytesIO from pathlib import Path from tempfile import NamedTemporaryFile, gettempdir -from typing import TYPE_CHECKING, Any, AsyncIterator, Callable +from typing import TYPE_CHECKING, Any, Callable from urllib.parse import urlsplit from uuid import uuid4 diff --git a/providers/src/airflow/providers/amazon/aws/hooks/sagemaker.py b/providers/src/airflow/providers/amazon/aws/hooks/sagemaker.py index 10d7b8436c0d0..fb2b5ba79b8f2 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/sagemaker.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/sagemaker.py @@ -23,9 +23,10 @@ import tempfile import time from collections import Counter, namedtuple +from collections.abc import AsyncGenerator, Generator from datetime import datetime from functools import partial -from typing import Any, AsyncGenerator, Callable, Generator, cast +from typing import Any, Callable, cast from asgiref.sync import sync_to_async from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/hooks/ses.py b/providers/src/airflow/providers/amazon/aws/hooks/ses.py index a5ea06de35171..7c0568c4d03c8 100644 --- a/providers/src/airflow/providers/amazon/aws/hooks/ses.py +++ b/providers/src/airflow/providers/amazon/aws/hooks/ses.py @@ -18,7 +18,8 @@ from __future__ import annotations -from typing import Any, Iterable +from collections.abc import Iterable +from typing import Any from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook from airflow.utils.email import build_mime_message diff --git a/providers/src/airflow/providers/amazon/aws/notifications/sns.py b/providers/src/airflow/providers/amazon/aws/notifications/sns.py index b769f633dbd7c..1ed61f3276b42 100644 --- a/providers/src/airflow/providers/amazon/aws/notifications/sns.py +++ b/providers/src/airflow/providers/amazon/aws/notifications/sns.py @@ -17,8 +17,8 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import Sequence from airflow.notifications.basenotifier import BaseNotifier from airflow.providers.amazon.aws.hooks.sns import SnsHook diff --git a/providers/src/airflow/providers/amazon/aws/notifications/sqs.py b/providers/src/airflow/providers/amazon/aws/notifications/sqs.py index 59f53b59336e2..e0188542c83f4 100644 --- a/providers/src/airflow/providers/amazon/aws/notifications/sqs.py +++ b/providers/src/airflow/providers/amazon/aws/notifications/sqs.py @@ -17,8 +17,8 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import Sequence from airflow.notifications.basenotifier import BaseNotifier from airflow.providers.amazon.aws.hooks.sqs import SqsHook diff --git a/providers/src/airflow/providers/amazon/aws/operators/athena.py b/providers/src/airflow/providers/amazon/aws/operators/athena.py index c602611803ed5..62c1e318d0238 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/athena.py +++ b/providers/src/airflow/providers/amazon/aws/operators/athena.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from urllib.parse import urlparse from airflow.configuration import conf diff --git a/providers/src/airflow/providers/amazon/aws/operators/base_aws.py b/providers/src/airflow/providers/amazon/aws/operators/base_aws.py index b2e49c25ab459..ce9855393319f 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/base_aws.py +++ b/providers/src/airflow/providers/amazon/aws/operators/base_aws.py @@ -17,7 +17,7 @@ from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from airflow.models import BaseOperator from airflow.providers.amazon.aws.utils.mixins import ( diff --git a/providers/src/airflow/providers/amazon/aws/operators/batch.py b/providers/src/airflow/providers/amazon/aws/operators/batch.py index f61292154799f..3df00fb04c37f 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/batch.py +++ b/providers/src/airflow/providers/amazon/aws/operators/batch.py @@ -26,9 +26,10 @@ from __future__ import annotations +from collections.abc import Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/operators/bedrock.py b/providers/src/airflow/providers/amazon/aws/operators/bedrock.py index 021ee92dbc184..ef4d78129d473 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/bedrock.py +++ b/providers/src/airflow/providers/amazon/aws/operators/bedrock.py @@ -17,8 +17,9 @@ from __future__ import annotations import json +from collections.abc import Sequence from time import sleep -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/operators/cloud_formation.py b/providers/src/airflow/providers/amazon/aws/operators/cloud_formation.py index b75c5dfb96102..b3168dccc464b 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/cloud_formation.py +++ b/providers/src/airflow/providers/amazon/aws/operators/cloud_formation.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.amazon.aws.hooks.cloud_formation import CloudFormationHook from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/operators/comprehend.py b/providers/src/airflow/providers/amazon/aws/operators/comprehend.py index 88bbbf9bf46db..01496bfc912ee 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/comprehend.py +++ b/providers/src/airflow/providers/amazon/aws/operators/comprehend.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, ClassVar, Sequence +from typing import TYPE_CHECKING, Any, ClassVar from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/operators/datasync.py b/providers/src/airflow/providers/amazon/aws/operators/datasync.py index 0c199b59fb7a1..d5c97843f16fb 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/datasync.py +++ b/providers/src/airflow/providers/amazon/aws/operators/datasync.py @@ -20,7 +20,8 @@ import logging import random -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException, AirflowTaskTimeout from airflow.providers.amazon.aws.hooks.datasync import DataSyncHook diff --git a/providers/src/airflow/providers/amazon/aws/operators/dms.py b/providers/src/airflow/providers/amazon/aws/operators/dms.py index 6d64de85e267b..f4acd3d934dc5 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/dms.py +++ b/providers/src/airflow/providers/amazon/aws/operators/dms.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, ClassVar, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, ClassVar from airflow.providers.amazon.aws.hooks.dms import DmsHook from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/operators/ec2.py b/providers/src/airflow/providers/amazon/aws/operators/ec2.py index a657b14e1d58d..5b25b27fd0555 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/ec2.py +++ b/providers/src/airflow/providers/amazon/aws/operators/ec2.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/operators/ecs.py b/providers/src/airflow/providers/amazon/aws/operators/ecs.py index 10b2d83ec9273..e44e1e1c1989a 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/ecs.py +++ b/providers/src/airflow/providers/amazon/aws/operators/ecs.py @@ -18,9 +18,10 @@ from __future__ import annotations import re +from collections.abc import Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/operators/eks.py b/providers/src/airflow/providers/amazon/aws/operators/eks.py index d90103362d01c..6ce0dd154305c 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/eks.py +++ b/providers/src/airflow/providers/amazon/aws/operators/eks.py @@ -20,9 +20,10 @@ import logging from ast import literal_eval +from collections.abc import Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, List, Sequence, cast +from typing import TYPE_CHECKING, Any, cast from botocore.exceptions import ClientError, WaiterError @@ -337,7 +338,7 @@ def execute(self, context: Context): fargate_pod_execution_role_arn=self.fargate_pod_execution_role_arn, fargate_selectors=self.fargate_selectors, create_fargate_profile_kwargs=self.create_fargate_profile_kwargs, - subnets=cast(List[str], self.resources_vpc_config.get("subnetIds")), + subnets=cast(list[str], self.resources_vpc_config.get("subnetIds")), ) def deferrable_create_cluster_next(self, context: Context, event: dict[str, Any] | None = None) -> None: @@ -376,7 +377,7 @@ def deferrable_create_cluster_next(self, context: Context, event: dict[str, Any] fargate_pod_execution_role_arn=self.fargate_pod_execution_role_arn, fargate_selectors=self.fargate_selectors, create_fargate_profile_kwargs=self.create_fargate_profile_kwargs, - subnets=cast(List[str], self.resources_vpc_config.get("subnetIds")), + subnets=cast(list[str], self.resources_vpc_config.get("subnetIds")), ) if self.compute == "fargate": self.defer( diff --git a/providers/src/airflow/providers/amazon/aws/operators/emr.py b/providers/src/airflow/providers/amazon/aws/operators/emr.py index 6aba14b350910..c6ba3bf29b857 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/emr.py +++ b/providers/src/airflow/providers/amazon/aws/operators/emr.py @@ -18,9 +18,10 @@ from __future__ import annotations import ast +from collections.abc import Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from uuid import uuid4 from airflow.configuration import conf diff --git a/providers/src/airflow/providers/amazon/aws/operators/eventbridge.py b/providers/src/airflow/providers/amazon/aws/operators/eventbridge.py index 5d02d275a0bbd..00e06a7ded12a 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/eventbridge.py +++ b/providers/src/airflow/providers/amazon/aws/operators/eventbridge.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.eventbridge import EventBridgeHook diff --git a/providers/src/airflow/providers/amazon/aws/operators/glacier.py b/providers/src/airflow/providers/amazon/aws/operators/glacier.py index 3164004181234..70f06b07ef98e 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/glacier.py +++ b/providers/src/airflow/providers/amazon/aws/operators/glacier.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.amazon.aws.hooks.glacier import GlacierHook from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/operators/glue.py b/providers/src/airflow/providers/amazon/aws/operators/glue.py index 563d619cd9943..2aa4b7f01924f 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/glue.py +++ b/providers/src/airflow/providers/amazon/aws/operators/glue.py @@ -19,8 +19,9 @@ import os import urllib.parse +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/operators/glue_crawler.py b/providers/src/airflow/providers/amazon/aws/operators/glue_crawler.py index 1ce73eea07163..4414026a815a0 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/glue_crawler.py +++ b/providers/src/airflow/providers/amazon/aws/operators/glue_crawler.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/operators/glue_databrew.py b/providers/src/airflow/providers/amazon/aws/operators/glue_databrew.py index f0b361ec176a9..2bdea28f3a3dc 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/glue_databrew.py +++ b/providers/src/airflow/providers/amazon/aws/operators/glue_databrew.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/operators/kinesis_analytics.py b/providers/src/airflow/providers/amazon/aws/operators/kinesis_analytics.py index 93f8bc6b805e4..16003e0b9f322 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/kinesis_analytics.py +++ b/providers/src/airflow/providers/amazon/aws/operators/kinesis_analytics.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, ClassVar, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, ClassVar from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/operators/lambda_function.py b/providers/src/airflow/providers/amazon/aws/operators/lambda_function.py index 8072c5045c168..54bab6e6aa818 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/lambda_function.py +++ b/providers/src/airflow/providers/amazon/aws/operators/lambda_function.py @@ -18,8 +18,9 @@ from __future__ import annotations import json +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/operators/neptune.py b/providers/src/airflow/providers/amazon/aws/operators/neptune.py index 1cc2c4b1b82f3..73e3c759e9eda 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/neptune.py +++ b/providers/src/airflow/providers/amazon/aws/operators/neptune.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/operators/quicksight.py b/providers/src/airflow/providers/amazon/aws/operators/quicksight.py index 9555e0d63a11a..5b333ec49db64 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/quicksight.py +++ b/providers/src/airflow/providers/amazon/aws/operators/quicksight.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.amazon.aws.hooks.quicksight import QuickSightHook from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/operators/rds.py b/providers/src/airflow/providers/amazon/aws/operators/rds.py index a0ab45d946846..0ef2462b04f33 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/rds.py +++ b/providers/src/airflow/providers/amazon/aws/operators/rds.py @@ -18,9 +18,10 @@ from __future__ import annotations import json +from collections.abc import Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/operators/redshift_cluster.py b/providers/src/airflow/providers/amazon/aws/operators/redshift_cluster.py index 4666445f96d9a..397e3995a0cdb 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/redshift_cluster.py +++ b/providers/src/airflow/providers/amazon/aws/operators/redshift_cluster.py @@ -17,8 +17,9 @@ from __future__ import annotations import time +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/operators/s3.py b/providers/src/airflow/providers/amazon/aws/operators/s3.py index 6ab2ba6750892..05c5bd88634b3 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/s3.py +++ b/providers/src/airflow/providers/amazon/aws/operators/s3.py @@ -21,8 +21,9 @@ import subprocess import sys +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING import pytz from dateutil import parser diff --git a/providers/src/airflow/providers/amazon/aws/operators/sagemaker.py b/providers/src/airflow/providers/amazon/aws/operators/sagemaker.py index e2fad21f09df3..3559f9fdf13aa 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/sagemaker.py +++ b/providers/src/airflow/providers/amazon/aws/operators/sagemaker.py @@ -19,8 +19,9 @@ import datetime import json import time +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, ClassVar, Sequence +from typing import TYPE_CHECKING, Any, Callable, ClassVar from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/operators/sns.py b/providers/src/airflow/providers/amazon/aws/operators/sns.py index 05b01c5849c21..c8a29355edbe2 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/sns.py +++ b/providers/src/airflow/providers/amazon/aws/operators/sns.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.amazon.aws.hooks.sns import SnsHook from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/operators/sqs.py b/providers/src/airflow/providers/amazon/aws/operators/sqs.py index 79444f8a57a97..dc453d0e6d1e4 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/sqs.py +++ b/providers/src/airflow/providers/amazon/aws/operators/sqs.py @@ -18,7 +18,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.amazon.aws.hooks.sqs import SqsHook from airflow.providers.amazon.aws.operators.base_aws import AwsBaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/operators/step_function.py b/providers/src/airflow/providers/amazon/aws/operators/step_function.py index e17aeeeae26fb..7556555443c60 100644 --- a/providers/src/airflow/providers/amazon/aws/operators/step_function.py +++ b/providers/src/airflow/providers/amazon/aws/operators/step_function.py @@ -17,8 +17,9 @@ from __future__ import annotations import json +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/athena.py b/providers/src/airflow/providers/amazon/aws/sensors/athena.py index 1dc8a4fe3335f..a0757f4807958 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/athena.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/athena.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.providers.amazon.aws.sensors.base_aws import AwsBaseSensor from airflow.providers.amazon.aws.utils.mixins import aws_template_fields diff --git a/providers/src/airflow/providers/amazon/aws/sensors/base_aws.py b/providers/src/airflow/providers/amazon/aws/sensors/base_aws.py index af9641aa2b38b..5c36a74cade82 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/base_aws.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/base_aws.py @@ -17,7 +17,7 @@ from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from airflow.providers.amazon.aws.utils.mixins import ( AwsBaseHookMixin, diff --git a/providers/src/airflow/providers/amazon/aws/sensors/batch.py b/providers/src/airflow/providers/amazon/aws/sensors/batch.py index 3d0c7799bf519..2fed9d345000e 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/batch.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/batch.py @@ -16,9 +16,10 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/bedrock.py b/providers/src/airflow/providers/amazon/aws/sensors/bedrock.py index e9157ab9c12a7..541702f4774d0 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/bedrock.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/bedrock.py @@ -18,7 +18,8 @@ from __future__ import annotations import abc -from typing import TYPE_CHECKING, Any, Sequence, TypeVar +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, TypeVar from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/cloud_formation.py b/providers/src/airflow/providers/amazon/aws/sensors/cloud_formation.py index ba07433bf0c80..6b5c7fa08a130 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/cloud_formation.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/cloud_formation.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.amazon.aws.sensors.base_aws import AwsBaseSensor from airflow.providers.amazon.aws.utils.mixins import aws_template_fields diff --git a/providers/src/airflow/providers/amazon/aws/sensors/comprehend.py b/providers/src/airflow/providers/amazon/aws/sensors/comprehend.py index 545f7b02fc8dc..0a246f9bc793d 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/comprehend.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/comprehend.py @@ -17,7 +17,8 @@ from __future__ import annotations import abc -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/dms.py b/providers/src/airflow/providers/amazon/aws/sensors/dms.py index 11867cb538d20..073d6b975d4b2 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/dms.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/dms.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.dms import DmsHook diff --git a/providers/src/airflow/providers/amazon/aws/sensors/dynamodb.py b/providers/src/airflow/providers/amazon/aws/sensors/dynamodb.py index ead8c123a621a..bc0f7bc979da1 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/dynamodb.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/dynamodb.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING, Any from botocore.exceptions import ClientError diff --git a/providers/src/airflow/providers/amazon/aws/sensors/ec2.py b/providers/src/airflow/providers/amazon/aws/sensors/ec2.py index 0736c63393ae7..fa2b638e72966 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/ec2.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/ec2.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/ecs.py b/providers/src/airflow/providers/amazon/aws/sensors/ecs.py index 049ed8227528d..3e121354f8b2a 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/ecs.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/ecs.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.ecs import ( diff --git a/providers/src/airflow/providers/amazon/aws/sensors/eks.py b/providers/src/airflow/providers/amazon/aws/sensors/eks.py index 79e160b007402..117d427b0f82b 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/eks.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/eks.py @@ -19,8 +19,9 @@ from __future__ import annotations from abc import abstractmethod +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.eks import ( diff --git a/providers/src/airflow/providers/amazon/aws/sensors/emr.py b/providers/src/airflow/providers/amazon/aws/sensors/emr.py index 50c9a836d96a1..1a7a2572d45c6 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/emr.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/emr.py @@ -17,9 +17,10 @@ # under the License. from __future__ import annotations +from collections.abc import Iterable, Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, Iterable, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import ( diff --git a/providers/src/airflow/providers/amazon/aws/sensors/glacier.py b/providers/src/airflow/providers/amazon/aws/sensors/glacier.py index eb87d8a51a21f..f36a0d701f070 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/glacier.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/glacier.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from enum import Enum -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.glacier import GlacierHook diff --git a/providers/src/airflow/providers/amazon/aws/sensors/glue.py b/providers/src/airflow/providers/amazon/aws/sensors/glue.py index 1209a782afcd5..41d25b5ae41b1 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/glue.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/glue.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/glue_catalog_partition.py b/providers/src/airflow/providers/amazon/aws/sensors/glue_catalog_partition.py index 0171644dfa31c..2e93a56cedd87 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/glue_catalog_partition.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/glue_catalog_partition.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/glue_crawler.py b/providers/src/airflow/providers/amazon/aws/sensors/glue_crawler.py index c1aea4af58a54..a68f643864091 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/glue_crawler.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/glue_crawler.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.glue_crawler import GlueCrawlerHook diff --git a/providers/src/airflow/providers/amazon/aws/sensors/kinesis_analytics.py b/providers/src/airflow/providers/amazon/aws/sensors/kinesis_analytics.py index 673445e67d5f9..1817dff340643 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/kinesis_analytics.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/kinesis_analytics.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/lambda_function.py b/providers/src/airflow/providers/amazon/aws/sensors/lambda_function.py index 8e01d40235ec8..8fc4d35358b93 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/lambda_function.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/lambda_function.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.lambda_function import LambdaHook diff --git a/providers/src/airflow/providers/amazon/aws/sensors/opensearch_serverless.py b/providers/src/airflow/providers/amazon/aws/sensors/opensearch_serverless.py index 0f539f9bfb82d..004a8cb7f434e 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/opensearch_serverless.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/opensearch_serverless.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/quicksight.py b/providers/src/airflow/providers/amazon/aws/sensors/quicksight.py index b0a9477706c57..03ca32dae2609 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/quicksight.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/quicksight.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.quicksight import QuickSightHook diff --git a/providers/src/airflow/providers/amazon/aws/sensors/rds.py b/providers/src/airflow/providers/amazon/aws/sensors/rds.py index a7566a8abcd63..b1d165617546d 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/rds.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/rds.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowNotFoundException from airflow.providers.amazon.aws.hooks.rds import RdsHook diff --git a/providers/src/airflow/providers/amazon/aws/sensors/redshift_cluster.py b/providers/src/airflow/providers/amazon/aws/sensors/redshift_cluster.py index 11ff83123022a..2f86e4dc0bab3 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/redshift_cluster.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/redshift_cluster.py @@ -16,9 +16,10 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/s3.py b/providers/src/airflow/providers/amazon/aws/sensors/s3.py index fd0d70a648466..bb3616597d272 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/s3.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/s3.py @@ -21,9 +21,10 @@ import inspect import os import re +from collections.abc import Sequence from datetime import datetime, timedelta from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Sequence, cast +from typing import TYPE_CHECKING, Any, Callable, cast from airflow.configuration import conf from airflow.providers.amazon.aws.utils import validate_execute_complete_event diff --git a/providers/src/airflow/providers/amazon/aws/sensors/sagemaker.py b/providers/src/airflow/providers/amazon/aws/sensors/sagemaker.py index 5863de92d9339..4a45e6ebb4e72 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/sagemaker.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/sagemaker.py @@ -17,8 +17,9 @@ from __future__ import annotations import time +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.sagemaker import LogState, SageMakerHook diff --git a/providers/src/airflow/providers/amazon/aws/sensors/sqs.py b/providers/src/airflow/providers/amazon/aws/sensors/sqs.py index 99991c83ceb58..006c5bf2ad20b 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/sqs.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/sqs.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Collection, Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Collection, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/amazon/aws/sensors/step_function.py b/providers/src/airflow/providers/amazon/aws/sensors/step_function.py index d4e58e2177c18..7492172c0f88d 100644 --- a/providers/src/airflow/providers/amazon/aws/sensors/step_function.py +++ b/providers/src/airflow/providers/amazon/aws/sensors/step_function.py @@ -17,7 +17,8 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.step_function import StepFunctionHook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/azure_blob_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/azure_blob_to_s3.py index 9af93e212b394..60a09bdc33f4c 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/azure_blob_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/azure_blob_to_s3.py @@ -19,7 +19,8 @@ import os import tempfile -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/base.py b/providers/src/airflow/providers/amazon/aws/transfers/base.py index 50458bb1631dd..f05f3c5c68000 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/base.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/base.py @@ -19,7 +19,7 @@ from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/dynamodb_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/dynamodb_to_s3.py index f7670cfd83713..d7e7a9e967cc5 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/dynamodb_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/dynamodb_to_s3.py @@ -20,12 +20,13 @@ import json import os +from collections.abc import Sequence from copy import copy from datetime import datetime from decimal import Decimal from functools import cached_property from tempfile import NamedTemporaryFile -from typing import IO, TYPE_CHECKING, Any, Callable, Sequence +from typing import IO, TYPE_CHECKING, Any, Callable from uuid import uuid4 from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/exasol_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/exasol_to_s3.py index ea17b77db6cc4..a0f1816c77836 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/exasol_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/exasol_to_s3.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/ftp_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/ftp_to_s3.py index 3f7c71d3113ff..9b6f7ea4a1027 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/ftp_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/ftp_to_s3.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py index edfbeaa2a239d..c4ead1b58a78f 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py @@ -20,7 +20,8 @@ from __future__ import annotations import os -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from packaging.version import Version diff --git a/providers/src/airflow/providers/amazon/aws/transfers/glacier_to_gcs.py b/providers/src/airflow/providers/amazon/aws/transfers/glacier_to_gcs.py index 469f2c385d2de..966afec02a788 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/glacier_to_gcs.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/glacier_to_gcs.py @@ -18,7 +18,8 @@ from __future__ import annotations import tempfile -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.glacier import GlacierHook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/google_api_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/google_api_to_s3.py index d3a020c993143..050cc296382d2 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/google_api_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/google_api_to_s3.py @@ -21,7 +21,8 @@ import json import sys -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.models.xcom import MAX_XCOM_SIZE, XCOM_RETURN_KEY diff --git a/providers/src/airflow/providers/amazon/aws/transfers/hive_to_dynamodb.py b/providers/src/airflow/providers/amazon/aws/transfers/hive_to_dynamodb.py index 3da7b506bb9cb..444591875aceb 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/hive_to_dynamodb.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/hive_to_dynamodb.py @@ -20,7 +20,8 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Callable from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.dynamodb import DynamoDBHook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/imap_attachment_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/imap_attachment_to_s3.py index aff83eb889101..cf1b96bfa2e7d 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/imap_attachment_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/imap_attachment_to_s3.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/local_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/local_to_s3.py index 144ce274577b2..aa6678af6b8f7 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/local_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/local_to_s3.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/mongo_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/mongo_to_s3.py index fdefaf6307fff..1dc32fb6ed71d 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/mongo_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/mongo_to_s3.py @@ -18,7 +18,8 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING, Any, Iterable, Sequence, cast +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING, Any, cast from bson import json_util diff --git a/providers/src/airflow/providers/amazon/aws/transfers/redshift_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/redshift_to_s3.py index 0ed59e3db7e8e..8d82253f9de58 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/redshift_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/redshift_to_s3.py @@ -20,7 +20,8 @@ from __future__ import annotations import re -from typing import TYPE_CHECKING, Iterable, Mapping, Sequence +from collections.abc import Iterable, Mapping, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py index 57b18299a80d6..f3e7291e142eb 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Literal, Sequence, TypedDict +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Literal, TypedDict from botocore.exceptions import ClientError, WaiterError diff --git a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_ftp.py b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_ftp.py index 9a15772310747..ee7dd0306b768 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_ftp.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_ftp.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_redshift.py b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_redshift.py index df040b19eafac..e6c21af18b54a 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_redshift.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_redshift.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_sftp.py b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_sftp.py index bd2b8c937e4b3..7abf300844bab 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_sftp.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_sftp.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from urllib.parse import urlsplit from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_sql.py b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_sql.py index bc6e9ec757dde..16250d2f78ece 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/s3_to_sql.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/s3_to_sql.py @@ -16,9 +16,10 @@ # under the License. from __future__ import annotations +from collections.abc import Iterable, Sequence from functools import cached_property from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Callable, Iterable, Sequence +from typing import TYPE_CHECKING, Callable from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/salesforce_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/salesforce_to_s3.py index 1c35c86af85be..79bdfb983f8a3 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/salesforce_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/salesforce_to_s3.py @@ -18,7 +18,8 @@ import os import tempfile -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/amazon/aws/transfers/sftp_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/sftp_to_s3.py index 322110dadba5d..e44741dca9b2a 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/sftp_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/sftp_to_s3.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from urllib.parse import urlsplit from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/amazon/aws/transfers/sql_to_s3.py b/providers/src/airflow/providers/amazon/aws/transfers/sql_to_s3.py index 19bc7f016b186..8443bcaf6963f 100644 --- a/providers/src/airflow/providers/amazon/aws/transfers/sql_to_s3.py +++ b/providers/src/airflow/providers/amazon/aws/transfers/sql_to_s3.py @@ -19,8 +19,9 @@ import enum from collections import namedtuple +from collections.abc import Iterable, Mapping, Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Any, Iterable, Mapping, Sequence, cast +from typing import TYPE_CHECKING, Any, cast from typing_extensions import Literal diff --git a/providers/src/airflow/providers/amazon/aws/triggers/base.py b/providers/src/airflow/providers/amazon/aws/triggers/base.py index 9b2e8696e43a9..eac4a8c56e138 100644 --- a/providers/src/airflow/providers/amazon/aws/triggers/base.py +++ b/providers/src/airflow/providers/amazon/aws/triggers/base.py @@ -18,7 +18,8 @@ from __future__ import annotations from abc import abstractmethod -from typing import TYPE_CHECKING, Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import TYPE_CHECKING, Any from airflow.providers.amazon.aws.utils.waiter_with_logging import async_wait from airflow.triggers.base import BaseTrigger, TriggerEvent diff --git a/providers/src/airflow/providers/amazon/aws/triggers/glue.py b/providers/src/airflow/providers/amazon/aws/triggers/glue.py index c4b0c38c66dfe..ad7b3945be5d0 100644 --- a/providers/src/airflow/providers/amazon/aws/triggers/glue.py +++ b/providers/src/airflow/providers/amazon/aws/triggers/glue.py @@ -18,8 +18,9 @@ from __future__ import annotations import asyncio +from collections.abc import AsyncIterator from functools import cached_property -from typing import TYPE_CHECKING, Any, AsyncIterator +from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from airflow.providers.amazon.aws.hooks.base_aws import AwsGenericHook diff --git a/providers/src/airflow/providers/amazon/aws/triggers/redshift_cluster.py b/providers/src/airflow/providers/amazon/aws/triggers/redshift_cluster.py index 0fd55e322e5aa..ad299595bf823 100644 --- a/providers/src/airflow/providers/amazon/aws/triggers/redshift_cluster.py +++ b/providers/src/airflow/providers/amazon/aws/triggers/redshift_cluster.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import TYPE_CHECKING, Any from airflow.providers.amazon.aws.hooks.redshift_cluster import RedshiftHook from airflow.providers.amazon.aws.triggers.base import AwsBaseWaiterTrigger diff --git a/providers/src/airflow/providers/amazon/aws/triggers/redshift_data.py b/providers/src/airflow/providers/amazon/aws/triggers/redshift_data.py index 9ff5ea9aa33b6..51e16179b3cdb 100644 --- a/providers/src/airflow/providers/amazon/aws/triggers/redshift_data.py +++ b/providers/src/airflow/providers/amazon/aws/triggers/redshift_data.py @@ -18,8 +18,9 @@ from __future__ import annotations import asyncio +from collections.abc import AsyncIterator from functools import cached_property -from typing import Any, AsyncIterator +from typing import Any from airflow.providers.amazon.aws.hooks.redshift_data import ( ABORTED_STATE, diff --git a/providers/src/airflow/providers/amazon/aws/triggers/s3.py b/providers/src/airflow/providers/amazon/aws/triggers/s3.py index adecde9aa1bbc..0be6c992cc8b6 100644 --- a/providers/src/airflow/providers/amazon/aws/triggers/s3.py +++ b/providers/src/airflow/providers/amazon/aws/triggers/s3.py @@ -17,8 +17,9 @@ from __future__ import annotations import asyncio +from collections.abc import AsyncIterator from functools import cached_property -from typing import TYPE_CHECKING, Any, AsyncIterator +from typing import TYPE_CHECKING, Any from airflow.providers.amazon.aws.hooks.s3 import S3Hook from airflow.triggers.base import BaseTrigger, TriggerEvent diff --git a/providers/src/airflow/providers/amazon/aws/triggers/sagemaker.py b/providers/src/airflow/providers/amazon/aws/triggers/sagemaker.py index 5ac6ea1abbacf..5f6350473f009 100644 --- a/providers/src/airflow/providers/amazon/aws/triggers/sagemaker.py +++ b/providers/src/airflow/providers/amazon/aws/triggers/sagemaker.py @@ -19,9 +19,10 @@ import asyncio from collections import Counter +from collections.abc import AsyncIterator from enum import IntEnum from functools import cached_property -from typing import Any, AsyncIterator +from typing import Any from botocore.exceptions import WaiterError diff --git a/providers/src/airflow/providers/amazon/aws/triggers/sqs.py b/providers/src/airflow/providers/amazon/aws/triggers/sqs.py index 562ae36f51bfe..31f344b998209 100644 --- a/providers/src/airflow/providers/amazon/aws/triggers/sqs.py +++ b/providers/src/airflow/providers/amazon/aws/triggers/sqs.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Any, AsyncIterator, Collection +from collections.abc import AsyncIterator, Collection +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.sqs import SqsHook diff --git a/providers/src/airflow/providers/amazon/aws/utils/task_log_fetcher.py b/providers/src/airflow/providers/amazon/aws/utils/task_log_fetcher.py index 5a344b507e8ce..a5fd8af3ba1d7 100644 --- a/providers/src/airflow/providers/amazon/aws/utils/task_log_fetcher.py +++ b/providers/src/airflow/providers/amazon/aws/utils/task_log_fetcher.py @@ -18,9 +18,10 @@ from __future__ import annotations import time +from collections.abc import Generator from datetime import datetime, timedelta, timezone from threading import Event, Thread -from typing import TYPE_CHECKING, Generator +from typing import TYPE_CHECKING from botocore.exceptions import ClientError, ConnectionClosedError diff --git a/providers/src/airflow/providers/apache/beam/operators/beam.py b/providers/src/airflow/providers/apache/beam/operators/beam.py index 65f23336589d2..2d7942ff4218f 100644 --- a/providers/src/airflow/providers/apache/beam/operators/beam.py +++ b/providers/src/airflow/providers/apache/beam/operators/beam.py @@ -26,10 +26,11 @@ import stat import tempfile from abc import ABC, ABCMeta, abstractmethod +from collections.abc import Sequence from concurrent.futures import ThreadPoolExecutor, as_completed from contextlib import ExitStack from functools import partial -from typing import IO, TYPE_CHECKING, Any, Callable, Sequence +from typing import IO, TYPE_CHECKING, Any, Callable from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/apache/beam/triggers/beam.py b/providers/src/airflow/providers/apache/beam/triggers/beam.py index b160218f737e0..67adcbeccf3c1 100644 --- a/providers/src/airflow/providers/apache/beam/triggers/beam.py +++ b/providers/src/airflow/providers/apache/beam/triggers/beam.py @@ -18,7 +18,8 @@ import asyncio import contextlib -from typing import IO, Any, AsyncIterator, Sequence +from collections.abc import AsyncIterator, Sequence +from typing import IO, Any from deprecated import deprecated from google.cloud.dataflow_v1beta3 import ListJobsRequest diff --git a/providers/src/airflow/providers/apache/cassandra/sensors/record.py b/providers/src/airflow/providers/apache/cassandra/sensors/record.py index bcd417d49c7d3..e971179765142 100644 --- a/providers/src/airflow/providers/apache/cassandra/sensors/record.py +++ b/providers/src/airflow/providers/apache/cassandra/sensors/record.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.providers.apache.cassandra.hooks.cassandra import CassandraHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/apache/cassandra/sensors/table.py b/providers/src/airflow/providers/apache/cassandra/sensors/table.py index 1ee99f687693f..5f816de907ecb 100644 --- a/providers/src/airflow/providers/apache/cassandra/sensors/table.py +++ b/providers/src/airflow/providers/apache/cassandra/sensors/table.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.providers.apache.cassandra.hooks.cassandra import CassandraHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/apache/drill/hooks/drill.py b/providers/src/airflow/providers/apache/drill/hooks/drill.py index 1d1b2bbfb04b8..fec3ae7f0f1d5 100644 --- a/providers/src/airflow/providers/apache/drill/hooks/drill.py +++ b/providers/src/airflow/providers/apache/drill/hooks/drill.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING, Any from sqlalchemy import create_engine diff --git a/providers/src/airflow/providers/apache/drill/operators/drill.py b/providers/src/airflow/providers/apache/drill/operators/drill.py index edf9d0f735902..f3b34962044db 100644 --- a/providers/src/airflow/providers/apache/drill/operators/drill.py +++ b/providers/src/airflow/providers/apache/drill/operators/drill.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import ClassVar, Sequence +from collections.abc import Sequence +from typing import ClassVar from deprecated import deprecated diff --git a/providers/src/airflow/providers/apache/druid/hooks/druid.py b/providers/src/airflow/providers/apache/druid/hooks/druid.py index c865adef412fb..c44a6be346e4a 100644 --- a/providers/src/airflow/providers/apache/druid/hooks/druid.py +++ b/providers/src/airflow/providers/apache/druid/hooks/druid.py @@ -18,9 +18,10 @@ from __future__ import annotations import time +from collections.abc import Iterable from enum import Enum from functools import cached_property -from typing import TYPE_CHECKING, Any, Iterable +from typing import TYPE_CHECKING, Any import requests from pydruid.db import connect diff --git a/providers/src/airflow/providers/apache/druid/operators/druid.py b/providers/src/airflow/providers/apache/druid/operators/druid.py index 71ad409cb960a..6867488028d29 100644 --- a/providers/src/airflow/providers/apache/druid/operators/druid.py +++ b/providers/src/airflow/providers/apache/druid/operators/druid.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.apache.druid.hooks.druid import DruidHook, IngestionType diff --git a/providers/src/airflow/providers/apache/druid/transfers/hive_to_druid.py b/providers/src/airflow/providers/apache/druid/transfers/hive_to_druid.py index 7ae50a25148d8..1e5280eedfe4c 100644 --- a/providers/src/airflow/providers/apache/druid/transfers/hive_to_druid.py +++ b/providers/src/airflow/providers/apache/druid/transfers/hive_to_druid.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.apache.druid.hooks.druid import DruidHook diff --git a/providers/src/airflow/providers/apache/flink/operators/flink_kubernetes.py b/providers/src/airflow/providers/apache/flink/operators/flink_kubernetes.py index b0b203df5107c..ed05397ec98a2 100644 --- a/providers/src/airflow/providers/apache/flink/operators/flink_kubernetes.py +++ b/providers/src/airflow/providers/apache/flink/operators/flink_kubernetes.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.cncf.kubernetes.hooks.kubernetes import KubernetesHook diff --git a/providers/src/airflow/providers/apache/flink/sensors/flink_kubernetes.py b/providers/src/airflow/providers/apache/flink/sensors/flink_kubernetes.py index 39cc7ea8c59bf..e54317f930781 100644 --- a/providers/src/airflow/providers/apache/flink/sensors/flink_kubernetes.py +++ b/providers/src/airflow/providers/apache/flink/sensors/flink_kubernetes.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from kubernetes import client diff --git a/providers/src/airflow/providers/apache/hdfs/sensors/web_hdfs.py b/providers/src/airflow/providers/apache/hdfs/sensors/web_hdfs.py index 14f622e6efedc..8b951bf3ec835 100644 --- a/providers/src/airflow/providers/apache/hdfs/sensors/web_hdfs.py +++ b/providers/src/airflow/providers/apache/hdfs/sensors/web_hdfs.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/apache/hive/operators/hive.py b/providers/src/airflow/providers/apache/hive/operators/hive.py index aedcb7eded724..e87674a552184 100644 --- a/providers/src/airflow/providers/apache/hive/operators/hive.py +++ b/providers/src/airflow/providers/apache/hive/operators/hive.py @@ -19,8 +19,9 @@ import os import re +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/apache/hive/operators/hive_stats.py b/providers/src/airflow/providers/apache/hive/operators/hive_stats.py index 139c0980f47db..9b5daf1f64376 100644 --- a/providers/src/airflow/providers/apache/hive/operators/hive_stats.py +++ b/providers/src/airflow/providers/apache/hive/operators/hive_stats.py @@ -18,7 +18,8 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/apache/hive/sensors/hive_partition.py b/providers/src/airflow/providers/apache/hive/sensors/hive_partition.py index d839bb444fcbd..08d52b6e02334 100644 --- a/providers/src/airflow/providers/apache/hive/sensors/hive_partition.py +++ b/providers/src/airflow/providers/apache/hive/sensors/hive_partition.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.providers.apache.hive.hooks.hive import HiveMetastoreHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/apache/hive/sensors/metastore_partition.py b/providers/src/airflow/providers/apache/hive/sensors/metastore_partition.py index f059d49fc62da..7f2d7dafe3159 100644 --- a/providers/src/airflow/providers/apache/hive/sensors/metastore_partition.py +++ b/providers/src/airflow/providers/apache/hive/sensors/metastore_partition.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.providers.common.sql.sensors.sql import SqlSensor diff --git a/providers/src/airflow/providers/apache/hive/sensors/named_hive_partition.py b/providers/src/airflow/providers/apache/hive/sensors/named_hive_partition.py index 3b78847d33b5f..c18388477de9f 100644 --- a/providers/src/airflow/providers/apache/hive/sensors/named_hive_partition.py +++ b/providers/src/airflow/providers/apache/hive/sensors/named_hive_partition.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/apache/hive/transfers/hive_to_mysql.py b/providers/src/airflow/providers/apache/hive/transfers/hive_to_mysql.py index 47aa9623bef56..e2d80dc0701d2 100644 --- a/providers/src/airflow/providers/apache/hive/transfers/hive_to_mysql.py +++ b/providers/src/airflow/providers/apache/hive/transfers/hive_to_mysql.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.apache.hive.hooks.hive import HiveServer2Hook diff --git a/providers/src/airflow/providers/apache/hive/transfers/hive_to_samba.py b/providers/src/airflow/providers/apache/hive/transfers/hive_to_samba.py index edfa6bf8b9368..50b1f669bc8dc 100644 --- a/providers/src/airflow/providers/apache/hive/transfers/hive_to_samba.py +++ b/providers/src/airflow/providers/apache/hive/transfers/hive_to_samba.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.apache.hive.hooks.hive import HiveServer2Hook diff --git a/providers/src/airflow/providers/apache/hive/transfers/mssql_to_hive.py b/providers/src/airflow/providers/apache/hive/transfers/mssql_to_hive.py index 79b5dae27ac3a..da296bd8edefb 100644 --- a/providers/src/airflow/providers/apache/hive/transfers/mssql_to_hive.py +++ b/providers/src/airflow/providers/apache/hive/transfers/mssql_to_hive.py @@ -20,8 +20,9 @@ from __future__ import annotations import csv +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING import pymssql diff --git a/providers/src/airflow/providers/apache/hive/transfers/mysql_to_hive.py b/providers/src/airflow/providers/apache/hive/transfers/mysql_to_hive.py index 5fca8ef0ccadd..8a21dd8cc39de 100644 --- a/providers/src/airflow/providers/apache/hive/transfers/mysql_to_hive.py +++ b/providers/src/airflow/providers/apache/hive/transfers/mysql_to_hive.py @@ -20,9 +20,10 @@ from __future__ import annotations import csv +from collections.abc import Sequence from contextlib import closing from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING try: import MySQLdb diff --git a/providers/src/airflow/providers/apache/hive/transfers/s3_to_hive.py b/providers/src/airflow/providers/apache/hive/transfers/s3_to_hive.py index e56a244f71a21..7eaf9dc1ac837 100644 --- a/providers/src/airflow/providers/apache/hive/transfers/s3_to_hive.py +++ b/providers/src/airflow/providers/apache/hive/transfers/s3_to_hive.py @@ -289,8 +289,9 @@ def uncompress_file(input_file_name, file_extension, dest_dir): fmodule = gzip.GzipFile elif file_extension.lower() == ".bz2": fmodule = bz2.BZ2File - with fmodule(input_file_name, mode="rb") as f_compressed, NamedTemporaryFile( - dir=dest_dir, mode="wb", delete=False - ) as f_uncompressed: + with ( + fmodule(input_file_name, mode="rb") as f_compressed, + NamedTemporaryFile(dir=dest_dir, mode="wb", delete=False) as f_uncompressed, + ): shutil.copyfileobj(f_compressed, f_uncompressed) return f_uncompressed.name diff --git a/providers/src/airflow/providers/apache/hive/transfers/vertica_to_hive.py b/providers/src/airflow/providers/apache/hive/transfers/vertica_to_hive.py index 415e51de76a1b..3a3fb63c2df54 100644 --- a/providers/src/airflow/providers/apache/hive/transfers/vertica_to_hive.py +++ b/providers/src/airflow/providers/apache/hive/transfers/vertica_to_hive.py @@ -20,8 +20,9 @@ from __future__ import annotations import csv +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.apache.hive.hooks.hive import HiveCliHook diff --git a/providers/src/airflow/providers/apache/kafka/hooks/client.py b/providers/src/airflow/providers/apache/kafka/hooks/client.py index abe503c3f6554..8df7760473768 100644 --- a/providers/src/airflow/providers/apache/kafka/hooks/client.py +++ b/providers/src/airflow/providers/apache/kafka/hooks/client.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from confluent_kafka import KafkaException from confluent_kafka.admin import NewTopic diff --git a/providers/src/airflow/providers/apache/kafka/hooks/consume.py b/providers/src/airflow/providers/apache/kafka/hooks/consume.py index 9e0d0f2454b66..014798910d06c 100644 --- a/providers/src/airflow/providers/apache/kafka/hooks/consume.py +++ b/providers/src/airflow/providers/apache/kafka/hooks/consume.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from confluent_kafka import Consumer diff --git a/providers/src/airflow/providers/apache/kafka/operators/consume.py b/providers/src/airflow/providers/apache/kafka/operators/consume.py index 377b58a46df5e..0a9d9a9d1c6d7 100644 --- a/providers/src/airflow/providers/apache/kafka/operators/consume.py +++ b/providers/src/airflow/providers/apache/kafka/operators/consume.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import partial -from typing import Any, Callable, Sequence +from typing import Any, Callable from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/apache/kafka/operators/produce.py b/providers/src/airflow/providers/apache/kafka/operators/produce.py index e0623128a1f7d..6c538615eafa9 100644 --- a/providers/src/airflow/providers/apache/kafka/operators/produce.py +++ b/providers/src/airflow/providers/apache/kafka/operators/produce.py @@ -17,8 +17,9 @@ from __future__ import annotations import logging +from collections.abc import Sequence from functools import partial -from typing import Any, Callable, Sequence +from typing import Any, Callable from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/apache/kafka/sensors/kafka.py b/providers/src/airflow/providers/apache/kafka/sensors/kafka.py index c88e1b3bd0b9f..9c545cd2ee6c5 100644 --- a/providers/src/airflow/providers/apache/kafka/sensors/kafka.py +++ b/providers/src/airflow/providers/apache/kafka/sensors/kafka.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import Any, Callable, Sequence +from collections.abc import Sequence +from typing import Any, Callable from airflow.models import BaseOperator from airflow.providers.apache.kafka.triggers.await_message import AwaitMessageTrigger diff --git a/providers/src/airflow/providers/apache/kafka/triggers/await_message.py b/providers/src/airflow/providers/apache/kafka/triggers/await_message.py index ce869846fde8b..d4e140c151f92 100644 --- a/providers/src/airflow/providers/apache/kafka/triggers/await_message.py +++ b/providers/src/airflow/providers/apache/kafka/triggers/await_message.py @@ -17,8 +17,9 @@ from __future__ import annotations import asyncio +from collections.abc import Sequence from functools import partial -from typing import Any, Sequence +from typing import Any from asgiref.sync import sync_to_async diff --git a/providers/src/airflow/providers/apache/kylin/operators/kylin_cube.py b/providers/src/airflow/providers/apache/kylin/operators/kylin_cube.py index a4a6f0a750365..01b98995802d4 100644 --- a/providers/src/airflow/providers/apache/kylin/operators/kylin_cube.py +++ b/providers/src/airflow/providers/apache/kylin/operators/kylin_cube.py @@ -18,8 +18,9 @@ from __future__ import annotations import time +from collections.abc import Sequence from datetime import datetime -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from kylinpy import kylinpy diff --git a/providers/src/airflow/providers/apache/livy/hooks/livy.py b/providers/src/airflow/providers/apache/livy/hooks/livy.py index 7cf6184aea15c..3eec9599457fe 100644 --- a/providers/src/airflow/providers/apache/livy/hooks/livy.py +++ b/providers/src/airflow/providers/apache/livy/hooks/livy.py @@ -21,8 +21,9 @@ import asyncio import json import re +from collections.abc import Sequence from enum import Enum -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any import aiohttp import requests diff --git a/providers/src/airflow/providers/apache/livy/operators/livy.py b/providers/src/airflow/providers/apache/livy/operators/livy.py index 789deb230529f..1390b46a7ad1b 100644 --- a/providers/src/airflow/providers/apache/livy/operators/livy.py +++ b/providers/src/airflow/providers/apache/livy/operators/livy.py @@ -19,8 +19,9 @@ from __future__ import annotations import time +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from deprecated.classic import deprecated diff --git a/providers/src/airflow/providers/apache/livy/sensors/livy.py b/providers/src/airflow/providers/apache/livy/sensors/livy.py index d14c112403ed3..3c1a50255ad7a 100644 --- a/providers/src/airflow/providers/apache/livy/sensors/livy.py +++ b/providers/src/airflow/providers/apache/livy/sensors/livy.py @@ -18,7 +18,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.providers.apache.livy.hooks.livy import LivyHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/apache/livy/triggers/livy.py b/providers/src/airflow/providers/apache/livy/triggers/livy.py index 423b49b8cc359..2e40b26113ed1 100644 --- a/providers/src/airflow/providers/apache/livy/triggers/livy.py +++ b/providers/src/airflow/providers/apache/livy/triggers/livy.py @@ -20,8 +20,9 @@ from __future__ import annotations import asyncio +from collections.abc import AsyncIterator from datetime import datetime, timedelta, timezone -from typing import Any, AsyncIterator +from typing import Any from airflow.providers.apache.livy.hooks.livy import BatchState, LivyAsyncHook from airflow.triggers.base import BaseTrigger, TriggerEvent diff --git a/providers/src/airflow/providers/apache/pig/operators/pig.py b/providers/src/airflow/providers/apache/pig/operators/pig.py index 2df5cc5d189ea..30359cb9c231d 100644 --- a/providers/src/airflow/providers/apache/pig/operators/pig.py +++ b/providers/src/airflow/providers/apache/pig/operators/pig.py @@ -18,7 +18,8 @@ from __future__ import annotations import re -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.apache.pig.hooks.pig import PigCliHook diff --git a/providers/src/airflow/providers/apache/pinot/hooks/pinot.py b/providers/src/airflow/providers/apache/pinot/hooks/pinot.py index a9c8a6de40d1e..7b4c95a3b8374 100644 --- a/providers/src/airflow/providers/apache/pinot/hooks/pinot.py +++ b/providers/src/airflow/providers/apache/pinot/hooks/pinot.py @@ -19,7 +19,8 @@ import os import subprocess -from typing import TYPE_CHECKING, Any, Iterable, Mapping +from collections.abc import Iterable, Mapping +from typing import TYPE_CHECKING, Any from pinotdb import connect diff --git a/providers/src/airflow/providers/apache/spark/decorators/pyspark.py b/providers/src/airflow/providers/apache/spark/decorators/pyspark.py index c44d37d0e092d..beccda5ed57a8 100644 --- a/providers/src/airflow/providers/apache/spark/decorators/pyspark.py +++ b/providers/src/airflow/providers/apache/spark/decorators/pyspark.py @@ -18,7 +18,8 @@ from __future__ import annotations import inspect -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.decorators.base import DecoratedOperator, TaskDecorator, task_decorator_factory from airflow.hooks.base import BaseHook diff --git a/providers/src/airflow/providers/apache/spark/hooks/spark_submit.py b/providers/src/airflow/providers/apache/spark/hooks/spark_submit.py index 9889cf9473508..8a00062c2ec8a 100644 --- a/providers/src/airflow/providers/apache/spark/hooks/spark_submit.py +++ b/providers/src/airflow/providers/apache/spark/hooks/spark_submit.py @@ -26,8 +26,9 @@ import tempfile import time import uuid +from collections.abc import Iterator from pathlib import Path -from typing import Any, Iterator +from typing import Any from airflow.configuration import conf as airflow_conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/apache/spark/operators/spark_sql.py b/providers/src/airflow/providers/apache/spark/operators/spark_sql.py index d4e6fbc98cc18..ad535c62d5ef7 100644 --- a/providers/src/airflow/providers/apache/spark/operators/spark_sql.py +++ b/providers/src/airflow/providers/apache/spark/operators/spark_sql.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from deprecated import deprecated diff --git a/providers/src/airflow/providers/apache/spark/operators/spark_submit.py b/providers/src/airflow/providers/apache/spark/operators/spark_submit.py index 16f232dd02946..2f6668643cff2 100644 --- a/providers/src/airflow/providers/apache/spark/operators/spark_submit.py +++ b/providers/src/airflow/providers/apache/spark/operators/spark_submit.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.apache.spark.hooks.spark_submit import SparkSubmitHook diff --git a/providers/src/airflow/providers/apprise/hooks/apprise.py b/providers/src/airflow/providers/apprise/hooks/apprise.py index e9af695068670..4904e5100c64e 100644 --- a/providers/src/airflow/providers/apprise/hooks/apprise.py +++ b/providers/src/airflow/providers/apprise/hooks/apprise.py @@ -19,7 +19,8 @@ import json import warnings -from typing import TYPE_CHECKING, Any, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING, Any import apprise from apprise import AppriseConfig, NotifyFormat, NotifyType diff --git a/providers/src/airflow/providers/apprise/notifications/apprise.py b/providers/src/airflow/providers/apprise/notifications/apprise.py index 480f96638baf5..ddbb4ac9e1b73 100644 --- a/providers/src/airflow/providers/apprise/notifications/apprise.py +++ b/providers/src/airflow/providers/apprise/notifications/apprise.py @@ -18,8 +18,8 @@ from __future__ import annotations import warnings +from collections.abc import Iterable from functools import cached_property -from typing import Iterable from apprise import AppriseConfig, NotifyFormat, NotifyType diff --git a/providers/src/airflow/providers/arangodb/operators/arangodb.py b/providers/src/airflow/providers/arangodb/operators/arangodb.py index db8648a3c355b..ac6bfe67612dc 100644 --- a/providers/src/airflow/providers/arangodb/operators/arangodb.py +++ b/providers/src/airflow/providers/arangodb/operators/arangodb.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Callable from airflow.models import BaseOperator from airflow.providers.arangodb.hooks.arangodb import ArangoDBHook diff --git a/providers/src/airflow/providers/arangodb/sensors/arangodb.py b/providers/src/airflow/providers/arangodb/sensors/arangodb.py index fa2f0af2bfc16..042a2415fbe5c 100644 --- a/providers/src/airflow/providers/arangodb/sensors/arangodb.py +++ b/providers/src/airflow/providers/arangodb/sensors/arangodb.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.arangodb.hooks.arangodb import ArangoDBHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/atlassian/jira/operators/jira.py b/providers/src/airflow/providers/atlassian/jira/operators/jira.py index e703020e12e7b..fde6222c208a9 100644 --- a/providers/src/airflow/providers/atlassian/jira/operators/jira.py +++ b/providers/src/airflow/providers/atlassian/jira/operators/jira.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.models import BaseOperator from airflow.providers.atlassian.jira.hooks.jira import JiraHook diff --git a/providers/src/airflow/providers/atlassian/jira/sensors/jira.py b/providers/src/airflow/providers/atlassian/jira/sensors/jira.py index e5c2fa16bd63e..62e567b0c7d96 100644 --- a/providers/src/airflow/providers/atlassian/jira/sensors/jira.py +++ b/providers/src/airflow/providers/atlassian/jira/sensors/jira.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.providers.atlassian.jira.hooks.jira import JiraHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/celery/executors/celery_executor.py b/providers/src/airflow/providers/celery/executors/celery_executor.py index 43ae2cc213399..0f439836bef05 100644 --- a/providers/src/airflow/providers/celery/executors/celery_executor.py +++ b/providers/src/airflow/providers/celery/executors/celery_executor.py @@ -30,9 +30,10 @@ import operator import time from collections import Counter +from collections.abc import Sequence from concurrent.futures import ProcessPoolExecutor from multiprocessing import cpu_count -from typing import TYPE_CHECKING, Any, Optional, Sequence, Tuple +from typing import TYPE_CHECKING, Any, Optional from celery import states as celery_states from deprecated import deprecated @@ -75,7 +76,7 @@ # Task instance that is sent over Celery queues # TaskInstanceKey, Command, queue_name, CallableTask - TaskInstanceInCelery = Tuple[TaskInstanceKey, CommandType, Optional[str], Task] + TaskInstanceInCelery = tuple[TaskInstanceKey, CommandType, Optional[str], Task] # PEP562 diff --git a/providers/src/airflow/providers/celery/executors/celery_executor_utils.py b/providers/src/airflow/providers/celery/executors/celery_executor_utils.py index 28630dd1659b7..12ae2c91cc131 100644 --- a/providers/src/airflow/providers/celery/executors/celery_executor_utils.py +++ b/providers/src/airflow/providers/celery/executors/celery_executor_utils.py @@ -29,8 +29,9 @@ import subprocess import traceback import warnings +from collections.abc import Mapping, MutableMapping from concurrent.futures import ProcessPoolExecutor -from typing import TYPE_CHECKING, Any, Mapping, MutableMapping, Optional, Tuple +from typing import TYPE_CHECKING, Any, Optional from celery import Celery, Task, states as celery_states from celery.backends.base import BaseKeyValueStoreBackend @@ -59,7 +60,7 @@ from airflow.executors.base_executor import CommandType, EventBufferValueType from airflow.models.taskinstance import TaskInstanceKey - TaskInstanceInCelery = Tuple[TaskInstanceKey, CommandType, Optional[str], Task] + TaskInstanceInCelery = tuple[TaskInstanceKey, CommandType, Optional[str], Task] OPERATION_TIMEOUT = conf.getfloat("celery", "operation_timeout") diff --git a/providers/src/airflow/providers/celery/executors/celery_kubernetes_executor.py b/providers/src/airflow/providers/celery/executors/celery_kubernetes_executor.py index 3715a37d3d86d..680bcfb3d603e 100644 --- a/providers/src/airflow/providers/celery/executors/celery_kubernetes_executor.py +++ b/providers/src/airflow/providers/celery/executors/celery_kubernetes_executor.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from deprecated import deprecated diff --git a/providers/src/airflow/providers/cncf/kubernetes/decorators/kubernetes.py b/providers/src/airflow/providers/cncf/kubernetes/decorators/kubernetes.py index c3f5951540cb4..cce1ffa8d6c19 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/decorators/kubernetes.py +++ b/providers/src/airflow/providers/cncf/kubernetes/decorators/kubernetes.py @@ -20,9 +20,10 @@ import os import pickle import uuid +from collections.abc import Sequence from shlex import quote from tempfile import TemporaryDirectory -from typing import TYPE_CHECKING, Callable, Sequence +from typing import TYPE_CHECKING, Callable import dill from kubernetes.client import models as k8s diff --git a/providers/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py b/providers/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py index c465548fddf67..32f840f69b810 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py +++ b/providers/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py @@ -30,10 +30,11 @@ import multiprocessing import time from collections import Counter, defaultdict +from collections.abc import Sequence from contextlib import suppress from datetime import datetime from queue import Empty, Queue -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from deprecated import deprecated from kubernetes.dynamic import DynamicClient diff --git a/providers/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor_types.py b/providers/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor_types.py index 1e29861c6c456..bd4274025a8a9 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor_types.py +++ b/providers/src/airflow/providers/cncf/kubernetes/executors/kubernetes_executor_types.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union +from typing import TYPE_CHECKING, Any, Optional, Union ADOPTED = "adopted" if TYPE_CHECKING: @@ -25,13 +25,13 @@ from airflow.utils.state import TaskInstanceState # TaskInstance key, command, configuration, pod_template_file - KubernetesJobType = Tuple[TaskInstanceKey, CommandType, Any, Optional[str]] + KubernetesJobType = tuple[TaskInstanceKey, CommandType, Any, Optional[str]] # key, pod state, pod_name, namespace, resource_version - KubernetesResultsType = Tuple[TaskInstanceKey, Optional[Union[TaskInstanceState, str]], str, str, str] + KubernetesResultsType = tuple[TaskInstanceKey, Optional[Union[TaskInstanceState, str]], str, str, str] # pod_name, namespace, pod state, annotations, resource_version - KubernetesWatchType = Tuple[str, str, Optional[Union[TaskInstanceState, str]], Dict[str, str], str] + KubernetesWatchType = tuple[str, str, Optional[Union[TaskInstanceState, str]], dict[str, str], str] ALL_NAMESPACES = "ALL_NAMESPACES" POD_EXECUTOR_DONE_KEY = "airflow_executor_done" diff --git a/providers/src/airflow/providers/cncf/kubernetes/executors/local_kubernetes_executor.py b/providers/src/airflow/providers/cncf/kubernetes/executors/local_kubernetes_executor.py index fa1e584971ef5..cf7d784aa5c46 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/executors/local_kubernetes_executor.py +++ b/providers/src/airflow/providers/cncf/kubernetes/executors/local_kubernetes_executor.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from deprecated import deprecated diff --git a/providers/src/airflow/providers/cncf/kubernetes/hooks/kubernetes.py b/providers/src/airflow/providers/cncf/kubernetes/hooks/kubernetes.py index a810e8f9ed522..11c8bd71c9d4f 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/hooks/kubernetes.py +++ b/providers/src/airflow/providers/cncf/kubernetes/hooks/kubernetes.py @@ -20,9 +20,10 @@ import contextlib import json import tempfile +from collections.abc import Generator from functools import cached_property from time import sleep -from typing import TYPE_CHECKING, Any, Generator +from typing import TYPE_CHECKING, Any import aiofiles import tenacity diff --git a/providers/src/airflow/providers/cncf/kubernetes/operators/job.py b/providers/src/airflow/providers/cncf/kubernetes/operators/job.py index a55c776913a4e..36fa4b92a91be 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/operators/job.py +++ b/providers/src/airflow/providers/cncf/kubernetes/operators/job.py @@ -22,8 +22,9 @@ import json import logging import os +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from kubernetes.client import BatchV1Api, models as k8s from kubernetes.client.api_client import ApiClient diff --git a/providers/src/airflow/providers/cncf/kubernetes/operators/pod.py b/providers/src/airflow/providers/cncf/kubernetes/operators/pod.py index afb976f80f160..cbafc72f3455c 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/operators/pod.py +++ b/providers/src/airflow/providers/cncf/kubernetes/operators/pod.py @@ -26,11 +26,11 @@ import re import shlex import string -from collections.abc import Container, Mapping +from collections.abc import Container, Iterable, Mapping, Sequence from contextlib import AbstractContextManager from enum import Enum from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Iterable, Literal, Sequence +from typing import TYPE_CHECKING, Any, Callable, Literal import kubernetes import tenacity diff --git a/providers/src/airflow/providers/cncf/kubernetes/operators/resource.py b/providers/src/airflow/providers/cncf/kubernetes/operators/resource.py index 417f75464619e..aef972faf26e8 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/operators/resource.py +++ b/providers/src/airflow/providers/cncf/kubernetes/operators/resource.py @@ -19,8 +19,9 @@ from __future__ import annotations import os +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING import tenacity import yaml diff --git a/providers/src/airflow/providers/cncf/kubernetes/sensors/spark_kubernetes.py b/providers/src/airflow/providers/cncf/kubernetes/sensors/spark_kubernetes.py index 3ed142e07acc4..08968d245fde7 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/sensors/spark_kubernetes.py +++ b/providers/src/airflow/providers/cncf/kubernetes/sensors/spark_kubernetes.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from kubernetes import client diff --git a/providers/src/airflow/providers/cncf/kubernetes/triggers/job.py b/providers/src/airflow/providers/cncf/kubernetes/triggers/job.py index d8d1db3567cea..a6b03e9fdea53 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/triggers/job.py +++ b/providers/src/airflow/providers/cncf/kubernetes/triggers/job.py @@ -17,8 +17,9 @@ from __future__ import annotations import asyncio +from collections.abc import AsyncIterator from functools import cached_property -from typing import TYPE_CHECKING, Any, AsyncIterator +from typing import TYPE_CHECKING, Any from airflow.providers.cncf.kubernetes.hooks.kubernetes import AsyncKubernetesHook, KubernetesHook from airflow.providers.cncf.kubernetes.utils.pod_manager import PodManager diff --git a/providers/src/airflow/providers/cncf/kubernetes/triggers/pod.py b/providers/src/airflow/providers/cncf/kubernetes/triggers/pod.py index 51b86647f36b5..ec08c3184549f 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/triggers/pod.py +++ b/providers/src/airflow/providers/cncf/kubernetes/triggers/pod.py @@ -19,9 +19,10 @@ import asyncio import datetime import traceback +from collections.abc import AsyncIterator from enum import Enum from functools import cached_property -from typing import TYPE_CHECKING, Any, AsyncIterator +from typing import TYPE_CHECKING, Any from airflow.providers.cncf.kubernetes.hooks.kubernetes import AsyncKubernetesHook from airflow.providers.cncf.kubernetes.utils.pod_manager import ( diff --git a/providers/src/airflow/providers/cncf/kubernetes/utils/k8s_resource_iterator.py b/providers/src/airflow/providers/cncf/kubernetes/utils/k8s_resource_iterator.py index bfa1d05272ccf..d66eb9fc80bc0 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/utils/k8s_resource_iterator.py +++ b/providers/src/airflow/providers/cncf/kubernetes/utils/k8s_resource_iterator.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import Callable, Iterator +from collections.abc import Iterator +from typing import Callable from kubernetes.utils import FailToCreateError diff --git a/providers/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py b/providers/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py index aa8e812921c3c..e123ef0b0d284 100644 --- a/providers/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py +++ b/providers/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py @@ -22,11 +22,11 @@ import json import math import time -from collections.abc import Iterable +from collections.abc import Generator, Iterable from contextlib import closing, suppress from dataclasses import dataclass from datetime import timedelta -from typing import TYPE_CHECKING, Generator, Protocol, cast +from typing import TYPE_CHECKING, Protocol, cast import pendulum import tenacity diff --git a/providers/src/airflow/providers/cohere/operators/embedding.py b/providers/src/airflow/providers/cohere/operators/embedding.py index 8fad0ae9423a7..85a585a9f739e 100644 --- a/providers/src/airflow/providers/cohere/operators/embedding.py +++ b/providers/src/airflow/providers/cohere/operators/embedding.py @@ -17,8 +17,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.cohere.hooks.cohere import CohereHook diff --git a/providers/src/airflow/providers/common/io/operators/file_transfer.py b/providers/src/airflow/providers/common/io/operators/file_transfer.py index 43957ed8aa900..840ef796e598d 100644 --- a/providers/src/airflow/providers/common/io/operators/file_transfer.py +++ b/providers/src/airflow/providers/common/io/operators/file_transfer.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.io.path import ObjectStoragePath from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/common/sql/hooks/handlers.py b/providers/src/airflow/providers/common/sql/hooks/handlers.py index 6fa12ef002143..3636cc214d213 100644 --- a/providers/src/airflow/providers/common/sql/hooks/handlers.py +++ b/providers/src/airflow/providers/common/sql/hooks/handlers.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import Iterable +from collections.abc import Iterable def return_single_query_results(sql: str | Iterable[str], return_last: bool, split_statements: bool): diff --git a/providers/src/airflow/providers/common/sql/hooks/sql.py b/providers/src/airflow/providers/common/sql/hooks/sql.py index 144677e49bf3a..d124b404d620d 100644 --- a/providers/src/airflow/providers/common/sql/hooks/sql.py +++ b/providers/src/airflow/providers/common/sql/hooks/sql.py @@ -18,6 +18,7 @@ import contextlib import warnings +from collections.abc import Generator, Iterable, Mapping, Sequence from contextlib import closing, contextmanager from datetime import datetime from functools import cached_property @@ -25,12 +26,7 @@ TYPE_CHECKING, Any, Callable, - Generator, - Iterable, - List, - Mapping, Protocol, - Sequence, TypeVar, cast, overload, @@ -518,7 +514,7 @@ def _make_common_data_structure(self, result: T | Sequence[T]) -> tuple | list[t ) if isinstance(result, Sequence): - return cast(List[tuple], result) + return cast(list[tuple], result) return cast(tuple, result) def _run_command(self, cur, sql_statement, parameters): diff --git a/providers/src/airflow/providers/common/sql/operators/sql.py b/providers/src/airflow/providers/common/sql/operators/sql.py index 44982b8e1efa9..3643d01b28eb9 100644 --- a/providers/src/airflow/providers/common/sql/operators/sql.py +++ b/providers/src/airflow/providers/common/sql/operators/sql.py @@ -19,8 +19,9 @@ import ast import re +from collections.abc import Iterable, Mapping, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, ClassVar, Iterable, Mapping, NoReturn, Sequence, SupportsAbs +from typing import TYPE_CHECKING, Any, Callable, ClassVar, NoReturn, SupportsAbs from airflow.exceptions import AirflowException, AirflowFailException from airflow.hooks.base import BaseHook diff --git a/providers/src/airflow/providers/common/sql/sensors/sql.py b/providers/src/airflow/providers/common/sql/sensors/sql.py index ac7eb7b4a4005..322a970c0b848 100644 --- a/providers/src/airflow/providers/common/sql/sensors/sql.py +++ b/providers/src/airflow/providers/common/sql/sensors/sql.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Mapping, Sequence from operator import itemgetter -from typing import TYPE_CHECKING, Any, Callable, Mapping, Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook diff --git a/providers/src/airflow/providers/databricks/hooks/databricks_sql.py b/providers/src/airflow/providers/databricks/hooks/databricks_sql.py index 6d4f679b2eed9..76b7720573e32 100644 --- a/providers/src/airflow/providers/databricks/hooks/databricks_sql.py +++ b/providers/src/airflow/providers/databricks/hooks/databricks_sql.py @@ -19,6 +19,7 @@ import threading import warnings from collections import namedtuple +from collections.abc import Iterable, Mapping, Sequence from contextlib import closing from copy import copy from datetime import timedelta @@ -26,10 +27,6 @@ TYPE_CHECKING, Any, Callable, - Iterable, - List, - Mapping, - Sequence, TypeVar, cast, overload, @@ -320,7 +317,7 @@ def _make_common_data_structure(self, result: Sequence[Row] | Row) -> list[tuple return [] rows_fields = tuple(rows[0].__fields__) rows_object = namedtuple("Row", rows_fields, rename=True) # type: ignore - return cast(List[tuple], [rows_object(*row) for row in rows]) + return cast(list[tuple], [rows_object(*row) for row in rows]) else: row: Row = result row_fields = tuple(row.__fields__) diff --git a/providers/src/airflow/providers/databricks/operators/databricks.py b/providers/src/airflow/providers/databricks/operators/databricks.py index 60800ff22e3fe..fb9905b878416 100644 --- a/providers/src/airflow/providers/databricks/operators/databricks.py +++ b/providers/src/airflow/providers/databricks/operators/databricks.py @@ -21,9 +21,10 @@ import time from abc import ABC, abstractmethod +from collections.abc import Sequence from functools import cached_property from logging import Logger -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from deprecated import deprecated diff --git a/providers/src/airflow/providers/databricks/operators/databricks_repos.py b/providers/src/airflow/providers/databricks/operators/databricks_repos.py index 42de7f290acb9..78ccffe97e9f3 100644 --- a/providers/src/airflow/providers/databricks/operators/databricks_repos.py +++ b/providers/src/airflow/providers/databricks/operators/databricks_repos.py @@ -20,8 +20,9 @@ from __future__ import annotations import re +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from urllib.parse import urlsplit from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/databricks/operators/databricks_sql.py b/providers/src/airflow/providers/databricks/operators/databricks_sql.py index 0998bc9a6ef53..d6dce23b529e1 100644 --- a/providers/src/airflow/providers/databricks/operators/databricks_sql.py +++ b/providers/src/airflow/providers/databricks/operators/databricks_sql.py @@ -21,7 +21,8 @@ import csv import json -from typing import TYPE_CHECKING, Any, ClassVar, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, ClassVar from databricks.sql.utils import ParamEscaper diff --git a/providers/src/airflow/providers/databricks/sensors/databricks_partition.py b/providers/src/airflow/providers/databricks/sensors/databricks_partition.py index 8ae98c99b1f08..3577e26a813d0 100644 --- a/providers/src/airflow/providers/databricks/sensors/databricks_partition.py +++ b/providers/src/airflow/providers/databricks/sensors/databricks_partition.py @@ -20,9 +20,10 @@ from __future__ import annotations +from collections.abc import Sequence from datetime import datetime from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable from databricks.sql.utils import ParamEscaper diff --git a/providers/src/airflow/providers/databricks/sensors/databricks_sql.py b/providers/src/airflow/providers/databricks/sensors/databricks_sql.py index 6b614f66144cd..bb78d5186f65f 100644 --- a/providers/src/airflow/providers/databricks/sensors/databricks_sql.py +++ b/providers/src/airflow/providers/databricks/sensors/databricks_sql.py @@ -20,8 +20,9 @@ from __future__ import annotations +from collections.abc import Iterable, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.exceptions import AirflowException from airflow.providers.common.sql.hooks.sql import fetch_all_handler diff --git a/providers/src/airflow/providers/dbt/cloud/triggers/dbt.py b/providers/src/airflow/providers/dbt/cloud/triggers/dbt.py index bf8c8d794a09a..c8acf2d81e647 100644 --- a/providers/src/airflow/providers/dbt/cloud/triggers/dbt.py +++ b/providers/src/airflow/providers/dbt/cloud/triggers/dbt.py @@ -18,7 +18,8 @@ import asyncio import time -from typing import Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import Any from airflow.providers.dbt.cloud.hooks.dbt import DbtCloudHook, DbtCloudJobRunStatus from airflow.triggers.base import BaseTrigger, TriggerEvent diff --git a/providers/src/airflow/providers/dingding/operators/dingding.py b/providers/src/airflow/providers/dingding/operators/dingding.py index ab78e69cac711..254f76fde5210 100644 --- a/providers/src/airflow/providers/dingding/operators/dingding.py +++ b/providers/src/airflow/providers/dingding/operators/dingding.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.dingding.hooks.dingding import DingdingHook diff --git a/providers/src/airflow/providers/discord/operators/discord_webhook.py b/providers/src/airflow/providers/discord/operators/discord_webhook.py index 0650b19b26cd8..027faca6e376f 100644 --- a/providers/src/airflow/providers/discord/operators/discord_webhook.py +++ b/providers/src/airflow/providers/discord/operators/discord_webhook.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.discord.hooks.discord_webhook import DiscordWebhookHook diff --git a/providers/src/airflow/providers/docker/decorators/docker.py b/providers/src/airflow/providers/docker/decorators/docker.py index 0439599257b1c..6863020c73adc 100644 --- a/providers/src/airflow/providers/docker/decorators/docker.py +++ b/providers/src/airflow/providers/docker/decorators/docker.py @@ -19,8 +19,9 @@ import base64 import os import warnings +from collections.abc import Sequence from tempfile import TemporaryDirectory -from typing import TYPE_CHECKING, Any, Callable, Literal, Sequence +from typing import TYPE_CHECKING, Any, Callable, Literal from airflow.decorators.base import DecoratedOperator, task_decorator_factory from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning diff --git a/providers/src/airflow/providers/docker/operators/docker.py b/providers/src/airflow/providers/docker/operators/docker.py index 01d07ffd98118..d232cb103900e 100644 --- a/providers/src/airflow/providers/docker/operators/docker.py +++ b/providers/src/airflow/providers/docker/operators/docker.py @@ -24,11 +24,11 @@ import pickle import tarfile import warnings -from collections.abc import Container +from collections.abc import Container, Iterable, Sequence from functools import cached_property from io import BytesIO, StringIO from tempfile import TemporaryDirectory -from typing import TYPE_CHECKING, Iterable, Sequence +from typing import TYPE_CHECKING from deprecated.classic import deprecated from docker.constants import DEFAULT_TIMEOUT_SECONDS diff --git a/providers/src/airflow/providers/edge/executors/edge_executor.py b/providers/src/airflow/providers/edge/executors/edge_executor.py index b990a3311571c..62276ba03a639 100644 --- a/providers/src/airflow/providers/edge/executors/edge_executor.py +++ b/providers/src/airflow/providers/edge/executors/edge_executor.py @@ -17,8 +17,9 @@ from __future__ import annotations +from collections.abc import Sequence from datetime import datetime, timedelta -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from sqlalchemy import delete diff --git a/providers/src/airflow/providers/edge/models/edge_job.py b/providers/src/airflow/providers/edge/models/edge_job.py index b6e316e1f76a3..d42064bd3c0f4 100644 --- a/providers/src/airflow/providers/edge/models/edge_job.py +++ b/providers/src/airflow/providers/edge/models/edge_job.py @@ -18,7 +18,7 @@ from ast import literal_eval from datetime import datetime -from typing import TYPE_CHECKING, List, Optional +from typing import TYPE_CHECKING, Optional from pydantic import BaseModel, ConfigDict from sqlalchemy import ( @@ -112,7 +112,7 @@ class EdgeJob(BaseModel, LoggingMixin): try_number: int state: TaskInstanceState queue: str - command: List[str] # noqa: UP006 - prevent Sphinx failing + command: list[str] queued_dttm: datetime edge_worker: Optional[str] # noqa: UP007 - prevent Sphinx failing last_update: Optional[datetime] # noqa: UP007 - prevent Sphinx failing diff --git a/providers/src/airflow/providers/edge/models/edge_worker.py b/providers/src/airflow/providers/edge/models/edge_worker.py index 7fdcb0cf3d413..56f9b9221ea9c 100644 --- a/providers/src/airflow/providers/edge/models/edge_worker.py +++ b/providers/src/airflow/providers/edge/models/edge_worker.py @@ -20,7 +20,7 @@ import json from datetime import datetime from enum import Enum -from typing import TYPE_CHECKING, List, Optional +from typing import TYPE_CHECKING, Optional from pydantic import BaseModel, ConfigDict from sqlalchemy import ( @@ -134,7 +134,7 @@ class EdgeWorker(BaseModel, LoggingMixin): worker_name: str state: EdgeWorkerState - queues: Optional[List[str]] # noqa: UP006,UP007 - prevent Sphinx failing + queues: Optional[list[str]] # noqa: UP007 - prevent Sphinx failing first_online: datetime last_update: Optional[datetime] = None # noqa: UP007 - prevent Sphinx failing jobs_active: int @@ -151,7 +151,7 @@ def set_metrics( connected: bool, jobs_active: int, concurrency: int, - queues: Optional[List[str]], # noqa: UP006,UP007 - prevent Sphinx failing + queues: Optional[list[str]], # noqa: UP007 - prevent Sphinx failing ) -> None: """Set metric of edge worker.""" queues = queues if queues else [] diff --git a/providers/src/airflow/providers/edge/worker_api/datamodels.py b/providers/src/airflow/providers/edge/worker_api/datamodels.py index 4eae0b912fb92..9ce181bc72688 100644 --- a/providers/src/airflow/providers/edge/worker_api/datamodels.py +++ b/providers/src/airflow/providers/edge/worker_api/datamodels.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import Any, Dict, Optional +from typing import Any, Optional from pydantic import BaseModel @@ -28,5 +28,5 @@ class JsonRpcRequest(BaseModel): """Fully qualified python module method name that is called via JSON RPC.""" jsonrpc: str """JSON RPC version.""" - params: Optional[Dict[str, Any]] = None # noqa: UP006, UP007 - prevent pytest failing in back-compat + params: Optional[dict[str, Any]] = None # noqa: UP007 - prevent pytest failing in back-compat """Parameters passed to the method.""" diff --git a/providers/src/airflow/providers/elasticsearch/log/es_response.py b/providers/src/airflow/providers/elasticsearch/log/es_response.py index 531f7d1b0d483..610b03f96e199 100644 --- a/providers/src/airflow/providers/elasticsearch/log/es_response.py +++ b/providers/src/airflow/providers/elasticsearch/log/es_response.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import Iterator +from collections.abc import Iterator def _wrap(val): diff --git a/providers/src/airflow/providers/elasticsearch/log/es_task_handler.py b/providers/src/airflow/providers/elasticsearch/log/es_task_handler.py index c4cc14faee3bd..4a3674e8424dd 100644 --- a/providers/src/airflow/providers/elasticsearch/log/es_task_handler.py +++ b/providers/src/airflow/providers/elasticsearch/log/es_task_handler.py @@ -25,7 +25,7 @@ import warnings from collections import defaultdict from operator import attrgetter -from typing import TYPE_CHECKING, Any, Callable, List, Literal, Tuple +from typing import TYPE_CHECKING, Any, Callable, Literal from urllib.parse import quote, urlparse # Using `from elasticsearch import *` would break elasticsearch mocking used in unit test. @@ -57,7 +57,7 @@ LOG_LINE_DEFAULTS = {"exc_text": "", "stack_info": ""} # Elasticsearch hosted log type -EsLogMsgType = List[Tuple[str, str]] +EsLogMsgType = list[tuple[str, str]] # Compatibility: Airflow 2.3.3 and up uses this method, which accesses the # LogTemplate model to record the log ID template used. If this function does diff --git a/providers/src/airflow/providers/exasol/hooks/exasol.py b/providers/src/airflow/providers/exasol/hooks/exasol.py index 3471a69065c1f..ad3362e9115ee 100644 --- a/providers/src/airflow/providers/exasol/hooks/exasol.py +++ b/providers/src/airflow/providers/exasol/hooks/exasol.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Iterable, Mapping, Sequence from contextlib import closing -from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, Sequence, TypeVar, overload +from typing import TYPE_CHECKING, Any, Callable, TypeVar, overload import pyexasol from pyexasol import ExaConnection, ExaStatement diff --git a/providers/src/airflow/providers/exasol/operators/exasol.py b/providers/src/airflow/providers/exasol/operators/exasol.py index 51c0131fa5b59..6f389a6d21526 100644 --- a/providers/src/airflow/providers/exasol/operators/exasol.py +++ b/providers/src/airflow/providers/exasol/operators/exasol.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import ClassVar, Sequence +from collections.abc import Sequence +from typing import ClassVar from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator from airflow.providers.exasol.hooks.exasol import exasol_fetch_all_handler diff --git a/providers/src/airflow/providers/fab/auth_manager/cli_commands/utils.py b/providers/src/airflow/providers/fab/auth_manager/cli_commands/utils.py index 78403e24079f1..03bfd526d09c4 100644 --- a/providers/src/airflow/providers/fab/auth_manager/cli_commands/utils.py +++ b/providers/src/airflow/providers/fab/auth_manager/cli_commands/utils.py @@ -18,9 +18,10 @@ from __future__ import annotations import os +from collections.abc import Generator from contextlib import contextmanager -from functools import lru_cache -from typing import TYPE_CHECKING, Generator +from functools import cache +from typing import TYPE_CHECKING from flask import Flask @@ -33,7 +34,7 @@ from airflow.www.extensions.init_appbuilder import AirflowAppBuilder -@lru_cache(maxsize=None) +@cache def _return_appbuilder(app: Flask) -> AirflowAppBuilder: """Return an appbuilder instance for the given app.""" init_appbuilder(app) diff --git a/providers/src/airflow/providers/fab/auth_manager/decorators/auth.py b/providers/src/airflow/providers/fab/auth_manager/decorators/auth.py index cfd799cf0f99a..075236673f056 100644 --- a/providers/src/airflow/providers/fab/auth_manager/decorators/auth.py +++ b/providers/src/airflow/providers/fab/auth_manager/decorators/auth.py @@ -18,8 +18,9 @@ from __future__ import annotations import logging +from collections.abc import Sequence from functools import wraps -from typing import Callable, Sequence, TypeVar, cast +from typing import Callable, TypeVar, cast from flask import current_app, render_template, request diff --git a/providers/src/airflow/providers/fab/auth_manager/fab_auth_manager.py b/providers/src/airflow/providers/fab/auth_manager/fab_auth_manager.py index 8a91106a64dfc..cdb0055003b67 100644 --- a/providers/src/airflow/providers/fab/auth_manager/fab_auth_manager.py +++ b/providers/src/airflow/providers/fab/auth_manager/fab_auth_manager.py @@ -18,9 +18,10 @@ from __future__ import annotations import argparse +from collections.abc import Container from functools import cached_property from pathlib import Path -from typing import TYPE_CHECKING, Any, Container +from typing import TYPE_CHECKING, Any import packaging.version from connexion import FlaskApi diff --git a/providers/src/airflow/providers/fab/auth_manager/security_manager/override.py b/providers/src/airflow/providers/fab/auth_manager/security_manager/override.py index c45d51eaf9062..9396dee4fdeef 100644 --- a/providers/src/airflow/providers/fab/auth_manager/security_manager/override.py +++ b/providers/src/airflow/providers/fab/auth_manager/security_manager/override.py @@ -24,7 +24,8 @@ import os import random import uuid -from typing import TYPE_CHECKING, Any, Callable, Collection, Iterable, Mapping, Sequence +from collections.abc import Collection, Iterable, Mapping, Sequence +from typing import TYPE_CHECKING, Any, Callable import jwt import packaging.version diff --git a/providers/src/airflow/providers/ftp/operators/ftp.py b/providers/src/airflow/providers/ftp/operators/ftp.py index 8a8c97667106c..ac03dd44bfab1 100644 --- a/providers/src/airflow/providers/ftp/operators/ftp.py +++ b/providers/src/airflow/providers/ftp/operators/ftp.py @@ -21,10 +21,11 @@ import os import socket +from collections.abc import Sequence from ftplib import FTP_PORT # nosec: B402 from functools import cached_property from pathlib import Path -from typing import Any, Sequence +from typing import Any from airflow.models import BaseOperator from airflow.providers.ftp.hooks.ftp import FTPHook, FTPSHook diff --git a/providers/src/airflow/providers/ftp/sensors/ftp.py b/providers/src/airflow/providers/ftp/sensors/ftp.py index 1ab56c56c0609..9d384c889c7ba 100644 --- a/providers/src/airflow/providers/ftp/sensors/ftp.py +++ b/providers/src/airflow/providers/ftp/sensors/ftp.py @@ -19,7 +19,8 @@ import ftplib # nosec: B402 import re -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.ftp.hooks.ftp import FTPHook, FTPSHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/google/ads/operators/ads.py b/providers/src/airflow/providers/google/ads/operators/ads.py index a1f2e9e1f6f6e..b8ef110c19d17 100644 --- a/providers/src/airflow/providers/google/ads/operators/ads.py +++ b/providers/src/airflow/providers/google/ads/operators/ads.py @@ -20,8 +20,9 @@ from __future__ import annotations import csv +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.ads.hooks.ads import GoogleAdsHook diff --git a/providers/src/airflow/providers/google/ads/transfers/ads_to_gcs.py b/providers/src/airflow/providers/google/ads/transfers/ads_to_gcs.py index 763255c573c09..b36e85854e752 100644 --- a/providers/src/airflow/providers/google/ads/transfers/ads_to_gcs.py +++ b/providers/src/airflow/providers/google/ads/transfers/ads_to_gcs.py @@ -17,9 +17,10 @@ from __future__ import annotations import csv +from collections.abc import Sequence from operator import attrgetter from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.ads.hooks.ads import GoogleAdsHook diff --git a/providers/src/airflow/providers/google/cloud/hooks/automl.py b/providers/src/airflow/providers/google/cloud/hooks/automl.py index 52c69dbfa2296..83c61e8ddfa37 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/automl.py +++ b/providers/src/airflow/providers/google/cloud/hooks/automl.py @@ -25,8 +25,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.automl_v1beta1 import ( diff --git a/providers/src/airflow/providers/google/cloud/hooks/bigquery.py b/providers/src/airflow/providers/google/cloud/hooks/bigquery.py index bce89e9e4184b..e4aa43f419f39 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/bigquery.py +++ b/providers/src/airflow/providers/google/cloud/hooks/bigquery.py @@ -26,9 +26,10 @@ import re import time import uuid +from collections.abc import Iterable, Mapping, Sequence from copy import deepcopy from datetime import datetime, timedelta -from typing import TYPE_CHECKING, Any, Iterable, Mapping, NoReturn, Sequence, Union, cast +from typing import TYPE_CHECKING, Any, NoReturn, Union, cast from aiohttp import ClientSession as ClientSession from gcloud.aio.bigquery import Job, Table as Table_async diff --git a/providers/src/airflow/providers/google/cloud/hooks/bigquery_dts.py b/providers/src/airflow/providers/google/cloud/hooks/bigquery_dts.py index 3ac1bbd95b460..467624778082c 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/bigquery_dts.py +++ b/providers/src/airflow/providers/google/cloud/hooks/bigquery_dts.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from copy import copy -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.bigquery_datatransfer_v1 import DataTransferServiceAsyncClient, DataTransferServiceClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/bigtable.py b/providers/src/airflow/providers/google/cloud/hooks/bigtable.py index 5f06e6eee6e7e..83a631eafa687 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/bigtable.py +++ b/providers/src/airflow/providers/google/cloud/hooks/bigtable.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.cloud.bigtable import Client, enums from google.cloud.bigtable.cluster import Cluster diff --git a/providers/src/airflow/providers/google/cloud/hooks/cloud_batch.py b/providers/src/airflow/providers/google/cloud/hooks/cloud_batch.py index e2d8dc810841f..3ef24014b6f14 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/cloud_batch.py +++ b/providers/src/airflow/providers/google/cloud/hooks/cloud_batch.py @@ -20,7 +20,8 @@ import itertools import json import time -from typing import TYPE_CHECKING, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING from google.cloud.batch import ListJobsRequest, ListTasksRequest from google.cloud.batch_v1 import ( diff --git a/providers/src/airflow/providers/google/cloud/hooks/cloud_build.py b/providers/src/airflow/providers/google/cloud/hooks/cloud_build.py index fcb83d4bfd2d9..ad28f22df2fd3 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/cloud_build.py +++ b/providers/src/airflow/providers/google/cloud/hooks/cloud_build.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.exceptions import AlreadyExists diff --git a/providers/src/airflow/providers/google/cloud/hooks/cloud_composer.py b/providers/src/airflow/providers/google/cloud/hooks/cloud_composer.py index 5d659ef81f617..de71d5af8212a 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/cloud_composer.py +++ b/providers/src/airflow/providers/google/cloud/hooks/cloud_composer.py @@ -19,7 +19,8 @@ import asyncio import time -from typing import TYPE_CHECKING, MutableSequence, Sequence +from collections.abc import MutableSequence, Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/cloud_memorystore.py b/providers/src/airflow/providers/google/cloud/hooks/cloud_memorystore.py index 768e9b6c62ec4..eb75e65b42e64 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/cloud_memorystore.py +++ b/providers/src/airflow/providers/google/cloud/hooks/cloud_memorystore.py @@ -28,7 +28,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core import path_template from google.api_core.exceptions import NotFound diff --git a/providers/src/airflow/providers/google/cloud/hooks/cloud_run.py b/providers/src/airflow/providers/google/cloud/hooks/cloud_run.py index f50cb59646d6b..af8fc8d96aa66 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/cloud_run.py +++ b/providers/src/airflow/providers/google/cloud/hooks/cloud_run.py @@ -18,7 +18,8 @@ from __future__ import annotations import itertools -from typing import TYPE_CHECKING, Any, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING, Any from google.cloud.run_v2 import ( CreateJobRequest, diff --git a/providers/src/airflow/providers/google/cloud/hooks/cloud_sql.py b/providers/src/airflow/providers/google/cloud/hooks/cloud_sql.py index 04bf84d909727..79be9c556b028 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/cloud_sql.py +++ b/providers/src/airflow/providers/google/cloud/hooks/cloud_sql.py @@ -33,11 +33,12 @@ import subprocess import time import uuid +from collections.abc import Sequence from inspect import signature from pathlib import Path from subprocess import PIPE, Popen from tempfile import NamedTemporaryFile, _TemporaryFileWrapper, gettempdir -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from urllib.parse import quote_plus import httpx diff --git a/providers/src/airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py b/providers/src/airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py index 215cb717b4491..f62679a63fa53 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py +++ b/providers/src/airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py @@ -31,9 +31,10 @@ import logging import time import warnings +from collections.abc import Sequence from copy import deepcopy from datetime import timedelta -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from google.cloud.storage_transfer_v1 import ( ListTransferJobsRequest, diff --git a/providers/src/airflow/providers/google/cloud/hooks/compute.py b/providers/src/airflow/providers/google/cloud/hooks/compute.py index 8882efad58b0f..bb86fbfa25547 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/compute.py +++ b/providers/src/airflow/providers/google/cloud/hooks/compute.py @@ -20,7 +20,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.cloud.compute_v1.services.instance_group_managers import InstanceGroupManagersClient from google.cloud.compute_v1.services.instance_templates import InstanceTemplatesClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/datacatalog.py b/providers/src/airflow/providers/google/cloud/hooks/datacatalog.py index 57418767fd0e3..2cfa308ff9248 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/datacatalog.py +++ b/providers/src/airflow/providers/google/cloud/hooks/datacatalog.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud import datacatalog diff --git a/providers/src/airflow/providers/google/cloud/hooks/dataflow.py b/providers/src/airflow/providers/google/cloud/hooks/dataflow.py index 09231cb099c70..ab26ccc38d61c 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/dataflow.py +++ b/providers/src/airflow/providers/google/cloud/hooks/dataflow.py @@ -27,8 +27,9 @@ import time import uuid import warnings +from collections.abc import Generator, Sequence from copy import deepcopy -from typing import TYPE_CHECKING, Any, Callable, Generator, Sequence, TypeVar, cast +from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast from google.cloud.dataflow_v1beta3 import ( GetJobRequest, diff --git a/providers/src/airflow/providers/google/cloud/hooks/dataform.py b/providers/src/airflow/providers/google/cloud/hooks/dataform.py index 5ca44ade940c9..c921b56c6fe82 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/dataform.py +++ b/providers/src/airflow/providers/google/cloud/hooks/dataform.py @@ -17,7 +17,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.dataform_v1beta1 import DataformClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/datafusion.py b/providers/src/airflow/providers/google/cloud/hooks/datafusion.py index a4fce57b2e3c9..89a4986adfd5c 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/datafusion.py +++ b/providers/src/airflow/providers/google/cloud/hooks/datafusion.py @@ -22,7 +22,8 @@ import json import os import time -from typing import Any, Dict, Sequence +from collections.abc import Sequence +from typing import Any from urllib.parse import quote, urlencode, urljoin import google.auth @@ -39,7 +40,7 @@ GoogleBaseHook, ) -Operation = Dict[str, Any] +Operation = dict[str, Any] class ConflictException(AirflowException): diff --git a/providers/src/airflow/providers/google/cloud/hooks/dataplex.py b/providers/src/airflow/providers/google/cloud/hooks/dataplex.py index 210d9bc754039..387dfb00a50c2 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/dataplex.py +++ b/providers/src/airflow/providers/google/cloud/hooks/dataplex.py @@ -19,7 +19,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/dataproc.py b/providers/src/airflow/providers/google/cloud/hooks/dataproc.py index ec05f5f341c42..b704c23107e71 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/dataproc.py +++ b/providers/src/airflow/providers/google/cloud/hooks/dataproc.py @@ -23,8 +23,8 @@ import subprocess import time import uuid -from collections.abc import MutableSequence -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import MutableSequence, Sequence +from typing import TYPE_CHECKING, Any from google.api_core.client_options import ClientOptions from google.api_core.exceptions import ServerError diff --git a/providers/src/airflow/providers/google/cloud/hooks/dataproc_metastore.py b/providers/src/airflow/providers/google/cloud/hooks/dataproc_metastore.py index 9700a1e949737..b0168ddbfbba8 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/dataproc_metastore.py +++ b/providers/src/airflow/providers/google/cloud/hooks/dataproc_metastore.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/datastore.py b/providers/src/airflow/providers/google/cloud/hooks/datastore.py index 864fa45835753..3c2bd97809d24 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/datastore.py +++ b/providers/src/airflow/providers/google/cloud/hooks/datastore.py @@ -20,7 +20,8 @@ from __future__ import annotations import time -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from googleapiclient.discovery import Resource, build diff --git a/providers/src/airflow/providers/google/cloud/hooks/dlp.py b/providers/src/airflow/providers/google/cloud/hooks/dlp.py index b5052ff8090b7..c0730497e904e 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/dlp.py +++ b/providers/src/airflow/providers/google/cloud/hooks/dlp.py @@ -28,7 +28,8 @@ import re import time -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.dlp import DlpServiceClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/functions.py b/providers/src/airflow/providers/google/cloud/hooks/functions.py index d488f1d25049e..eaa05f292874c 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/functions.py +++ b/providers/src/airflow/providers/google/cloud/hooks/functions.py @@ -20,7 +20,7 @@ from __future__ import annotations import time -from typing import Sequence +from collections.abc import Sequence import requests from googleapiclient.discovery import build diff --git a/providers/src/airflow/providers/google/cloud/hooks/gcs.py b/providers/src/airflow/providers/google/cloud/hooks/gcs.py index 22feb2854ec3f..cf69f8bb76556 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/gcs.py +++ b/providers/src/airflow/providers/google/cloud/hooks/gcs.py @@ -26,11 +26,12 @@ import shutil import time import warnings +from collections.abc import Generator, Sequence from contextlib import contextmanager from functools import partial from io import BytesIO from tempfile import NamedTemporaryFile -from typing import IO, TYPE_CHECKING, Any, Callable, Generator, Sequence, TypeVar, cast, overload +from typing import IO, TYPE_CHECKING, Any, Callable, TypeVar, cast, overload from urllib.parse import urlsplit from gcloud.aio.storage import Storage diff --git a/providers/src/airflow/providers/google/cloud/hooks/kms.py b/providers/src/airflow/providers/google/cloud/hooks/kms.py index 5071fc5ffb180..e69273d993934 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/kms.py +++ b/providers/src/airflow/providers/google/cloud/hooks/kms.py @@ -20,7 +20,8 @@ from __future__ import annotations import base64 -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.kms_v1 import KeyManagementServiceClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/kubernetes_engine.py b/providers/src/airflow/providers/google/cloud/hooks/kubernetes_engine.py index ef9d79793774f..23eab9dd3cd44 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/kubernetes_engine.py +++ b/providers/src/airflow/providers/google/cloud/hooks/kubernetes_engine.py @@ -22,7 +22,8 @@ import contextlib import json import time -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/life_sciences.py b/providers/src/airflow/providers/google/cloud/hooks/life_sciences.py index 9cf052045d087..a3552db5c6b8f 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/life_sciences.py +++ b/providers/src/airflow/providers/google/cloud/hooks/life_sciences.py @@ -20,7 +20,7 @@ from __future__ import annotations import time -from typing import Sequence +from collections.abc import Sequence import google.api_core.path_template from googleapiclient.discovery import build diff --git a/providers/src/airflow/providers/google/cloud/hooks/natural_language.py b/providers/src/airflow/providers/google/cloud/hooks/natural_language.py index 48c218c15b6bb..edeef2d393167 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/natural_language.py +++ b/providers/src/airflow/providers/google/cloud/hooks/natural_language.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.language_v1 import EncodingType, LanguageServiceClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/os_login.py b/providers/src/airflow/providers/google/cloud/hooks/os_login.py index 0829eeff9b97a..bcb3d8eac1c72 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/os_login.py +++ b/providers/src/airflow/providers/google/cloud/hooks/os_login.py @@ -24,7 +24,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.oslogin_v1 import ImportSshPublicKeyResponse, OsLoginServiceClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/pubsub.py b/providers/src/airflow/providers/google/cloud/hooks/pubsub.py index e2ca684baab38..58237c5c2ae1e 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/pubsub.py +++ b/providers/src/airflow/providers/google/cloud/hooks/pubsub.py @@ -28,8 +28,9 @@ import warnings from base64 import b64decode +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from uuid import uuid4 from google.api_core.exceptions import AlreadyExists, GoogleAPICallError diff --git a/providers/src/airflow/providers/google/cloud/hooks/secret_manager.py b/providers/src/airflow/providers/google/cloud/hooks/secret_manager.py index 48983fa70342c..db144acf42da6 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/secret_manager.py +++ b/providers/src/airflow/providers/google/cloud/hooks/secret_manager.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.secretmanager_v1 import ( diff --git a/providers/src/airflow/providers/google/cloud/hooks/spanner.py b/providers/src/airflow/providers/google/cloud/hooks/spanner.py index f765e274f5960..24bea1e9566d5 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/spanner.py +++ b/providers/src/airflow/providers/google/cloud/hooks/spanner.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable, NamedTuple, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Callable, NamedTuple from google.api_core.exceptions import AlreadyExists, GoogleAPICallError from google.cloud.spanner_v1.client import Client diff --git a/providers/src/airflow/providers/google/cloud/hooks/speech_to_text.py b/providers/src/airflow/providers/google/cloud/hooks/speech_to_text.py index 4f8f4ddfd5ed3..098081990f9bb 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/speech_to_text.py +++ b/providers/src/airflow/providers/google/cloud/hooks/speech_to_text.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.speech_v1 import SpeechClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/stackdriver.py b/providers/src/airflow/providers/google/cloud/hooks/stackdriver.py index 57fadda627822..a24c540c73d1c 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/stackdriver.py +++ b/providers/src/airflow/providers/google/cloud/hooks/stackdriver.py @@ -21,7 +21,8 @@ import contextlib import json -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import InvalidArgument from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/tasks.py b/providers/src/airflow/providers/google/cloud/hooks/tasks.py index 92943482da54c..98a859a58e43e 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/tasks.py +++ b/providers/src/airflow/providers/google/cloud/hooks/tasks.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.tasks_v2 import CloudTasksClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/text_to_speech.py b/providers/src/airflow/providers/google/cloud/hooks/text_to_speech.py index 789892cfb4efe..be2e7a3cd3818 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/text_to_speech.py +++ b/providers/src/airflow/providers/google/cloud/hooks/text_to_speech.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.texttospeech_v1 import TextToSpeechClient diff --git a/providers/src/airflow/providers/google/cloud/hooks/translate.py b/providers/src/airflow/providers/google/cloud/hooks/translate.py index 6ddb220f3e789..4901e4a9914fc 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/translate.py +++ b/providers/src/airflow/providers/google/cloud/hooks/translate.py @@ -19,11 +19,9 @@ from __future__ import annotations +from collections.abc import MutableMapping, MutableSequence, Sequence from typing import ( TYPE_CHECKING, - MutableMapping, - MutableSequence, - Sequence, cast, ) diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py index 07fabf86e245f..978ab699edacd 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/auto_ml.py @@ -20,7 +20,8 @@ from __future__ import annotations import warnings -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py index 7a805dfdf6ee9..286566a778898 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/batch_prediction_job.py @@ -20,7 +20,8 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py index 64e9370fc9679..9948c7e3acfa3 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py @@ -20,7 +20,8 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/dataset.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/dataset.py index c3c13d349f79e..49461f3f974b0 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/dataset.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/dataset.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py index ce82089bbfa96..7d8d376ebf38a 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/endpoint_service.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py index 4a74ebba6df1c..a3eec0ef855de 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py @@ -26,7 +26,8 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/model_service.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/model_service.py index e1396f217bc2e..ed9e8c7723ebd 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/model_service.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/model_service.py @@ -20,7 +20,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py index a1217608ac0d9..9d91d08cbd5d8 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/pipeline_job.py @@ -26,7 +26,8 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py index 26a647516bd46..9fcc984408892 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vertex_ai/prediction_service.py @@ -17,7 +17,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.client_options import ClientOptions from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/hooks/video_intelligence.py b/providers/src/airflow/providers/google/cloud/hooks/video_intelligence.py index dd0bba6fa8630..df1271b3f75b5 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/video_intelligence.py +++ b/providers/src/airflow/providers/google/cloud/hooks/video_intelligence.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.videointelligence_v1 import ( diff --git a/providers/src/airflow/providers/google/cloud/hooks/vision.py b/providers/src/airflow/providers/google/cloud/hooks/vision.py index 0bf9b4c01573c..a96b75aa13b81 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/vision.py +++ b/providers/src/airflow/providers/google/cloud/hooks/vision.py @@ -19,9 +19,10 @@ from __future__ import annotations +from collections.abc import Sequence from copy import deepcopy from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.vision_v1 import ( diff --git a/providers/src/airflow/providers/google/cloud/hooks/workflows.py b/providers/src/airflow/providers/google/cloud/hooks/workflows.py index 23cc2dd1ea231..cd063c270fc93 100644 --- a/providers/src/airflow/providers/google/cloud/hooks/workflows.py +++ b/providers/src/airflow/providers/google/cloud/hooks/workflows.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.workflows.executions_v1beta import Execution, ExecutionsClient diff --git a/providers/src/airflow/providers/google/cloud/log/gcs_task_handler.py b/providers/src/airflow/providers/google/cloud/log/gcs_task_handler.py index 8c11b2692e6c9..ba2cf4db27d97 100644 --- a/providers/src/airflow/providers/google/cloud/log/gcs_task_handler.py +++ b/providers/src/airflow/providers/google/cloud/log/gcs_task_handler.py @@ -20,9 +20,10 @@ import logging import os import shutil +from collections.abc import Collection from functools import cached_property from pathlib import Path -from typing import TYPE_CHECKING, Collection +from typing import TYPE_CHECKING # not sure why but mypy complains on missing `storage` but it is clearly there and is importable from google.cloud import storage # type: ignore[attr-defined] diff --git a/providers/src/airflow/providers/google/cloud/log/stackdriver_task_handler.py b/providers/src/airflow/providers/google/cloud/log/stackdriver_task_handler.py index e150419f7e045..b26696d290eaf 100644 --- a/providers/src/airflow/providers/google/cloud/log/stackdriver_task_handler.py +++ b/providers/src/airflow/providers/google/cloud/log/stackdriver_task_handler.py @@ -20,8 +20,9 @@ import logging import warnings +from collections.abc import Collection from functools import cached_property -from typing import TYPE_CHECKING, Collection +from typing import TYPE_CHECKING from urllib.parse import urlencode from google.cloud import logging as gcp_logging diff --git a/providers/src/airflow/providers/google/cloud/operators/automl.py b/providers/src/airflow/providers/google/cloud/operators/automl.py index 89d1c617cffea..ffc1371d73bf4 100644 --- a/providers/src/airflow/providers/google/cloud/operators/automl.py +++ b/providers/src/airflow/providers/google/cloud/operators/automl.py @@ -21,8 +21,9 @@ import ast import warnings +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence, Tuple, cast +from typing import TYPE_CHECKING, cast from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.automl_v1beta1 import ( @@ -53,7 +54,7 @@ from airflow.utils.context import Context -MetaData = Sequence[Tuple[str, str]] +MetaData = Sequence[tuple[str, str]] def _raise_exception_for_deprecated_operator( diff --git a/providers/src/airflow/providers/google/cloud/operators/bigquery.py b/providers/src/airflow/providers/google/cloud/operators/bigquery.py index db5566f769b97..a46a33a910898 100644 --- a/providers/src/airflow/providers/google/cloud/operators/bigquery.py +++ b/providers/src/airflow/providers/google/cloud/operators/bigquery.py @@ -23,8 +23,9 @@ import json import re import warnings +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence, SupportsAbs +from typing import TYPE_CHECKING, Any, SupportsAbs from google.api_core.exceptions import Conflict from google.cloud.bigquery import DEFAULT_RETRY, CopyJob, ExtractJob, LoadJob, QueryJob, Row diff --git a/providers/src/airflow/providers/google/cloud/operators/bigquery_dts.py b/providers/src/airflow/providers/google/cloud/operators/bigquery_dts.py index 9619aa3addc9d..a9da994ff6fb0 100644 --- a/providers/src/airflow/providers/google/cloud/operators/bigquery_dts.py +++ b/providers/src/airflow/providers/google/cloud/operators/bigquery_dts.py @@ -20,8 +20,9 @@ from __future__ import annotations import time +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.bigquery_datatransfer_v1 import ( diff --git a/providers/src/airflow/providers/google/cloud/operators/bigtable.py b/providers/src/airflow/providers/google/cloud/operators/bigtable.py index ffd98a82b6994..d33fa159d7b39 100644 --- a/providers/src/airflow/providers/google/cloud/operators/bigtable.py +++ b/providers/src/airflow/providers/google/cloud/operators/bigtable.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING import google.api_core.exceptions diff --git a/providers/src/airflow/providers/google/cloud/operators/cloud_batch.py b/providers/src/airflow/providers/google/cloud/operators/cloud_batch.py index dce17ecba45ef..0587076f9e263 100644 --- a/providers/src/airflow/providers/google/cloud/operators/cloud_batch.py +++ b/providers/src/airflow/providers/google/cloud/operators/cloud_batch.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.cloud.batch_v1 import Job, Task diff --git a/providers/src/airflow/providers/google/cloud/operators/cloud_build.py b/providers/src/airflow/providers/google/cloud/operators/cloud_build.py index 3625e8c427d36..565b2be13aa27 100644 --- a/providers/src/airflow/providers/google/cloud/operators/cloud_build.py +++ b/providers/src/airflow/providers/google/cloud/operators/cloud_build.py @@ -21,8 +21,9 @@ import json import re +from collections.abc import Sequence from copy import deepcopy -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from urllib.parse import unquote, urlsplit from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/cloud_composer.py b/providers/src/airflow/providers/google/cloud/operators/cloud_composer.py index ad63397a176b1..5bc0d11afdbb1 100644 --- a/providers/src/airflow/providers/google/cloud/operators/cloud_composer.py +++ b/providers/src/airflow/providers/google/cloud/operators/cloud_composer.py @@ -18,7 +18,8 @@ from __future__ import annotations import shlex -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import AlreadyExists from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/cloud_memorystore.py b/providers/src/airflow/providers/google/cloud/operators/cloud_memorystore.py index fc83e0f476051..5138ed1cf5143 100644 --- a/providers/src/airflow/providers/google/cloud/operators/cloud_memorystore.py +++ b/providers/src/airflow/providers/google/cloud/operators/cloud_memorystore.py @@ -26,7 +26,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.memcache_v1beta2.types import cloud_memcache diff --git a/providers/src/airflow/providers/google/cloud/operators/cloud_run.py b/providers/src/airflow/providers/google/cloud/operators/cloud_run.py index 01b7f2ff704ca..520d8b168db26 100644 --- a/providers/src/airflow/providers/google/cloud/operators/cloud_run.py +++ b/providers/src/airflow/providers/google/cloud/operators/cloud_run.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any import google.cloud.exceptions from google.api_core.exceptions import AlreadyExists diff --git a/providers/src/airflow/providers/google/cloud/operators/cloud_sql.py b/providers/src/airflow/providers/google/cloud/operators/cloud_sql.py index b971844c9449e..eb75817ae7f4b 100644 --- a/providers/src/airflow/providers/google/cloud/operators/cloud_sql.py +++ b/providers/src/airflow/providers/google/cloud/operators/cloud_sql.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Iterable, Mapping, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Iterable, Mapping, Sequence +from typing import TYPE_CHECKING, Any from googleapiclient.errors import HttpError diff --git a/providers/src/airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py b/providers/src/airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py index 20f1f5e0299e1..808c93147d8c6 100644 --- a/providers/src/airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py +++ b/providers/src/airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py @@ -19,9 +19,10 @@ from __future__ import annotations +from collections.abc import Sequence from copy import deepcopy from datetime import date, time -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook diff --git a/providers/src/airflow/providers/google/cloud/operators/compute.py b/providers/src/airflow/providers/google/cloud/operators/compute.py index 7a3bbc0b19607..b43305c13af33 100644 --- a/providers/src/airflow/providers/google/cloud/operators/compute.py +++ b/providers/src/airflow/providers/google/cloud/operators/compute.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from copy import deepcopy -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from google.api_core import exceptions from google.cloud.compute_v1.types import Instance, InstanceGroupManager, InstanceTemplate diff --git a/providers/src/airflow/providers/google/cloud/operators/datacatalog.py b/providers/src/airflow/providers/google/cloud/operators/datacatalog.py index b725c66246db7..13d29c5772fd4 100644 --- a/providers/src/airflow/providers/google/cloud/operators/datacatalog.py +++ b/providers/src/airflow/providers/google/cloud/operators/datacatalog.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import AlreadyExists, NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/dataflow.py b/providers/src/airflow/providers/google/cloud/operators/dataflow.py index 34a25042ad7ce..3fcbc7f67b784 100644 --- a/providers/src/airflow/providers/google/cloud/operators/dataflow.py +++ b/providers/src/airflow/providers/google/cloud/operators/dataflow.py @@ -20,9 +20,10 @@ from __future__ import annotations import uuid +from collections.abc import Sequence from enum import Enum from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from googleapiclient.errors import HttpError diff --git a/providers/src/airflow/providers/google/cloud/operators/dataform.py b/providers/src/airflow/providers/google/cloud/operators/dataform.py index cbec87c878903..4212cd22a12ec 100644 --- a/providers/src/airflow/providers/google/cloud/operators/dataform.py +++ b/providers/src/airflow/providers/google/cloud/operators/dataform.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.google.cloud.links.dataform import ( DataformRepositoryLink, diff --git a/providers/src/airflow/providers/google/cloud/operators/datafusion.py b/providers/src/airflow/providers/google/cloud/operators/datafusion.py index 4960432e85988..02169748b3984 100644 --- a/providers/src/airflow/providers/google/cloud/operators/datafusion.py +++ b/providers/src/airflow/providers/google/cloud/operators/datafusion.py @@ -19,7 +19,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.retry import exponential_sleep_generator from googleapiclient.errors import HttpError diff --git a/providers/src/airflow/providers/google/cloud/operators/dataplex.py b/providers/src/airflow/providers/google/cloud/operators/dataplex.py index f77c648f20e18..8f7a0d694b9f3 100644 --- a/providers/src/airflow/providers/google/cloud/operators/dataplex.py +++ b/providers/src/airflow/providers/google/cloud/operators/dataplex.py @@ -19,7 +19,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.providers.google.cloud.triggers.dataplex import ( diff --git a/providers/src/airflow/providers/google/cloud/operators/dataprep.py b/providers/src/airflow/providers/google/cloud/operators/dataprep.py index 4636e8beb773d..f25a4cc783b3b 100644 --- a/providers/src/airflow/providers/google/cloud/operators/dataprep.py +++ b/providers/src/airflow/providers/google/cloud/operators/dataprep.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.google.cloud.hooks.dataprep import GoogleDataprepHook from airflow.providers.google.cloud.links.dataprep import DataprepFlowLink, DataprepJobGroupLink diff --git a/providers/src/airflow/providers/google/cloud/operators/dataproc.py b/providers/src/airflow/providers/google/cloud/operators/dataproc.py index d8569e9cb932a..f029493fd0c1a 100644 --- a/providers/src/airflow/providers/google/cloud/operators/dataproc.py +++ b/providers/src/airflow/providers/google/cloud/operators/dataproc.py @@ -23,12 +23,12 @@ import re import time import warnings -from collections.abc import MutableSequence +from collections.abc import MutableSequence, Sequence from dataclasses import dataclass from datetime import datetime, timedelta from enum import Enum from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import AlreadyExists, NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/dataproc_metastore.py b/providers/src/airflow/providers/google/cloud/operators/dataproc_metastore.py index aa7dbafd22617..a9470b17e3e3c 100644 --- a/providers/src/airflow/providers/google/cloud/operators/dataproc_metastore.py +++ b/providers/src/airflow/providers/google/cloud/operators/dataproc_metastore.py @@ -20,7 +20,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import AlreadyExists from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/datastore.py b/providers/src/airflow/providers/google/cloud/operators/datastore.py index f3ac9054f0b4c..7738910ea69b5 100644 --- a/providers/src/airflow/providers/google/cloud/operators/datastore.py +++ b/providers/src/airflow/providers/google/cloud/operators/datastore.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.providers.google.cloud.hooks.datastore import DatastoreHook diff --git a/providers/src/airflow/providers/google/cloud/operators/dlp.py b/providers/src/airflow/providers/google/cloud/operators/dlp.py index 9941574ae5561..eca84824f0543 100644 --- a/providers/src/airflow/providers/google/cloud/operators/dlp.py +++ b/providers/src/airflow/providers/google/cloud/operators/dlp.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import AlreadyExists, InvalidArgument, NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/functions.py b/providers/src/airflow/providers/google/cloud/operators/functions.py index 589459003dc54..9b067fec76518 100644 --- a/providers/src/airflow/providers/google/cloud/operators/functions.py +++ b/providers/src/airflow/providers/google/cloud/operators/functions.py @@ -20,7 +20,8 @@ from __future__ import annotations import re -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from googleapiclient.errors import HttpError diff --git a/providers/src/airflow/providers/google/cloud/operators/gcs.py b/providers/src/airflow/providers/google/cloud/operators/gcs.py index ae4344aeb4c81..0cb8527d526da 100644 --- a/providers/src/airflow/providers/google/cloud/operators/gcs.py +++ b/providers/src/airflow/providers/google/cloud/operators/gcs.py @@ -23,9 +23,10 @@ import subprocess import sys import warnings +from collections.abc import Sequence from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING import pendulum diff --git a/providers/src/airflow/providers/google/cloud/operators/kubernetes_engine.py b/providers/src/airflow/providers/google/cloud/operators/kubernetes_engine.py index 84de9cfdafcbf..82c3dd0ffefd6 100644 --- a/providers/src/airflow/providers/google/cloud/operators/kubernetes_engine.py +++ b/providers/src/airflow/providers/google/cloud/operators/kubernetes_engine.py @@ -20,8 +20,9 @@ from __future__ import annotations import warnings +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any import requests import yaml diff --git a/providers/src/airflow/providers/google/cloud/operators/life_sciences.py b/providers/src/airflow/providers/google/cloud/operators/life_sciences.py index d79aae83bd349..3389c1bdb8bb7 100644 --- a/providers/src/airflow/providers/google/cloud/operators/life_sciences.py +++ b/providers/src/airflow/providers/google/cloud/operators/life_sciences.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning from airflow.providers.google.cloud.hooks.life_sciences import LifeSciencesHook diff --git a/providers/src/airflow/providers/google/cloud/operators/mlengine.py b/providers/src/airflow/providers/google/cloud/operators/mlengine.py index 4da055075e9a7..f6e43f71ab400 100644 --- a/providers/src/airflow/providers/google/cloud/operators/mlengine.py +++ b/providers/src/airflow/providers/google/cloud/operators/mlengine.py @@ -22,7 +22,8 @@ import logging import re import time -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from googleapiclient.errors import HttpError diff --git a/providers/src/airflow/providers/google/cloud/operators/natural_language.py b/providers/src/airflow/providers/google/cloud/operators/natural_language.py index ea58ab9c33a40..edd9a4c2ac820 100644 --- a/providers/src/airflow/providers/google/cloud/operators/natural_language.py +++ b/providers/src/airflow/providers/google/cloud/operators/natural_language.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence, Tuple +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.protobuf.json_format import MessageToDict @@ -34,7 +35,7 @@ from airflow.utils.context import Context -MetaData = Sequence[Tuple[str, str]] +MetaData = Sequence[tuple[str, str]] class CloudNaturalLanguageAnalyzeEntitiesOperator(GoogleCloudBaseOperator): diff --git a/providers/src/airflow/providers/google/cloud/operators/pubsub.py b/providers/src/airflow/providers/google/cloud/operators/pubsub.py index 28b620f8f3c1b..81e1c88c822fa 100644 --- a/providers/src/airflow/providers/google/cloud/operators/pubsub.py +++ b/providers/src/airflow/providers/google/cloud/operators/pubsub.py @@ -25,7 +25,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.pubsub_v1.types import ( diff --git a/providers/src/airflow/providers/google/cloud/operators/spanner.py b/providers/src/airflow/providers/google/cloud/operators/spanner.py index b6e25a369f610..e93a8c30ace67 100644 --- a/providers/src/airflow/providers/google/cloud/operators/spanner.py +++ b/providers/src/airflow/providers/google/cloud/operators/spanner.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.google.cloud.hooks.spanner import SpannerHook diff --git a/providers/src/airflow/providers/google/cloud/operators/speech_to_text.py b/providers/src/airflow/providers/google/cloud/operators/speech_to_text.py index f8c3e4703f9e0..752e7d3454be0 100644 --- a/providers/src/airflow/providers/google/cloud/operators/speech_to_text.py +++ b/providers/src/airflow/providers/google/cloud/operators/speech_to_text.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.protobuf.json_format import MessageToDict diff --git a/providers/src/airflow/providers/google/cloud/operators/stackdriver.py b/providers/src/airflow/providers/google/cloud/operators/stackdriver.py index ca64e3995c272..2edc126479e12 100644 --- a/providers/src/airflow/providers/google/cloud/operators/stackdriver.py +++ b/providers/src/airflow/providers/google/cloud/operators/stackdriver.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.monitoring_v3 import AlertPolicy, NotificationChannel diff --git a/providers/src/airflow/providers/google/cloud/operators/tasks.py b/providers/src/airflow/providers/google/cloud/operators/tasks.py index 8678622b686e1..735f8fbde9fa9 100644 --- a/providers/src/airflow/providers/google/cloud/operators/tasks.py +++ b/providers/src/airflow/providers/google/cloud/operators/tasks.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence, Tuple +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import AlreadyExists from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault @@ -37,7 +38,7 @@ from airflow.utils.context import Context -MetaData = Sequence[Tuple[str, str]] +MetaData = Sequence[tuple[str, str]] class CloudTasksQueueCreateOperator(GoogleCloudBaseOperator): diff --git a/providers/src/airflow/providers/google/cloud/operators/text_to_speech.py b/providers/src/airflow/providers/google/cloud/operators/text_to_speech.py index bae69d6598486..adb4bb6a9d376 100644 --- a/providers/src/airflow/providers/google/cloud/operators/text_to_speech.py +++ b/providers/src/airflow/providers/google/cloud/operators/text_to_speech.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/translate.py b/providers/src/airflow/providers/google/cloud/operators/translate.py index d384e9b8efa9b..193433deaa7c8 100644 --- a/providers/src/airflow/providers/google/cloud/operators/translate.py +++ b/providers/src/airflow/providers/google/cloud/operators/translate.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, MutableMapping, MutableSequence, Sequence +from collections.abc import MutableMapping, MutableSequence, Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import GoogleAPICallError from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/translate_speech.py b/providers/src/airflow/providers/google/cloud/operators/translate_speech.py index b0b540c31e086..e92865beda17f 100644 --- a/providers/src/airflow/providers/google/cloud/operators/translate_speech.py +++ b/providers/src/airflow/providers/google/cloud/operators/translate_speech.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.protobuf.json_format import MessageToDict diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py index d3069984a8300..1ca440170698b 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/auto_ml.py @@ -20,7 +20,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py index 97f5b508e752f..705f6e31154fd 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/batch_prediction_job.py @@ -20,8 +20,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/custom_job.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/custom_job.py index ebde5c24597ad..fa901b4cae654 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/custom_job.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/custom_job.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/dataset.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/dataset.py index 5aae8b07e521a..0d5754fc3f9e0 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/dataset.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/dataset.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py index 3a53efbf4d7e9..db485d5cfcc77 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/endpoint_service.py @@ -20,7 +20,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/generative_model.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/generative_model.py index 05a4abf138073..78eba3338961a 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/generative_model.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/generative_model.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowProviderDeprecationWarning from airflow.providers.google.cloud.hooks.vertex_ai.generative_model import GenerativeModelHook diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py index 4c3ce251f06bf..b0928f67ca9b0 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py @@ -20,7 +20,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/model_service.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/model_service.py index 48fb9154ce051..79980685c0b14 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/model_service.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/model_service.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py index 716c509a2e264..883dafe6a74eb 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py +++ b/providers/src/airflow/providers/google/cloud/operators/vertex_ai/pipeline_job.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import NotFound from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/operators/video_intelligence.py b/providers/src/airflow/providers/google/cloud/operators/video_intelligence.py index da524c872fde9..0d4da307f63b8 100644 --- a/providers/src/airflow/providers/google/cloud/operators/video_intelligence.py +++ b/providers/src/airflow/providers/google/cloud/operators/video_intelligence.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.videointelligence_v1 import Feature, VideoContext diff --git a/providers/src/airflow/providers/google/cloud/operators/vision.py b/providers/src/airflow/providers/google/cloud/operators/vision.py index 62905315de65f..3f1c0bd74ce82 100644 --- a/providers/src/airflow/providers/google/cloud/operators/vision.py +++ b/providers/src/airflow/providers/google/cloud/operators/vision.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from copy import deepcopy -from typing import TYPE_CHECKING, Any, Sequence, Tuple +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import AlreadyExists from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault @@ -43,7 +44,7 @@ from airflow.utils.context import Context -MetaData = Sequence[Tuple[str, str]] +MetaData = Sequence[tuple[str, str]] class CloudVisionCreateProductSetOperator(GoogleCloudBaseOperator): diff --git a/providers/src/airflow/providers/google/cloud/operators/workflows.py b/providers/src/airflow/providers/google/cloud/operators/workflows.py index 86c232bf05678..70b8eaef3950c 100644 --- a/providers/src/airflow/providers/google/cloud/operators/workflows.py +++ b/providers/src/airflow/providers/google/cloud/operators/workflows.py @@ -20,7 +20,8 @@ import json import re import uuid -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import AlreadyExists from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault diff --git a/providers/src/airflow/providers/google/cloud/secrets/secret_manager.py b/providers/src/airflow/providers/google/cloud/secrets/secret_manager.py index b0f7ba5233772..6f84b9a6f97fb 100644 --- a/providers/src/airflow/providers/google/cloud/secrets/secret_manager.py +++ b/providers/src/airflow/providers/google/cloud/secrets/secret_manager.py @@ -19,7 +19,7 @@ from __future__ import annotations import logging -from typing import Sequence +from collections.abc import Sequence from google.auth.exceptions import DefaultCredentialsError diff --git a/providers/src/airflow/providers/google/cloud/sensors/bigquery.py b/providers/src/airflow/providers/google/cloud/sensors/bigquery.py index c63ad5ca7a917..a4cbce91c6f1e 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/bigquery.py +++ b/providers/src/airflow/providers/google/cloud/sensors/bigquery.py @@ -20,8 +20,9 @@ from __future__ import annotations import warnings +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning diff --git a/providers/src/airflow/providers/google/cloud/sensors/bigquery_dts.py b/providers/src/airflow/providers/google/cloud/sensors/bigquery_dts.py index c7e158db07025..96215849cdd1e 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/bigquery_dts.py +++ b/providers/src/airflow/providers/google/cloud/sensors/bigquery_dts.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.bigquery_datatransfer_v1 import TransferState diff --git a/providers/src/airflow/providers/google/cloud/sensors/bigtable.py b/providers/src/airflow/providers/google/cloud/sensors/bigtable.py index f9cd61b9adfac..f67ebfc59a68c 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/bigtable.py +++ b/providers/src/airflow/providers/google/cloud/sensors/bigtable.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING import google.api_core.exceptions from google.cloud.bigtable import enums diff --git a/providers/src/airflow/providers/google/cloud/sensors/cloud_composer.py b/providers/src/airflow/providers/google/cloud/sensors/cloud_composer.py index 8389b82522779..d6e1622abefae 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/cloud_composer.py +++ b/providers/src/airflow/providers/google/cloud/sensors/cloud_composer.py @@ -20,8 +20,9 @@ from __future__ import annotations import json +from collections.abc import Iterable, Sequence from datetime import datetime, timedelta -from typing import TYPE_CHECKING, Iterable, Sequence +from typing import TYPE_CHECKING from dateutil import parser from google.cloud.orchestration.airflow.service_v1.types import ExecuteAirflowCommandResponse diff --git a/providers/src/airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py b/providers/src/airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py index ca5ac0087414a..575971c2e0c87 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py +++ b/providers/src/airflow/providers/google/cloud/sensors/cloud_storage_transfer_service.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.google.cloud.hooks.cloud_storage_transfer_service import ( COUNTERS, diff --git a/providers/src/airflow/providers/google/cloud/sensors/dataflow.py b/providers/src/airflow/providers/google/cloud/sensors/dataflow.py index eebd03d8d3a99..a38cc2db9ee17 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/dataflow.py +++ b/providers/src/airflow/providers/google/cloud/sensors/dataflow.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/google/cloud/sensors/dataform.py b/providers/src/airflow/providers/google/cloud/sensors/dataform.py index 17d1351404fa4..6e300333ba1c1 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/dataform.py +++ b/providers/src/airflow/providers/google/cloud/sensors/dataform.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.google.cloud.hooks.dataform import DataformHook diff --git a/providers/src/airflow/providers/google/cloud/sensors/datafusion.py b/providers/src/airflow/providers/google/cloud/sensors/datafusion.py index a3bea76351132..29335949b15c1 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/datafusion.py +++ b/providers/src/airflow/providers/google/cloud/sensors/datafusion.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException, AirflowNotFoundException from airflow.providers.google.cloud.hooks.datafusion import DataFusionHook diff --git a/providers/src/airflow/providers/google/cloud/sensors/dataplex.py b/providers/src/airflow/providers/google/cloud/sensors/dataplex.py index ea6d2003d828b..b1ff0fdccf83b 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/dataplex.py +++ b/providers/src/airflow/providers/google/cloud/sensors/dataplex.py @@ -19,7 +19,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING if TYPE_CHECKING: from google.api_core.retry import Retry diff --git a/providers/src/airflow/providers/google/cloud/sensors/dataprep.py b/providers/src/airflow/providers/google/cloud/sensors/dataprep.py index bcf7df05b1bed..333dc03c14ecf 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/dataprep.py +++ b/providers/src/airflow/providers/google/cloud/sensors/dataprep.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.google.cloud.hooks.dataprep import GoogleDataprepHook, JobGroupStatuses from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/google/cloud/sensors/dataproc.py b/providers/src/airflow/providers/google/cloud/sensors/dataproc.py index f533b56ec5d0a..4b1a5b98d2045 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/dataproc.py +++ b/providers/src/airflow/providers/google/cloud/sensors/dataproc.py @@ -20,7 +20,8 @@ from __future__ import annotations import time -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.exceptions import ServerError from google.cloud.dataproc_v1.types import Batch, JobStatus diff --git a/providers/src/airflow/providers/google/cloud/sensors/dataproc_metastore.py b/providers/src/airflow/providers/google/cloud/sensors/dataproc_metastore.py index 9413f43298182..a3c712e783688 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/dataproc_metastore.py +++ b/providers/src/airflow/providers/google/cloud/sensors/dataproc_metastore.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.google.cloud.hooks.dataproc_metastore import DataprocMetastoreHook diff --git a/providers/src/airflow/providers/google/cloud/sensors/gcs.py b/providers/src/airflow/providers/google/cloud/sensors/gcs.py index 3b6b2e6d9ed32..569efea172c6c 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/gcs.py +++ b/providers/src/airflow/providers/google/cloud/sensors/gcs.py @@ -21,8 +21,9 @@ import os import textwrap +from collections.abc import Sequence from datetime import datetime, timedelta -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable from google.cloud.storage.retry import DEFAULT_RETRY diff --git a/providers/src/airflow/providers/google/cloud/sensors/pubsub.py b/providers/src/airflow/providers/google/cloud/sensors/pubsub.py index aa74411f072e5..03cf00f56695b 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/pubsub.py +++ b/providers/src/airflow/providers/google/cloud/sensors/pubsub.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable from google.cloud import pubsub_v1 from google.cloud.pubsub_v1.types import ReceivedMessage diff --git a/providers/src/airflow/providers/google/cloud/sensors/tasks.py b/providers/src/airflow/providers/google/cloud/sensors/tasks.py index b5631b6b8ede3..aa87914d066d1 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/tasks.py +++ b/providers/src/airflow/providers/google/cloud/sensors/tasks.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.google.cloud.hooks.tasks import CloudTasksHook from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID diff --git a/providers/src/airflow/providers/google/cloud/sensors/workflows.py b/providers/src/airflow/providers/google/cloud/sensors/workflows.py index aeacef4636e29..eeca15f0d76fb 100644 --- a/providers/src/airflow/providers/google/cloud/sensors/workflows.py +++ b/providers/src/airflow/providers/google/cloud/sensors/workflows.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault from google.cloud.workflows.executions_v1beta import Execution diff --git a/providers/src/airflow/providers/google/cloud/transfers/adls_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/adls_to_gcs.py index f11b6aa881b80..a445138e1ff0f 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/adls_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/adls_to_gcs.py @@ -20,8 +20,9 @@ from __future__ import annotations import os +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.providers.google.cloud.hooks.gcs import GCSHook, _parse_gcs_url diff --git a/providers/src/airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py index 9642339ba8b15..303f0c00761a1 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/azure_blob_to_gcs.py @@ -18,7 +18,8 @@ from __future__ import annotations import tempfile -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py index 6b9970481ddd6..9dd3ca6015f47 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/azure_fileshare_to_gcs.py @@ -18,8 +18,9 @@ from __future__ import annotations import warnings +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py index e1f3d3b13f565..403314362a782 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py +++ b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_bigquery.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.bigquery import BigQueryHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_gcs.py index 2833f79a3e81a..b776d102f103f 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_gcs.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import Conflict from google.cloud.bigquery import DEFAULT_RETRY, UnknownJob diff --git a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_mssql.py b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_mssql.py index 8a5749dc9e2ce..e10badd8b508b 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_mssql.py +++ b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_mssql.py @@ -20,7 +20,8 @@ from __future__ import annotations import warnings -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowProviderDeprecationWarning from airflow.providers.google.cloud.links.bigquery import BigQueryTableLink diff --git a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_mysql.py b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_mysql.py index a2c77f70e18df..22c35d0a243f6 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_mysql.py +++ b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_mysql.py @@ -20,7 +20,7 @@ from __future__ import annotations import warnings -from typing import Sequence +from collections.abc import Sequence from airflow.exceptions import AirflowProviderDeprecationWarning from airflow.providers.google.cloud.transfers.bigquery_to_sql import BigQueryToSqlBaseOperator diff --git a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_sql.py b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_sql.py index dacba73934932..081bb8df9d63e 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_sql.py +++ b/providers/src/airflow/providers/google/cloud/transfers/bigquery_to_sql.py @@ -20,7 +20,8 @@ from __future__ import annotations import abc -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.bigquery import BigQueryHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/calendar_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/calendar_to_gcs.py index c9c3f585859f6..f9d7b977db0c1 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/calendar_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/calendar_to_gcs.py @@ -17,8 +17,9 @@ from __future__ import annotations import json +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/cassandra_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/cassandra_to_gcs.py index 8537834f65a99..ec6dba891d004 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/cassandra_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/cassandra_to_gcs.py @@ -21,10 +21,11 @@ import json from base64 import b64encode +from collections.abc import Iterable, Sequence from datetime import datetime from decimal import Decimal from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Any, Iterable, NewType, Sequence +from typing import TYPE_CHECKING, Any, NewType from uuid import UUID from cassandra.util import Date, OrderedMapSerializedKey, SortedSet, Time diff --git a/providers/src/airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py index 2a33cb01972ac..8d6adc398d8b1 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/facebook_ads_to_gcs.py @@ -21,8 +21,9 @@ import csv import tempfile +from collections.abc import Sequence from enum import Enum -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py b/providers/src/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py index 6dfe1bd1a2c31..7558ebf735d1b 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py +++ b/providers/src/airflow/providers/google/cloud/transfers/gcs_to_bigquery.py @@ -20,7 +20,8 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import BadRequest, Conflict from google.cloud.bigquery import ( diff --git a/providers/src/airflow/providers/google/cloud/transfers/gcs_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/gcs_to_gcs.py index 8980436a10536..07ebdef892b02 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/gcs_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/gcs_to_gcs.py @@ -20,7 +20,8 @@ from __future__ import annotations import warnings -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/cloud/transfers/gcs_to_local.py b/providers/src/airflow/providers/google/cloud/transfers/gcs_to_local.py index b496a3cf6adcb..bdcee1006ff56 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/gcs_to_local.py +++ b/providers/src/airflow/providers/google/cloud/transfers/gcs_to_local.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/cloud/transfers/gcs_to_sftp.py b/providers/src/airflow/providers/google/cloud/transfers/gcs_to_sftp.py index 15be76a957870..4210cdc041f81 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/gcs_to_sftp.py +++ b/providers/src/airflow/providers/google/cloud/transfers/gcs_to_sftp.py @@ -20,8 +20,9 @@ from __future__ import annotations import os +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/cloud/transfers/gdrive_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/gdrive_to_gcs.py index 1ba0051038dad..dc57fd712c568 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/gdrive_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/gdrive_to_gcs.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/gdrive_to_local.py b/providers/src/airflow/providers/google/cloud/transfers/gdrive_to_local.py index 7d68127f62101..22dcc9f67ccb8 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/gdrive_to_local.py +++ b/providers/src/airflow/providers/google/cloud/transfers/gdrive_to_local.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.suite.hooks.drive import GoogleDriveHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/local_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/local_to_gcs.py index a5e9806d2c515..eeed05c1d002a 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/local_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/local_to_gcs.py @@ -20,8 +20,9 @@ from __future__ import annotations import os +from collections.abc import Sequence from glob import glob -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/mssql_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/mssql_to_gcs.py index 7668f51e6cf65..6bcd9f38ff08a 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/mssql_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/mssql_to_gcs.py @@ -21,7 +21,7 @@ import datetime import decimal -from typing import Sequence +from collections.abc import Sequence from airflow.providers.google.cloud.transfers.sql_to_gcs import BaseSQLToGCSOperator from airflow.providers.microsoft.mssql.hooks.mssql import MsSqlHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/s3_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/s3_to_gcs.py index 67783014b2fc1..cbd82724ede67 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/s3_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/s3_to_gcs.py @@ -17,9 +17,10 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from datetime import datetime, timezone from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/google/cloud/transfers/salesforce_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/salesforce_to_gcs.py index a46d75d21f6b0..b83f09be70b24 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/salesforce_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/salesforce_to_gcs.py @@ -18,7 +18,8 @@ import os import tempfile -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/sftp_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/sftp_to_gcs.py index 57af1fdebeda8..77bd28116cb7f 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/sftp_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/sftp_to_gcs.py @@ -20,8 +20,9 @@ from __future__ import annotations import os +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/cloud/transfers/sheets_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/sheets_to_gcs.py index a54bc3a2fb276..8c681bc5c9db6 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/sheets_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/sheets_to_gcs.py @@ -17,8 +17,9 @@ from __future__ import annotations import csv +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/google/cloud/transfers/sql_to_gcs.py b/providers/src/airflow/providers/google/cloud/transfers/sql_to_gcs.py index 49e2daa2ca1c4..2ce2260720aae 100644 --- a/providers/src/airflow/providers/google/cloud/transfers/sql_to_gcs.py +++ b/providers/src/airflow/providers/google/cloud/transfers/sql_to_gcs.py @@ -23,8 +23,9 @@ import csv import json import os +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any import pyarrow as pa import pyarrow.parquet as pq diff --git a/providers/src/airflow/providers/google/cloud/triggers/bigquery.py b/providers/src/airflow/providers/google/cloud/triggers/bigquery.py index fc19db988126f..13d9f55bacb45 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/bigquery.py +++ b/providers/src/airflow/providers/google/cloud/triggers/bigquery.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Any, AsyncIterator, Sequence, SupportsAbs +from collections.abc import AsyncIterator, Sequence +from typing import TYPE_CHECKING, Any, SupportsAbs from aiohttp import ClientSession from aiohttp.client_exceptions import ClientResponseError diff --git a/providers/src/airflow/providers/google/cloud/triggers/bigquery_dts.py b/providers/src/airflow/providers/google/cloud/triggers/bigquery_dts.py index 4d4d7fbdfa892..6c99c8ef7cf2c 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/bigquery_dts.py +++ b/providers/src/airflow/providers/google/cloud/triggers/bigquery_dts.py @@ -18,7 +18,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncIterator, Sequence +from collections.abc import AsyncIterator, Sequence +from typing import Any from google.cloud.bigquery_datatransfer_v1 import TransferRun, TransferState diff --git a/providers/src/airflow/providers/google/cloud/triggers/cloud_batch.py b/providers/src/airflow/providers/google/cloud/triggers/cloud_batch.py index f54684b6c1ffc..6e994ac80d779 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/cloud_batch.py +++ b/providers/src/airflow/providers/google/cloud/triggers/cloud_batch.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncIterator, Sequence +from collections.abc import AsyncIterator, Sequence +from typing import Any from google.cloud.batch_v1 import Job, JobStatus diff --git a/providers/src/airflow/providers/google/cloud/triggers/cloud_build.py b/providers/src/airflow/providers/google/cloud/triggers/cloud_build.py index 20fd5d701ec80..5834d41ff7bb2 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/cloud_build.py +++ b/providers/src/airflow/providers/google/cloud/triggers/cloud_build.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncIterator, Sequence +from collections.abc import AsyncIterator, Sequence +from typing import Any from google.cloud.devtools.cloudbuild_v1.types import Build diff --git a/providers/src/airflow/providers/google/cloud/triggers/cloud_composer.py b/providers/src/airflow/providers/google/cloud/triggers/cloud_composer.py index 16436a254e3de..c13681aaeff7c 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/cloud_composer.py +++ b/providers/src/airflow/providers/google/cloud/triggers/cloud_composer.py @@ -20,8 +20,9 @@ import asyncio import json +from collections.abc import Sequence from datetime import datetime -from typing import Any, Sequence +from typing import Any from dateutil import parser from google.cloud.orchestration.airflow.service_v1.types import ExecuteAirflowCommandResponse diff --git a/providers/src/airflow/providers/google/cloud/triggers/cloud_run.py b/providers/src/airflow/providers/google/cloud/triggers/cloud_run.py index f91f5a8c3e0a6..106f4ad95008d 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/cloud_run.py +++ b/providers/src/airflow/providers/google/cloud/triggers/cloud_run.py @@ -17,8 +17,9 @@ from __future__ import annotations import asyncio +from collections.abc import AsyncIterator, Sequence from enum import Enum -from typing import TYPE_CHECKING, Any, AsyncIterator, Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.providers.google.cloud.hooks.cloud_run import CloudRunAsyncHook diff --git a/providers/src/airflow/providers/google/cloud/triggers/cloud_sql.py b/providers/src/airflow/providers/google/cloud/triggers/cloud_sql.py index 98dcc54650c3b..e7381c0463f99 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/cloud_sql.py +++ b/providers/src/airflow/providers/google/cloud/triggers/cloud_sql.py @@ -20,7 +20,7 @@ from __future__ import annotations import asyncio -from typing import Sequence +from collections.abc import Sequence from airflow.providers.google.cloud.hooks.cloud_sql import CloudSQLAsyncHook, CloudSqlOperationStatus from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID diff --git a/providers/src/airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py b/providers/src/airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py index 90f3ad1a33bee..e95df81277902 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py +++ b/providers/src/airflow/providers/google/cloud/triggers/cloud_storage_transfer_service.py @@ -18,7 +18,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncIterator, Iterable +from collections.abc import AsyncIterator, Iterable +from typing import Any from google.api_core.exceptions import GoogleAPIError from google.cloud.storage_transfer_v1.types import TransferOperation diff --git a/providers/src/airflow/providers/google/cloud/triggers/dataflow.py b/providers/src/airflow/providers/google/cloud/triggers/dataflow.py index 4b994bf6e4d7d..e368949ce3d51 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/dataflow.py +++ b/providers/src/airflow/providers/google/cloud/triggers/dataflow.py @@ -18,8 +18,9 @@ from __future__ import annotations import asyncio +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from google.cloud.dataflow_v1beta3 import JobState from google.cloud.dataflow_v1beta3.types import ( diff --git a/providers/src/airflow/providers/google/cloud/triggers/datafusion.py b/providers/src/airflow/providers/google/cloud/triggers/datafusion.py index 563b03ccd2c2f..6a130e63b2ca0 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/datafusion.py +++ b/providers/src/airflow/providers/google/cloud/triggers/datafusion.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncIterator, Sequence +from collections.abc import AsyncIterator, Sequence +from typing import Any from airflow.providers.google.cloud.hooks.datafusion import DataFusionAsyncHook from airflow.providers.google.cloud.utils.datafusion import DataFusionPipelineType diff --git a/providers/src/airflow/providers/google/cloud/triggers/dataplex.py b/providers/src/airflow/providers/google/cloud/triggers/dataplex.py index 07ac958ef4261..f9b83e004b571 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/dataplex.py +++ b/providers/src/airflow/providers/google/cloud/triggers/dataplex.py @@ -20,7 +20,7 @@ from __future__ import annotations import asyncio -from typing import AsyncIterator, Sequence +from collections.abc import AsyncIterator, Sequence from google.cloud.dataplex_v1.types import DataScanJob diff --git a/providers/src/airflow/providers/google/cloud/triggers/dataproc.py b/providers/src/airflow/providers/google/cloud/triggers/dataproc.py index 508b0444c05aa..80afd381cc389 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/dataproc.py +++ b/providers/src/airflow/providers/google/cloud/triggers/dataproc.py @@ -22,7 +22,8 @@ import asyncio import re import time -from typing import TYPE_CHECKING, Any, AsyncIterator, Sequence +from collections.abc import AsyncIterator, Sequence +from typing import TYPE_CHECKING, Any from google.api_core.exceptions import NotFound from google.cloud.dataproc_v1 import Batch, Cluster, ClusterStatus, JobStatus diff --git a/providers/src/airflow/providers/google/cloud/triggers/gcs.py b/providers/src/airflow/providers/google/cloud/triggers/gcs.py index 9054260ee5bac..c0e1b422e7f0e 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/gcs.py +++ b/providers/src/airflow/providers/google/cloud/triggers/gcs.py @@ -19,8 +19,9 @@ import asyncio import os +from collections.abc import AsyncIterator from datetime import datetime -from typing import Any, AsyncIterator +from typing import Any from aiohttp import ClientSession diff --git a/providers/src/airflow/providers/google/cloud/triggers/kubernetes_engine.py b/providers/src/airflow/providers/google/cloud/triggers/kubernetes_engine.py index 483b72e60e41b..074ba568d944b 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/kubernetes_engine.py +++ b/providers/src/airflow/providers/google/cloud/triggers/kubernetes_engine.py @@ -19,8 +19,9 @@ import asyncio import warnings +from collections.abc import AsyncIterator, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, AsyncIterator, Sequence +from typing import TYPE_CHECKING, Any from google.cloud.container_v1.types import Operation from packaging.version import parse as parse_version diff --git a/providers/src/airflow/providers/google/cloud/triggers/mlengine.py b/providers/src/airflow/providers/google/cloud/triggers/mlengine.py index b4ae37c681939..e0afe3a641e2a 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/mlengine.py +++ b/providers/src/airflow/providers/google/cloud/triggers/mlengine.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncIterator, Sequence +from collections.abc import AsyncIterator, Sequence +from typing import Any from airflow.providers.google.cloud.hooks.mlengine import MLEngineAsyncHook from airflow.providers.google.common.hooks.base_google import PROVIDE_PROJECT_ID diff --git a/providers/src/airflow/providers/google/cloud/triggers/pubsub.py b/providers/src/airflow/providers/google/cloud/triggers/pubsub.py index e98603006f725..8b60801fd2d7c 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/pubsub.py +++ b/providers/src/airflow/providers/google/cloud/triggers/pubsub.py @@ -19,8 +19,9 @@ from __future__ import annotations import asyncio +from collections.abc import AsyncIterator, Sequence from functools import cached_property -from typing import Any, AsyncIterator, Sequence +from typing import Any from google.cloud.pubsub_v1.types import ReceivedMessage diff --git a/providers/src/airflow/providers/google/cloud/triggers/vertex_ai.py b/providers/src/airflow/providers/google/cloud/triggers/vertex_ai.py index b3e87d3808317..98c53411308ec 100644 --- a/providers/src/airflow/providers/google/cloud/triggers/vertex_ai.py +++ b/providers/src/airflow/providers/google/cloud/triggers/vertex_ai.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import AsyncIterator, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, AsyncIterator, Sequence +from typing import TYPE_CHECKING, Any from google.cloud.aiplatform_v1 import ( BatchPredictionJob, diff --git a/providers/src/airflow/providers/google/cloud/utils/credentials_provider.py b/providers/src/airflow/providers/google/cloud/utils/credentials_provider.py index 22c6de17d57c9..34a1a5aa55a6d 100644 --- a/providers/src/airflow/providers/google/cloud/utils/credentials_provider.py +++ b/providers/src/airflow/providers/google/cloud/utils/credentials_provider.py @@ -23,8 +23,8 @@ import logging import os import tempfile +from collections.abc import Collection, Generator, Sequence from contextlib import ExitStack, contextmanager -from typing import Collection, Generator, Sequence from urllib.parse import urlencode import google.auth diff --git a/providers/src/airflow/providers/google/cloud/utils/dataform.py b/providers/src/airflow/providers/google/cloud/utils/dataform.py index 636a605ab60e5..c5fe3fd3e2c46 100644 --- a/providers/src/airflow/providers/google/cloud/utils/dataform.py +++ b/providers/src/airflow/providers/google/cloud/utils/dataform.py @@ -18,8 +18,8 @@ from __future__ import annotations import json +from collections.abc import Mapping from enum import Enum -from typing import Mapping from airflow.providers.google.cloud.operators.dataform import ( DataformInstallNpmPackagesOperator, diff --git a/providers/src/airflow/providers/google/cloud/utils/field_validator.py b/providers/src/airflow/providers/google/cloud/utils/field_validator.py index 621cf499f8aa2..4a1f25ef25a6d 100644 --- a/providers/src/airflow/providers/google/cloud/utils/field_validator.py +++ b/providers/src/airflow/providers/google/cloud/utils/field_validator.py @@ -134,7 +134,8 @@ from __future__ import annotations import re -from typing import Callable, Sequence +from collections.abc import Sequence +from typing import Callable from airflow.exceptions import AirflowException from airflow.utils.log.logging_mixin import LoggingMixin diff --git a/providers/src/airflow/providers/google/cloud/utils/mlengine_operator_utils.py b/providers/src/airflow/providers/google/cloud/utils/mlengine_operator_utils.py index eb128ef285729..412b699421a21 100644 --- a/providers/src/airflow/providers/google/cloud/utils/mlengine_operator_utils.py +++ b/providers/src/airflow/providers/google/cloud/utils/mlengine_operator_utils.py @@ -22,7 +22,8 @@ import json import os import re -from typing import TYPE_CHECKING, Callable, Iterable, TypeVar +from collections.abc import Iterable +from typing import TYPE_CHECKING, Callable, TypeVar from urllib.parse import urlsplit import dill diff --git a/providers/src/airflow/providers/google/common/hooks/base_google.py b/providers/src/airflow/providers/google/common/hooks/base_google.py index 56795e3a17b19..35bccf808cc72 100644 --- a/providers/src/airflow/providers/google/common/hooks/base_google.py +++ b/providers/src/airflow/providers/google/common/hooks/base_google.py @@ -26,9 +26,10 @@ import logging import os import tempfile +from collections.abc import Generator, Sequence from contextlib import ExitStack, contextmanager from subprocess import check_output -from typing import TYPE_CHECKING, Any, Callable, Generator, Sequence, TypeVar, cast +from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast import google.auth import google.oauth2.service_account diff --git a/providers/src/airflow/providers/google/common/hooks/discovery_api.py b/providers/src/airflow/providers/google/common/hooks/discovery_api.py index 1724e7873a4ea..2cf13c0313aa3 100644 --- a/providers/src/airflow/providers/google/common/hooks/discovery_api.py +++ b/providers/src/airflow/providers/google/common/hooks/discovery_api.py @@ -19,7 +19,7 @@ from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from googleapiclient.discovery import Resource, build diff --git a/providers/src/airflow/providers/google/firebase/hooks/firestore.py b/providers/src/airflow/providers/google/firebase/hooks/firestore.py index 5bcff6239d693..dae41db5ee09c 100644 --- a/providers/src/airflow/providers/google/firebase/hooks/firestore.py +++ b/providers/src/airflow/providers/google/firebase/hooks/firestore.py @@ -20,7 +20,7 @@ from __future__ import annotations import time -from typing import Sequence +from collections.abc import Sequence from googleapiclient.discovery import build, build_from_document diff --git a/providers/src/airflow/providers/google/firebase/operators/firestore.py b/providers/src/airflow/providers/google/firebase/operators/firestore.py index d3a3c97f11017..055bcadb92a41 100644 --- a/providers/src/airflow/providers/google/firebase/operators/firestore.py +++ b/providers/src/airflow/providers/google/firebase/operators/firestore.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/marketing_platform/hooks/analytics_admin.py b/providers/src/airflow/providers/google/marketing_platform/hooks/analytics_admin.py index 94f205a9f1726..492a91af2880f 100644 --- a/providers/src/airflow/providers/google/marketing_platform/hooks/analytics_admin.py +++ b/providers/src/airflow/providers/google/marketing_platform/hooks/analytics_admin.py @@ -27,7 +27,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from google.analytics.admin_v1beta import ( AnalyticsAdminServiceClient, diff --git a/providers/src/airflow/providers/google/marketing_platform/hooks/campaign_manager.py b/providers/src/airflow/providers/google/marketing_platform/hooks/campaign_manager.py index 4fdc9208c6e84..55926fbaadf5d 100644 --- a/providers/src/airflow/providers/google/marketing_platform/hooks/campaign_manager.py +++ b/providers/src/airflow/providers/google/marketing_platform/hooks/campaign_manager.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from googleapiclient.discovery import Resource, build diff --git a/providers/src/airflow/providers/google/marketing_platform/hooks/display_video.py b/providers/src/airflow/providers/google/marketing_platform/hooks/display_video.py index 091d29713c473..7ca6cff9df433 100644 --- a/providers/src/airflow/providers/google/marketing_platform/hooks/display_video.py +++ b/providers/src/airflow/providers/google/marketing_platform/hooks/display_video.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from googleapiclient.discovery import Resource, build diff --git a/providers/src/airflow/providers/google/marketing_platform/hooks/search_ads.py b/providers/src/airflow/providers/google/marketing_platform/hooks/search_ads.py index 66f2cdda2f7af..1d8be32e7cbab 100644 --- a/providers/src/airflow/providers/google/marketing_platform/hooks/search_ads.py +++ b/providers/src/airflow/providers/google/marketing_platform/hooks/search_ads.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from google.oauth2.credentials import Credentials from googleapiclient.discovery import build diff --git a/providers/src/airflow/providers/google/marketing_platform/operators/analytics_admin.py b/providers/src/airflow/providers/google/marketing_platform/operators/analytics_admin.py index f55279c2c2f75..8f662f9c92d50 100644 --- a/providers/src/airflow/providers/google/marketing_platform/operators/analytics_admin.py +++ b/providers/src/airflow/providers/google/marketing_platform/operators/analytics_admin.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from google.analytics.admin_v1beta import ( Account, diff --git a/providers/src/airflow/providers/google/marketing_platform/operators/campaign_manager.py b/providers/src/airflow/providers/google/marketing_platform/operators/campaign_manager.py index 1a286f02037bd..4673f3c53a2ae 100644 --- a/providers/src/airflow/providers/google/marketing_platform/operators/campaign_manager.py +++ b/providers/src/airflow/providers/google/marketing_platform/operators/campaign_manager.py @@ -22,7 +22,8 @@ import json import tempfile import uuid -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from googleapiclient import http diff --git a/providers/src/airflow/providers/google/marketing_platform/operators/display_video.py b/providers/src/airflow/providers/google/marketing_platform/operators/display_video.py index 8dadff7540629..a45ca8ae2d22d 100644 --- a/providers/src/airflow/providers/google/marketing_platform/operators/display_video.py +++ b/providers/src/airflow/providers/google/marketing_platform/operators/display_video.py @@ -24,7 +24,8 @@ import shutil import tempfile import urllib.request -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from urllib.parse import urlsplit from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/google/marketing_platform/operators/search_ads.py b/providers/src/airflow/providers/google/marketing_platform/operators/search_ads.py index 067c2a8946187..1c7e120aa37f0 100644 --- a/providers/src/airflow/providers/google/marketing_platform/operators/search_ads.py +++ b/providers/src/airflow/providers/google/marketing_platform/operators/search_ads.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.google.marketing_platform.hooks.search_ads import GoogleSearchAdsReportingHook diff --git a/providers/src/airflow/providers/google/marketing_platform/sensors/campaign_manager.py b/providers/src/airflow/providers/google/marketing_platform/sensors/campaign_manager.py index 316e7bfa59f46..4b0b7eddb8de9 100644 --- a/providers/src/airflow/providers/google/marketing_platform/sensors/campaign_manager.py +++ b/providers/src/airflow/providers/google/marketing_platform/sensors/campaign_manager.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.google.marketing_platform.hooks.campaign_manager import GoogleCampaignManagerHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/google/marketing_platform/sensors/display_video.py b/providers/src/airflow/providers/google/marketing_platform/sensors/display_video.py index 5a5a143d39468..5f06970254843 100644 --- a/providers/src/airflow/providers/google/marketing_platform/sensors/display_video.py +++ b/providers/src/airflow/providers/google/marketing_platform/sensors/display_video.py @@ -18,7 +18,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.google.marketing_platform.hooks.display_video import GoogleDisplayVideo360Hook diff --git a/providers/src/airflow/providers/google/suite/hooks/calendar.py b/providers/src/airflow/providers/google/suite/hooks/calendar.py index b64ede9dc9a6a..ddc0078bba17d 100644 --- a/providers/src/airflow/providers/google/suite/hooks/calendar.py +++ b/providers/src/airflow/providers/google/suite/hooks/calendar.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from googleapiclient.discovery import build diff --git a/providers/src/airflow/providers/google/suite/hooks/drive.py b/providers/src/airflow/providers/google/suite/hooks/drive.py index 62f01499d8459..a33828950c1a0 100644 --- a/providers/src/airflow/providers/google/suite/hooks/drive.py +++ b/providers/src/airflow/providers/google/suite/hooks/drive.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import IO, Any, Sequence +from collections.abc import Sequence +from typing import IO, Any from googleapiclient.discovery import Resource, build from googleapiclient.errors import Error as GoogleApiClientError diff --git a/providers/src/airflow/providers/google/suite/hooks/sheets.py b/providers/src/airflow/providers/google/suite/hooks/sheets.py index 992cb9e6ac553..88ae6bb0d031a 100644 --- a/providers/src/airflow/providers/google/suite/hooks/sheets.py +++ b/providers/src/airflow/providers/google/suite/hooks/sheets.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from googleapiclient.discovery import build diff --git a/providers/src/airflow/providers/google/suite/operators/sheets.py b/providers/src/airflow/providers/google/suite/operators/sheets.py index 4f3e581b55edb..f6eaaf9d2ba07 100644 --- a/providers/src/airflow/providers/google/suite/operators/sheets.py +++ b/providers/src/airflow/providers/google/suite/operators/sheets.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from airflow.models import BaseOperator from airflow.providers.google.suite.hooks.sheets import GSheetsHook diff --git a/providers/src/airflow/providers/google/suite/sensors/drive.py b/providers/src/airflow/providers/google/suite/sensors/drive.py index b66a2059b2d49..edc4609e5cba5 100644 --- a/providers/src/airflow/providers/google/suite/sensors/drive.py +++ b/providers/src/airflow/providers/google/suite/sensors/drive.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.google.suite.hooks.drive import GoogleDriveHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/google/suite/transfers/gcs_to_gdrive.py b/providers/src/airflow/providers/google/suite/transfers/gcs_to_gdrive.py index c290b349fbd86..2a8728e30ea13 100644 --- a/providers/src/airflow/providers/google/suite/transfers/gcs_to_gdrive.py +++ b/providers/src/airflow/providers/google/suite/transfers/gcs_to_gdrive.py @@ -20,7 +20,8 @@ from __future__ import annotations import tempfile -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/suite/transfers/gcs_to_sheets.py b/providers/src/airflow/providers/google/suite/transfers/gcs_to_sheets.py index a2e6d7ca45db2..95b9120df91d3 100644 --- a/providers/src/airflow/providers/google/suite/transfers/gcs_to_sheets.py +++ b/providers/src/airflow/providers/google/suite/transfers/gcs_to_sheets.py @@ -17,8 +17,9 @@ from __future__ import annotations import csv +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import Any, Sequence +from typing import Any from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/google/suite/transfers/local_to_drive.py b/providers/src/airflow/providers/google/suite/transfers/local_to_drive.py index 70b07fec84d68..9a9e831762850 100644 --- a/providers/src/airflow/providers/google/suite/transfers/local_to_drive.py +++ b/providers/src/airflow/providers/google/suite/transfers/local_to_drive.py @@ -19,8 +19,9 @@ from __future__ import annotations import os +from collections.abc import Sequence from pathlib import Path -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowFailException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/google/suite/transfers/sql_to_sheets.py b/providers/src/airflow/providers/google/suite/transfers/sql_to_sheets.py index 1e6bc3ca4b2ee..ed9243a0c900c 100644 --- a/providers/src/airflow/providers/google/suite/transfers/sql_to_sheets.py +++ b/providers/src/airflow/providers/google/suite/transfers/sql_to_sheets.py @@ -19,8 +19,9 @@ import datetime import logging import numbers +from collections.abc import Iterable, Mapping, Sequence from contextlib import closing -from typing import Any, Iterable, Mapping, Sequence +from typing import Any from airflow.providers.common.sql.operators.sql import BaseSQLOperator from airflow.providers.google.suite.hooks.sheets import GSheetsHook diff --git a/providers/src/airflow/providers/grpc/hooks/grpc.py b/providers/src/airflow/providers/grpc/hooks/grpc.py index 49317814247b3..2027f40b5834f 100644 --- a/providers/src/airflow/providers/grpc/hooks/grpc.py +++ b/providers/src/airflow/providers/grpc/hooks/grpc.py @@ -18,7 +18,8 @@ from __future__ import annotations -from typing import Any, Callable, Generator +from collections.abc import Generator +from typing import Any, Callable import grpc from google import auth as google_auth diff --git a/providers/src/airflow/providers/grpc/operators/grpc.py b/providers/src/airflow/providers/grpc/operators/grpc.py index 294bf8584b3c4..261a4286a05f3 100644 --- a/providers/src/airflow/providers/grpc/operators/grpc.py +++ b/providers/src/airflow/providers/grpc/operators/grpc.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.models import BaseOperator from airflow.providers.grpc.hooks.grpc import GrpcHook diff --git a/providers/src/airflow/providers/http/operators/http.py b/providers/src/airflow/providers/http/operators/http.py index 358294af98799..a51faef142879 100644 --- a/providers/src/airflow/providers/http/operators/http.py +++ b/providers/src/airflow/providers/http/operators/http.py @@ -19,7 +19,8 @@ import base64 import pickle -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from deprecated import deprecated from requests import Response diff --git a/providers/src/airflow/providers/http/sensors/http.py b/providers/src/airflow/providers/http/sensors/http.py index 784284496a95d..23eb033a04faf 100644 --- a/providers/src/airflow/providers/http/sensors/http.py +++ b/providers/src/airflow/providers/http/sensors/http.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/http/triggers/http.py b/providers/src/airflow/providers/http/triggers/http.py index 543cd323b80a3..c527d86ae5494 100644 --- a/providers/src/airflow/providers/http/triggers/http.py +++ b/providers/src/airflow/providers/http/triggers/http.py @@ -19,7 +19,8 @@ import asyncio import base64 import pickle -from typing import TYPE_CHECKING, Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import TYPE_CHECKING, Any import requests from requests.cookies import RequestsCookieJar diff --git a/providers/src/airflow/providers/imap/hooks/imap.py b/providers/src/airflow/providers/imap/hooks/imap.py index c60080fa7ef41..a5ab9ad673cf1 100644 --- a/providers/src/airflow/providers/imap/hooks/imap.py +++ b/providers/src/airflow/providers/imap/hooks/imap.py @@ -28,7 +28,8 @@ import os import re import ssl -from typing import TYPE_CHECKING, Any, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook diff --git a/providers/src/airflow/providers/imap/sensors/imap_attachment.py b/providers/src/airflow/providers/imap/sensors/imap_attachment.py index 9eea63cebb523..2109cadcd3060 100644 --- a/providers/src/airflow/providers/imap/sensors/imap_attachment.py +++ b/providers/src/airflow/providers/imap/sensors/imap_attachment.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.imap.hooks.imap import ImapHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/influxdb/operators/influxdb.py b/providers/src/airflow/providers/influxdb/operators/influxdb.py index 9a23628d61274..ba91ea898c53e 100644 --- a/providers/src/airflow/providers/influxdb/operators/influxdb.py +++ b/providers/src/airflow/providers/influxdb/operators/influxdb.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.influxdb.hooks.influxdb import InfluxDBHook diff --git a/providers/src/airflow/providers/jdbc/operators/jdbc.py b/providers/src/airflow/providers/jdbc/operators/jdbc.py index 3357b569c8fb4..5b721422d3733 100644 --- a/providers/src/airflow/providers/jdbc/operators/jdbc.py +++ b/providers/src/airflow/providers/jdbc/operators/jdbc.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import ClassVar, Sequence +from collections.abc import Sequence +from typing import ClassVar from deprecated import deprecated diff --git a/providers/src/airflow/providers/jenkins/operators/jenkins_job_trigger.py b/providers/src/airflow/providers/jenkins/operators/jenkins_job_trigger.py index 1f7237cfcfce1..67c486e75a335 100644 --- a/providers/src/airflow/providers/jenkins/operators/jenkins_job_trigger.py +++ b/providers/src/airflow/providers/jenkins/operators/jenkins_job_trigger.py @@ -21,8 +21,9 @@ import json import socket import time +from collections.abc import Iterable, Mapping, Sequence from functools import cached_property -from typing import Any, Iterable, Mapping, Sequence, Union +from typing import Any, Union from urllib.error import HTTPError, URLError import jenkins diff --git a/providers/src/airflow/providers/jenkins/sensors/jenkins.py b/providers/src/airflow/providers/jenkins/sensors/jenkins.py index d0018b24eeda2..75585d66bcde7 100644 --- a/providers/src/airflow/providers/jenkins/sensors/jenkins.py +++ b/providers/src/airflow/providers/jenkins/sensors/jenkins.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.providers.jenkins.hooks.jenkins import JenkinsHook diff --git a/providers/src/airflow/providers/microsoft/azure/hooks/cosmos.py b/providers/src/airflow/providers/microsoft/azure/hooks/cosmos.py index 9d8b360a75522..da11ce10e0a16 100644 --- a/providers/src/airflow/providers/microsoft/azure/hooks/cosmos.py +++ b/providers/src/airflow/providers/microsoft/azure/hooks/cosmos.py @@ -27,7 +27,7 @@ from __future__ import annotations import uuid -from typing import TYPE_CHECKING, Any, List, Union +from typing import TYPE_CHECKING, Any, Union from urllib.parse import urlparse from azure.cosmos import PartitionKey @@ -44,7 +44,7 @@ ) if TYPE_CHECKING: - PartitionKeyType = Union[str, List[str]] + PartitionKeyType = Union[str, list[str]] class AzureCosmosDBHook(BaseHook): diff --git a/providers/src/airflow/providers/microsoft/azure/operators/adls.py b/providers/src/airflow/providers/microsoft/azure/operators/adls.py index 6afb495077963..e682083ca96c1 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/adls.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/adls.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import IO, TYPE_CHECKING, Any, AnyStr, Iterable, Sequence +from collections.abc import Iterable, Sequence +from typing import IO, TYPE_CHECKING, Any, AnyStr from airflow.models import BaseOperator from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook, AzureDataLakeStorageV2Hook diff --git a/providers/src/airflow/providers/microsoft/azure/operators/adx.py b/providers/src/airflow/providers/microsoft/azure/operators/adx.py index 1a8c1a07f018d..5efa087f9de31 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/adx.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/adx.py @@ -19,8 +19,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from deprecated.classic import deprecated diff --git a/providers/src/airflow/providers/microsoft/azure/operators/asb.py b/providers/src/airflow/providers/microsoft/azure/operators/asb.py index 7d6bab0d625f6..f46d4a8390da7 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/asb.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/asb.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from azure.core.exceptions import ResourceNotFoundError diff --git a/providers/src/airflow/providers/microsoft/azure/operators/batch.py b/providers/src/airflow/providers/microsoft/azure/operators/batch.py index 549d953346d3c..da724624a4bef 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/batch.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/batch.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from azure.batch import models as batch_models from deprecated.classic import deprecated diff --git a/providers/src/airflow/providers/microsoft/azure/operators/container_instances.py b/providers/src/airflow/providers/microsoft/azure/operators/container_instances.py index b47dec1c703e5..8b21f8226b3ac 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/container_instances.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/container_instances.py @@ -20,7 +20,8 @@ import re import time from collections import namedtuple -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from azure.mgmt.containerinstance.models import ( Container, diff --git a/providers/src/airflow/providers/microsoft/azure/operators/cosmos.py b/providers/src/airflow/providers/microsoft/azure/operators/cosmos.py index 44b9b2e98deee..99cee311f4102 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/cosmos.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/cosmos.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.microsoft.azure.hooks.cosmos import AzureCosmosDBHook diff --git a/providers/src/airflow/providers/microsoft/azure/operators/data_factory.py b/providers/src/airflow/providers/microsoft/azure/operators/data_factory.py index b8595e84c92f0..d6313c68b2286 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/data_factory.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/data_factory.py @@ -18,8 +18,9 @@ import time import warnings +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/microsoft/azure/operators/msgraph.py b/providers/src/airflow/providers/microsoft/azure/operators/msgraph.py index 0d187ebd5144b..fd73d418e1f35 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/msgraph.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/msgraph.py @@ -17,12 +17,12 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from copy import deepcopy from typing import ( TYPE_CHECKING, Any, Callable, - Sequence, ) from airflow.exceptions import AirflowException, TaskDeferred diff --git a/providers/src/airflow/providers/microsoft/azure/operators/powerbi.py b/providers/src/airflow/providers/microsoft/azure/operators/powerbi.py index b80966f541fc6..e2ff64ffe95df 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/powerbi.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/powerbi.py @@ -17,7 +17,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.models import BaseOperator, BaseOperatorLink diff --git a/providers/src/airflow/providers/microsoft/azure/operators/synapse.py b/providers/src/airflow/providers/microsoft/azure/operators/synapse.py index 8aeaea5c9cb82..275a45b30f455 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/synapse.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/synapse.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from urllib.parse import urlencode from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/microsoft/azure/operators/wasb_delete_blob.py b/providers/src/airflow/providers/microsoft/azure/operators/wasb_delete_blob.py index 7015746a825cd..7b9c3dfd61ee9 100644 --- a/providers/src/airflow/providers/microsoft/azure/operators/wasb_delete_blob.py +++ b/providers/src/airflow/providers/microsoft/azure/operators/wasb_delete_blob.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.microsoft.azure.hooks.wasb import WasbHook diff --git a/providers/src/airflow/providers/microsoft/azure/sensors/cosmos.py b/providers/src/airflow/providers/microsoft/azure/sensors/cosmos.py index 9e31e1b99999f..c4d9806bc49f6 100644 --- a/providers/src/airflow/providers/microsoft/azure/sensors/cosmos.py +++ b/providers/src/airflow/providers/microsoft/azure/sensors/cosmos.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.microsoft.azure.hooks.cosmos import AzureCosmosDBHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/microsoft/azure/sensors/data_factory.py b/providers/src/airflow/providers/microsoft/azure/sensors/data_factory.py index a8abba255ef0c..30f55c01d27e1 100644 --- a/providers/src/airflow/providers/microsoft/azure/sensors/data_factory.py +++ b/providers/src/airflow/providers/microsoft/azure/sensors/data_factory.py @@ -16,9 +16,10 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from datetime import timedelta from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/microsoft/azure/sensors/msgraph.py b/providers/src/airflow/providers/microsoft/azure/sensors/msgraph.py index 6736ea59c918d..904e5241c22b6 100644 --- a/providers/src/airflow/providers/microsoft/azure/sensors/msgraph.py +++ b/providers/src/airflow/providers/microsoft/azure/sensors/msgraph.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.exceptions import AirflowException from airflow.providers.microsoft.azure.hooks.msgraph import KiotaRequestAdapterHook diff --git a/providers/src/airflow/providers/microsoft/azure/sensors/wasb.py b/providers/src/airflow/providers/microsoft/azure/sensors/wasb.py index d5f5cd424bfff..5862b518233d9 100644 --- a/providers/src/airflow/providers/microsoft/azure/sensors/wasb.py +++ b/providers/src/airflow/providers/microsoft/azure/sensors/wasb.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from deprecated import deprecated diff --git a/providers/src/airflow/providers/microsoft/azure/transfers/local_to_adls.py b/providers/src/airflow/providers/microsoft/azure/transfers/local_to_adls.py index 032742fc6497d..016a6e2b0bda4 100644 --- a/providers/src/airflow/providers/microsoft/azure/transfers/local_to_adls.py +++ b/providers/src/airflow/providers/microsoft/azure/transfers/local_to_adls.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/microsoft/azure/transfers/local_to_wasb.py b/providers/src/airflow/providers/microsoft/azure/transfers/local_to_wasb.py index 29dd11c1e72e4..53ac418c8ba6e 100644 --- a/providers/src/airflow/providers/microsoft/azure/transfers/local_to_wasb.py +++ b/providers/src/airflow/providers/microsoft/azure/transfers/local_to_wasb.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.microsoft.azure.hooks.wasb import WasbHook diff --git a/providers/src/airflow/providers/microsoft/azure/transfers/oracle_to_azure_data_lake.py b/providers/src/airflow/providers/microsoft/azure/transfers/oracle_to_azure_data_lake.py index 7a73e7483527a..db2e22de7c158 100644 --- a/providers/src/airflow/providers/microsoft/azure/transfers/oracle_to_azure_data_lake.py +++ b/providers/src/airflow/providers/microsoft/azure/transfers/oracle_to_azure_data_lake.py @@ -19,8 +19,9 @@ import csv import os +from collections.abc import Sequence from tempfile import TemporaryDirectory -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.microsoft.azure.hooks.data_lake import AzureDataLakeHook diff --git a/providers/src/airflow/providers/microsoft/azure/transfers/s3_to_wasb.py b/providers/src/airflow/providers/microsoft/azure/transfers/s3_to_wasb.py index 53e7bce12f51a..ce7e3d7371a58 100644 --- a/providers/src/airflow/providers/microsoft/azure/transfers/s3_to_wasb.py +++ b/providers/src/airflow/providers/microsoft/azure/transfers/s3_to_wasb.py @@ -18,8 +18,9 @@ from __future__ import annotations import tempfile +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py b/providers/src/airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py index e11f1f443b418..009c53935065c 100644 --- a/providers/src/airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py +++ b/providers/src/airflow/providers/microsoft/azure/transfers/sftp_to_wasb.py @@ -21,9 +21,10 @@ import os from collections import namedtuple +from collections.abc import Sequence from functools import cached_property from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING if TYPE_CHECKING: from airflow.utils.context import Context diff --git a/providers/src/airflow/providers/microsoft/azure/triggers/data_factory.py b/providers/src/airflow/providers/microsoft/azure/triggers/data_factory.py index ab5ed2a0f1316..5e275a66762ef 100644 --- a/providers/src/airflow/providers/microsoft/azure/triggers/data_factory.py +++ b/providers/src/airflow/providers/microsoft/azure/triggers/data_factory.py @@ -18,7 +18,8 @@ import asyncio import time -from typing import Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import Any from azure.core.exceptions import ServiceRequestError diff --git a/providers/src/airflow/providers/microsoft/azure/triggers/msgraph.py b/providers/src/airflow/providers/microsoft/azure/triggers/msgraph.py index 0015964be86dd..076f2f493ea89 100644 --- a/providers/src/airflow/providers/microsoft/azure/triggers/msgraph.py +++ b/providers/src/airflow/providers/microsoft/azure/triggers/msgraph.py @@ -20,14 +20,13 @@ import json import locale from base64 import b64encode +from collections.abc import AsyncIterator, Sequence from contextlib import suppress from datetime import datetime from json import JSONDecodeError from typing import ( TYPE_CHECKING, Any, - AsyncIterator, - Sequence, ) from uuid import UUID diff --git a/providers/src/airflow/providers/microsoft/azure/triggers/powerbi.py b/providers/src/airflow/providers/microsoft/azure/triggers/powerbi.py index 3e23f3fa068d8..572fb58f3b316 100644 --- a/providers/src/airflow/providers/microsoft/azure/triggers/powerbi.py +++ b/providers/src/airflow/providers/microsoft/azure/triggers/powerbi.py @@ -19,7 +19,8 @@ import asyncio import time -from typing import TYPE_CHECKING, AsyncIterator +from collections.abc import AsyncIterator +from typing import TYPE_CHECKING from airflow.providers.microsoft.azure.hooks.powerbi import ( PowerBIDatasetRefreshStatus, diff --git a/providers/src/airflow/providers/microsoft/azure/triggers/wasb.py b/providers/src/airflow/providers/microsoft/azure/triggers/wasb.py index 0a19bb6b12e4f..6032b1d8a4fd3 100644 --- a/providers/src/airflow/providers/microsoft/azure/triggers/wasb.py +++ b/providers/src/airflow/providers/microsoft/azure/triggers/wasb.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import Any from airflow.providers.microsoft.azure.hooks.wasb import WasbAsyncHook from airflow.triggers.base import BaseTrigger, TriggerEvent diff --git a/providers/src/airflow/providers/microsoft/mssql/operators/mssql.py b/providers/src/airflow/providers/microsoft/mssql/operators/mssql.py index e21c78c3bf6a1..3e698e6589b03 100644 --- a/providers/src/airflow/providers/microsoft/mssql/operators/mssql.py +++ b/providers/src/airflow/providers/microsoft/mssql/operators/mssql.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import ClassVar, Sequence +from collections.abc import Sequence +from typing import ClassVar from deprecated import deprecated diff --git a/providers/src/airflow/providers/microsoft/psrp/hooks/psrp.py b/providers/src/airflow/providers/microsoft/psrp/hooks/psrp.py index 8aff72adfb941..9c855703f9dc0 100644 --- a/providers/src/airflow/providers/microsoft/psrp/hooks/psrp.py +++ b/providers/src/airflow/providers/microsoft/psrp/hooks/psrp.py @@ -17,10 +17,11 @@ # under the License. from __future__ import annotations +from collections.abc import Generator from contextlib import contextmanager from copy import copy from logging import DEBUG, ERROR, INFO, WARNING -from typing import TYPE_CHECKING, Any, Callable, Generator +from typing import TYPE_CHECKING, Any, Callable from warnings import warn from weakref import WeakKeyDictionary diff --git a/providers/src/airflow/providers/microsoft/winrm/operators/winrm.py b/providers/src/airflow/providers/microsoft/winrm/operators/winrm.py index 1e91cd1daf56f..1a7ba21bfbf48 100644 --- a/providers/src/airflow/providers/microsoft/winrm/operators/winrm.py +++ b/providers/src/airflow/providers/microsoft/winrm/operators/winrm.py @@ -19,7 +19,8 @@ import logging from base64 import b64encode -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/mongo/hooks/mongo.py b/providers/src/airflow/providers/mongo/hooks/mongo.py index a15cc45491ddd..6cfc8dca6b54e 100644 --- a/providers/src/airflow/providers/mongo/hooks/mongo.py +++ b/providers/src/airflow/providers/mongo/hooks/mongo.py @@ -20,7 +20,8 @@ from __future__ import annotations import warnings -from typing import TYPE_CHECKING, Any, Iterable, overload +from collections.abc import Iterable +from typing import TYPE_CHECKING, Any, overload from urllib.parse import quote_plus, urlunsplit import pymongo diff --git a/providers/src/airflow/providers/mongo/sensors/mongo.py b/providers/src/airflow/providers/mongo/sensors/mongo.py index 724ab5b4c6a9a..edf420f479627 100644 --- a/providers/src/airflow/providers/mongo/sensors/mongo.py +++ b/providers/src/airflow/providers/mongo/sensors/mongo.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.mongo.hooks.mongo import MongoHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/mysql/operators/mysql.py b/providers/src/airflow/providers/mysql/operators/mysql.py index 7a47dd0a68cf3..ca40ffa55e417 100644 --- a/providers/src/airflow/providers/mysql/operators/mysql.py +++ b/providers/src/airflow/providers/mysql/operators/mysql.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import ClassVar, Sequence +from collections.abc import Sequence +from typing import ClassVar from deprecated import deprecated diff --git a/providers/src/airflow/providers/mysql/transfers/presto_to_mysql.py b/providers/src/airflow/providers/mysql/transfers/presto_to_mysql.py index 0d80b58bff8cb..3849de6f7efb5 100644 --- a/providers/src/airflow/providers/mysql/transfers/presto_to_mysql.py +++ b/providers/src/airflow/providers/mysql/transfers/presto_to_mysql.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.mysql.hooks.mysql import MySqlHook diff --git a/providers/src/airflow/providers/mysql/transfers/s3_to_mysql.py b/providers/src/airflow/providers/mysql/transfers/s3_to_mysql.py index d6f6c401b501a..930528022c36c 100644 --- a/providers/src/airflow/providers/mysql/transfers/s3_to_mysql.py +++ b/providers/src/airflow/providers/mysql/transfers/s3_to_mysql.py @@ -17,7 +17,8 @@ from __future__ import annotations import os -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.amazon.aws.hooks.s3 import S3Hook diff --git a/providers/src/airflow/providers/mysql/transfers/trino_to_mysql.py b/providers/src/airflow/providers/mysql/transfers/trino_to_mysql.py index e96aaafd5bf02..77347db1bb3bc 100644 --- a/providers/src/airflow/providers/mysql/transfers/trino_to_mysql.py +++ b/providers/src/airflow/providers/mysql/transfers/trino_to_mysql.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.mysql.hooks.mysql import MySqlHook diff --git a/providers/src/airflow/providers/mysql/transfers/vertica_to_mysql.py b/providers/src/airflow/providers/mysql/transfers/vertica_to_mysql.py index e13ee7bddadb7..c871ce0dafb75 100644 --- a/providers/src/airflow/providers/mysql/transfers/vertica_to_mysql.py +++ b/providers/src/airflow/providers/mysql/transfers/vertica_to_mysql.py @@ -18,9 +18,10 @@ from __future__ import annotations import csv +from collections.abc import Sequence from contextlib import closing from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING try: import MySQLdb diff --git a/providers/src/airflow/providers/neo4j/operators/neo4j.py b/providers/src/airflow/providers/neo4j/operators/neo4j.py index 6cd36f9472f84..7740dfbe2669e 100644 --- a/providers/src/airflow/providers/neo4j/operators/neo4j.py +++ b/providers/src/airflow/providers/neo4j/operators/neo4j.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Iterable, Mapping, Sequence +from collections.abc import Iterable, Mapping, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.neo4j.hooks.neo4j import Neo4jHook diff --git a/providers/src/airflow/providers/odbc/hooks/odbc.py b/providers/src/airflow/providers/odbc/hooks/odbc.py index aa3f9ce50fa80..1d9ebb6fc375a 100644 --- a/providers/src/airflow/providers/odbc/hooks/odbc.py +++ b/providers/src/airflow/providers/odbc/hooks/odbc.py @@ -19,7 +19,8 @@ from __future__ import annotations from collections import namedtuple -from typing import Any, List, Sequence, cast +from collections.abc import Sequence +from typing import Any, cast from urllib.parse import quote_plus from pyodbc import Connection, Row, connect @@ -222,7 +223,7 @@ def _make_common_data_structure(self, result: Sequence[Row] | Row) -> list[tuple if isinstance(result, Sequence): field_names = [col[0] for col in result[0].cursor_description] row_object = namedtuple("Row", field_names, rename=True) # type: ignore - return cast(List[tuple], [row_object(*row) for row in result]) + return cast(list[tuple], [row_object(*row) for row in result]) else: field_names = [col[0] for col in result.cursor_description] return cast(tuple, namedtuple("Row", field_names, rename=True)(*result)) # type: ignore diff --git a/providers/src/airflow/providers/openai/operators/openai.py b/providers/src/airflow/providers/openai/operators/openai.py index 7ce834865409b..d38caf8e2af88 100644 --- a/providers/src/airflow/providers/openai/operators/openai.py +++ b/providers/src/airflow/providers/openai/operators/openai.py @@ -18,8 +18,9 @@ from __future__ import annotations import time +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Literal, Sequence +from typing import TYPE_CHECKING, Any, Literal from airflow.configuration import conf from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/openai/triggers/openai.py b/providers/src/airflow/providers/openai/triggers/openai.py index 481753f7bcc35..5800e948490d3 100644 --- a/providers/src/airflow/providers/openai/triggers/openai.py +++ b/providers/src/airflow/providers/openai/triggers/openai.py @@ -18,7 +18,8 @@ import asyncio import time -from typing import Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import Any from airflow.providers.openai.hooks.openai import BatchStatus, OpenAIHook from airflow.triggers.base import BaseTrigger, TriggerEvent diff --git a/providers/src/airflow/providers/openlineage/extractors/manager.py b/providers/src/airflow/providers/openlineage/extractors/manager.py index be824335718b1..12d64050208be 100644 --- a/providers/src/airflow/providers/openlineage/extractors/manager.py +++ b/providers/src/airflow/providers/openlineage/extractors/manager.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Iterator +from collections.abc import Iterator +from typing import TYPE_CHECKING from airflow.providers.common.compat.openlineage.utils.utils import ( translate_airflow_asset, diff --git a/providers/src/airflow/providers/openlineage/utils/sql.py b/providers/src/airflow/providers/openlineage/utils/sql.py index 7cbd9531945bf..1223a3618bd7b 100644 --- a/providers/src/airflow/providers/openlineage/utils/sql.py +++ b/providers/src/airflow/providers/openlineage/utils/sql.py @@ -20,7 +20,7 @@ from collections import defaultdict from contextlib import closing from enum import IntEnum -from typing import TYPE_CHECKING, Dict, List, Optional +from typing import TYPE_CHECKING, Optional from attrs import define from openlineage.client.event_v2 import Dataset @@ -50,7 +50,7 @@ class ColumnIndex(IntEnum): DATABASE = 5 -TablesHierarchy = Dict[Optional[str], Dict[Optional[str], List[str]]] +TablesHierarchy = dict[Optional[str], dict[Optional[str], list[str]]] @define diff --git a/providers/src/airflow/providers/openlineage/utils/utils.py b/providers/src/airflow/providers/openlineage/utils/utils.py index a37b94b85c19d..622f45bd65b29 100644 --- a/providers/src/airflow/providers/openlineage/utils/utils.py +++ b/providers/src/airflow/providers/openlineage/utils/utils.py @@ -20,10 +20,11 @@ import datetime import json import logging +from collections.abc import Iterable from contextlib import suppress from functools import wraps from importlib import metadata -from typing import TYPE_CHECKING, Any, Callable, Iterable +from typing import TYPE_CHECKING, Any, Callable import attrs from deprecated import deprecated diff --git a/providers/src/airflow/providers/opensearch/log/os_response.py b/providers/src/airflow/providers/opensearch/log/os_response.py index de2635b4227d6..2827cb0f04547 100644 --- a/providers/src/airflow/providers/opensearch/log/os_response.py +++ b/providers/src/airflow/providers/opensearch/log/os_response.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import Iterator +from collections.abc import Iterator def _wrap(val): diff --git a/providers/src/airflow/providers/opensearch/log/os_task_handler.py b/providers/src/airflow/providers/opensearch/log/os_task_handler.py index ca061f04825d3..7bbaecb11592e 100644 --- a/providers/src/airflow/providers/opensearch/log/os_task_handler.py +++ b/providers/src/airflow/providers/opensearch/log/os_task_handler.py @@ -24,7 +24,7 @@ from collections import defaultdict from datetime import datetime from operator import attrgetter -from typing import TYPE_CHECKING, Any, Callable, List, Literal, Tuple +from typing import TYPE_CHECKING, Any, Callable, Literal import pendulum from opensearchpy import OpenSearch @@ -49,7 +49,7 @@ if TYPE_CHECKING: from airflow.models.taskinstance import TaskInstance, TaskInstanceKey USE_PER_RUN_LOG_ID = hasattr(DagRun, "get_log_template") -OsLogMsgType = List[Tuple[str, str]] +OsLogMsgType = list[tuple[str, str]] LOG_LINE_DEFAULTS = {"exc_text": "", "stack_info": ""} diff --git a/providers/src/airflow/providers/opensearch/operators/opensearch.py b/providers/src/airflow/providers/opensearch/operators/opensearch.py index 6599e5bf94ec4..4351f2dc1bbf1 100644 --- a/providers/src/airflow/providers/opensearch/operators/opensearch.py +++ b/providers/src/airflow/providers/opensearch/operators/opensearch.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from opensearchpy import RequestsHttpConnection from opensearchpy.exceptions import OpenSearchException diff --git a/providers/src/airflow/providers/opsgenie/notifications/opsgenie.py b/providers/src/airflow/providers/opsgenie/notifications/opsgenie.py index 50f06ff1714b4..6d29210364b58 100644 --- a/providers/src/airflow/providers/opsgenie/notifications/opsgenie.py +++ b/providers/src/airflow/providers/opsgenie/notifications/opsgenie.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.notifications.basenotifier import BaseNotifier from airflow.providers.opsgenie.hooks.opsgenie import OpsgenieAlertHook diff --git a/providers/src/airflow/providers/opsgenie/operators/opsgenie.py b/providers/src/airflow/providers/opsgenie/operators/opsgenie.py index d12db20873562..43d161b15206c 100644 --- a/providers/src/airflow/providers/opsgenie/operators/opsgenie.py +++ b/providers/src/airflow/providers/opsgenie/operators/opsgenie.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.opsgenie.hooks.opsgenie import OpsgenieAlertHook diff --git a/providers/src/airflow/providers/oracle/operators/oracle.py b/providers/src/airflow/providers/oracle/operators/oracle.py index 5770271d6360f..60da9fcb70dad 100644 --- a/providers/src/airflow/providers/oracle/operators/oracle.py +++ b/providers/src/airflow/providers/oracle/operators/oracle.py @@ -18,7 +18,8 @@ from __future__ import annotations import re -from typing import TYPE_CHECKING, ClassVar, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, ClassVar import oracledb from deprecated import deprecated diff --git a/providers/src/airflow/providers/oracle/transfers/oracle_to_oracle.py b/providers/src/airflow/providers/oracle/transfers/oracle_to_oracle.py index ad66b2530fd59..f97fda2bb3d9e 100644 --- a/providers/src/airflow/providers/oracle/transfers/oracle_to_oracle.py +++ b/providers/src/airflow/providers/oracle/transfers/oracle_to_oracle.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.oracle.hooks.oracle import OracleHook diff --git a/providers/src/airflow/providers/papermill/operators/papermill.py b/providers/src/airflow/providers/papermill/operators/papermill.py index b89266d130889..acc4ccd9b9e0e 100644 --- a/providers/src/airflow/providers/papermill/operators/papermill.py +++ b/providers/src/airflow/providers/papermill/operators/papermill.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Collection, Sequence from functools import cached_property -from typing import TYPE_CHECKING, ClassVar, Collection, Sequence +from typing import TYPE_CHECKING, ClassVar import attr import papermill as pm diff --git a/providers/src/airflow/providers/pinecone/hooks/pinecone.py b/providers/src/airflow/providers/pinecone/hooks/pinecone.py index 3efeb14846726..932fd04acd6ea 100644 --- a/providers/src/airflow/providers/pinecone/hooks/pinecone.py +++ b/providers/src/airflow/providers/pinecone/hooks/pinecone.py @@ -328,7 +328,7 @@ def query_vector( :param include_values: Whether to include the vector values in the result. :param include_metadata: Indicates whether metadata is included in the response as well as the ids. :param sparse_vector: sparse values of the query vector. Expected to be either a SparseValues object or a dict - of the form: {'indices': List[int], 'values': List[float]}, where the lists each have the same length. + of the form: {'indices': list[int], 'values': list[float]}, where the lists each have the same length. """ index = self.pinecone_client.Index(index_name) return index.query( diff --git a/providers/src/airflow/providers/pinecone/operators/pinecone.py b/providers/src/airflow/providers/pinecone/operators/pinecone.py index 70711e062308d..040bef46227e1 100644 --- a/providers/src/airflow/providers/pinecone/operators/pinecone.py +++ b/providers/src/airflow/providers/pinecone/operators/pinecone.py @@ -17,8 +17,9 @@ from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.pinecone.hooks.pinecone import PineconeHook diff --git a/providers/src/airflow/providers/postgres/hooks/postgres.py b/providers/src/airflow/providers/postgres/hooks/postgres.py index 73dd10a67ef71..f4a4c4e60e8f9 100644 --- a/providers/src/airflow/providers/postgres/hooks/postgres.py +++ b/providers/src/airflow/providers/postgres/hooks/postgres.py @@ -19,9 +19,10 @@ import os import warnings +from collections.abc import Iterable from contextlib import closing from copy import deepcopy -from typing import TYPE_CHECKING, Any, Iterable, Union +from typing import TYPE_CHECKING, Any, Union import psycopg2 import psycopg2.extensions diff --git a/providers/src/airflow/providers/postgres/operators/postgres.py b/providers/src/airflow/providers/postgres/operators/postgres.py index f936d4626978b..7fc0a38a4e53b 100644 --- a/providers/src/airflow/providers/postgres/operators/postgres.py +++ b/providers/src/airflow/providers/postgres/operators/postgres.py @@ -18,7 +18,8 @@ from __future__ import annotations import warnings -from typing import ClassVar, Mapping +from collections.abc import Mapping +from typing import ClassVar from deprecated import deprecated diff --git a/providers/src/airflow/providers/presto/hooks/presto.py b/providers/src/airflow/providers/presto/hooks/presto.py index 483635c5c6e13..c78361f73eb12 100644 --- a/providers/src/airflow/providers/presto/hooks/presto.py +++ b/providers/src/airflow/providers/presto/hooks/presto.py @@ -19,7 +19,8 @@ import json import os -from typing import TYPE_CHECKING, Any, Iterable, Mapping, TypeVar +from collections.abc import Iterable, Mapping +from typing import TYPE_CHECKING, Any, TypeVar import prestodb from packaging.version import Version diff --git a/providers/src/airflow/providers/presto/transfers/gcs_to_presto.py b/providers/src/airflow/providers/presto/transfers/gcs_to_presto.py index e1ecd2c0f5cb2..876e923c7da1e 100644 --- a/providers/src/airflow/providers/presto/transfers/gcs_to_presto.py +++ b/providers/src/airflow/providers/presto/transfers/gcs_to_presto.py @@ -21,8 +21,9 @@ import csv import json +from collections.abc import Iterable, Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Iterable, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/qdrant/operators/qdrant.py b/providers/src/airflow/providers/qdrant/operators/qdrant.py index 6cc71d864b5a9..f747a5809d84d 100644 --- a/providers/src/airflow/providers/qdrant/operators/qdrant.py +++ b/providers/src/airflow/providers/qdrant/operators/qdrant.py @@ -17,8 +17,9 @@ from __future__ import annotations +from collections.abc import Iterable, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Iterable, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.qdrant.hooks.qdrant import QdrantHook diff --git a/providers/src/airflow/providers/redis/operators/redis_publish.py b/providers/src/airflow/providers/redis/operators/redis_publish.py index b42539c0828b1..eebaf3e1102df 100644 --- a/providers/src/airflow/providers/redis/operators/redis_publish.py +++ b/providers/src/airflow/providers/redis/operators/redis_publish.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.redis.hooks.redis import RedisHook diff --git a/providers/src/airflow/providers/redis/sensors/redis_key.py b/providers/src/airflow/providers/redis/sensors/redis_key.py index 2f29d4d82361f..3fba123e6026e 100644 --- a/providers/src/airflow/providers/redis/sensors/redis_key.py +++ b/providers/src/airflow/providers/redis/sensors/redis_key.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.redis.hooks.redis import RedisHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/redis/sensors/redis_pub_sub.py b/providers/src/airflow/providers/redis/sensors/redis_pub_sub.py index 776279c126cd0..2c0fed4e6a81c 100644 --- a/providers/src/airflow/providers/redis/sensors/redis_pub_sub.py +++ b/providers/src/airflow/providers/redis/sensors/redis_pub_sub.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.providers.redis.hooks.redis import RedisHook from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/salesforce/hooks/salesforce.py b/providers/src/airflow/providers/salesforce/hooks/salesforce.py index 6b2bc0e058bf7..ca54f01f5f05a 100644 --- a/providers/src/airflow/providers/salesforce/hooks/salesforce.py +++ b/providers/src/airflow/providers/salesforce/hooks/salesforce.py @@ -26,8 +26,9 @@ import logging import time +from collections.abc import Iterable from functools import cached_property -from typing import TYPE_CHECKING, Any, Iterable, cast +from typing import TYPE_CHECKING, Any, cast from simple_salesforce import Salesforce, api diff --git a/providers/src/airflow/providers/salesforce/operators/bulk.py b/providers/src/airflow/providers/salesforce/operators/bulk.py index 85839fd9f1be4..779ab08b056f6 100644 --- a/providers/src/airflow/providers/salesforce/operators/bulk.py +++ b/providers/src/airflow/providers/salesforce/operators/bulk.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Iterable, cast +from collections.abc import Iterable +from typing import TYPE_CHECKING, cast from airflow.models import BaseOperator from airflow.providers.salesforce.hooks.salesforce import SalesforceHook diff --git a/providers/src/airflow/providers/samba/transfers/gcs_to_samba.py b/providers/src/airflow/providers/samba/transfers/gcs_to_samba.py index bddc038b736ed..bfc1f0f2c1097 100644 --- a/providers/src/airflow/providers/samba/transfers/gcs_to_samba.py +++ b/providers/src/airflow/providers/samba/transfers/gcs_to_samba.py @@ -20,8 +20,9 @@ from __future__ import annotations import os +from collections.abc import Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/segment/operators/segment_track_event.py b/providers/src/airflow/providers/segment/operators/segment_track_event.py index 46904f647294b..e3274fe375a57 100644 --- a/providers/src/airflow/providers/segment/operators/segment_track_event.py +++ b/providers/src/airflow/providers/segment/operators/segment_track_event.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.segment.hooks.segment import SegmentHook diff --git a/providers/src/airflow/providers/sendgrid/utils/emailer.py b/providers/src/airflow/providers/sendgrid/utils/emailer.py index b82aad35db9b6..c096246d25076 100644 --- a/providers/src/airflow/providers/sendgrid/utils/emailer.py +++ b/providers/src/airflow/providers/sendgrid/utils/emailer.py @@ -24,7 +24,8 @@ import mimetypes import os import warnings -from typing import Iterable, Union +from collections.abc import Iterable +from typing import Union import sendgrid from sendgrid.helpers.mail import ( diff --git a/providers/src/airflow/providers/sftp/decorators/sensors/sftp.py b/providers/src/airflow/providers/sftp/decorators/sensors/sftp.py index d12b3ee76154a..8533218965d9a 100644 --- a/providers/src/airflow/providers/sftp/decorators/sensors/sftp.py +++ b/providers/src/airflow/providers/sftp/decorators/sensors/sftp.py @@ -17,7 +17,8 @@ from __future__ import annotations -from typing import Callable, Sequence +from collections.abc import Sequence +from typing import Callable from airflow.decorators.base import TaskDecorator, get_unique_task_id, task_decorator_factory from airflow.providers.sftp.sensors.sftp import SFTPSensor diff --git a/providers/src/airflow/providers/sftp/hooks/sftp.py b/providers/src/airflow/providers/sftp/hooks/sftp.py index b8b755d93f5fd..fec11666dec38 100644 --- a/providers/src/airflow/providers/sftp/hooks/sftp.py +++ b/providers/src/airflow/providers/sftp/hooks/sftp.py @@ -23,8 +23,9 @@ import os import stat import warnings +from collections.abc import Sequence from fnmatch import fnmatch -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable import asyncssh from asgiref.sync import sync_to_async diff --git a/providers/src/airflow/providers/sftp/operators/sftp.py b/providers/src/airflow/providers/sftp/operators/sftp.py index e04f68cb09875..95a2880ae2eac 100644 --- a/providers/src/airflow/providers/sftp/operators/sftp.py +++ b/providers/src/airflow/providers/sftp/operators/sftp.py @@ -22,8 +22,9 @@ import os import socket import warnings +from collections.abc import Sequence from pathlib import Path -from typing import Any, Sequence +from typing import Any import paramiko diff --git a/providers/src/airflow/providers/sftp/sensors/sftp.py b/providers/src/airflow/providers/sftp/sensors/sftp.py index f6b076331fe5b..9a5cb14345282 100644 --- a/providers/src/airflow/providers/sftp/sensors/sftp.py +++ b/providers/src/airflow/providers/sftp/sensors/sftp.py @@ -20,8 +20,9 @@ from __future__ import annotations import os +from collections.abc import Sequence from datetime import datetime, timedelta -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable from paramiko.sftp import SFTP_NO_SUCH_FILE diff --git a/providers/src/airflow/providers/sftp/triggers/sftp.py b/providers/src/airflow/providers/sftp/triggers/sftp.py index 6a39c95870607..08a047975fdf5 100644 --- a/providers/src/airflow/providers/sftp/triggers/sftp.py +++ b/providers/src/airflow/providers/sftp/triggers/sftp.py @@ -18,8 +18,9 @@ from __future__ import annotations import asyncio +from collections.abc import AsyncIterator from datetime import datetime -from typing import Any, AsyncIterator +from typing import Any from dateutil.parser import parse as parse_date diff --git a/providers/src/airflow/providers/singularity/operators/singularity.py b/providers/src/airflow/providers/singularity/operators/singularity.py index dde0ed0ac48f7..d5ba00425151e 100644 --- a/providers/src/airflow/providers/singularity/operators/singularity.py +++ b/providers/src/airflow/providers/singularity/operators/singularity.py @@ -20,7 +20,8 @@ import ast import os import shutil -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from spython.main import Client diff --git a/providers/src/airflow/providers/slack/hooks/slack.py b/providers/src/airflow/providers/slack/hooks/slack.py index 3c696230131c1..3f667c9943dcc 100644 --- a/providers/src/airflow/providers/slack/hooks/slack.py +++ b/providers/src/airflow/providers/slack/hooks/slack.py @@ -19,9 +19,10 @@ import json import warnings +from collections.abc import Sequence from functools import cached_property from pathlib import Path -from typing import TYPE_CHECKING, Any, Sequence, TypedDict +from typing import TYPE_CHECKING, Any, TypedDict from deprecated import deprecated from slack_sdk import WebClient diff --git a/providers/src/airflow/providers/slack/notifications/slack.py b/providers/src/airflow/providers/slack/notifications/slack.py index aee67b9b2641a..0678a75921736 100644 --- a/providers/src/airflow/providers/slack/notifications/slack.py +++ b/providers/src/airflow/providers/slack/notifications/slack.py @@ -18,8 +18,9 @@ from __future__ import annotations import json +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.notifications.basenotifier import BaseNotifier from airflow.providers.slack.hooks.slack import SlackHook diff --git a/providers/src/airflow/providers/slack/operators/slack.py b/providers/src/airflow/providers/slack/operators/slack.py index 88644726e27a6..a4a31a8527260 100644 --- a/providers/src/airflow/providers/slack/operators/slack.py +++ b/providers/src/airflow/providers/slack/operators/slack.py @@ -19,8 +19,9 @@ import json import warnings +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from typing_extensions import Literal diff --git a/providers/src/airflow/providers/slack/operators/slack_webhook.py b/providers/src/airflow/providers/slack/operators/slack_webhook.py index 9a36a806e9284..e17c3c706baa8 100644 --- a/providers/src/airflow/providers/slack/operators/slack_webhook.py +++ b/providers/src/airflow/providers/slack/operators/slack_webhook.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.slack.hooks.slack_webhook import SlackWebhookHook diff --git a/providers/src/airflow/providers/slack/transfers/base_sql_to_slack.py b/providers/src/airflow/providers/slack/transfers/base_sql_to_slack.py index 70e48e72bf103..523a83ca1f661 100644 --- a/providers/src/airflow/providers/slack/transfers/base_sql_to_slack.py +++ b/providers/src/airflow/providers/slack/transfers/base_sql_to_slack.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Mapping +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException from airflow.hooks.base import BaseHook diff --git a/providers/src/airflow/providers/slack/transfers/sql_to_slack.py b/providers/src/airflow/providers/slack/transfers/sql_to_slack.py index 6b3ebeec86bf3..91d2237a1194b 100644 --- a/providers/src/airflow/providers/slack/transfers/sql_to_slack.py +++ b/providers/src/airflow/providers/slack/transfers/sql_to_slack.py @@ -16,9 +16,10 @@ # under the License. from __future__ import annotations +from collections.abc import Mapping, Sequence from functools import cached_property from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Any, Mapping, Sequence +from typing import TYPE_CHECKING, Any from deprecated import deprecated from typing_extensions import Literal diff --git a/providers/src/airflow/providers/slack/transfers/sql_to_slack_webhook.py b/providers/src/airflow/providers/slack/transfers/sql_to_slack_webhook.py index 82cbd2a4949a6..cfc3944e228cd 100644 --- a/providers/src/airflow/providers/slack/transfers/sql_to_slack_webhook.py +++ b/providers/src/airflow/providers/slack/transfers/sql_to_slack_webhook.py @@ -17,7 +17,8 @@ from __future__ import annotations import warnings -from typing import TYPE_CHECKING, Any, Iterable, Mapping, Sequence +from collections.abc import Iterable, Mapping, Sequence +from typing import TYPE_CHECKING, Any from deprecated import deprecated from tabulate import tabulate diff --git a/providers/src/airflow/providers/slack/utils/__init__.py b/providers/src/airflow/providers/slack/utils/__init__.py index 594f0fe656c81..6201dafaea597 100644 --- a/providers/src/airflow/providers/slack/utils/__init__.py +++ b/providers/src/airflow/providers/slack/utils/__init__.py @@ -17,7 +17,8 @@ from __future__ import annotations import warnings -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from airflow.utils.types import NOTSET diff --git a/providers/src/airflow/providers/smtp/hooks/smtp.py b/providers/src/airflow/providers/smtp/hooks/smtp.py index cf4b2c3bf0cf2..f6374e7fec91e 100644 --- a/providers/src/airflow/providers/smtp/hooks/smtp.py +++ b/providers/src/airflow/providers/smtp/hooks/smtp.py @@ -28,11 +28,12 @@ import re import smtplib import ssl +from collections.abc import Iterable from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.utils import formatdate -from typing import TYPE_CHECKING, Any, Iterable +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowException, AirflowNotFoundException from airflow.hooks.base import BaseHook diff --git a/providers/src/airflow/providers/smtp/notifications/smtp.py b/providers/src/airflow/providers/smtp/notifications/smtp.py index cc9a804bf9a66..fb043e59c071a 100644 --- a/providers/src/airflow/providers/smtp/notifications/smtp.py +++ b/providers/src/airflow/providers/smtp/notifications/smtp.py @@ -17,9 +17,10 @@ from __future__ import annotations +from collections.abc import Iterable from functools import cached_property from pathlib import Path -from typing import Any, Iterable +from typing import Any from airflow.configuration import conf from airflow.notifications.basenotifier import BaseNotifier diff --git a/providers/src/airflow/providers/smtp/operators/smtp.py b/providers/src/airflow/providers/smtp/operators/smtp.py index db1f162c21287..3c08f8d51fd24 100644 --- a/providers/src/airflow/providers/smtp/operators/smtp.py +++ b/providers/src/airflow/providers/smtp/operators/smtp.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.smtp.hooks.smtp import SmtpHook diff --git a/providers/src/airflow/providers/snowflake/decorators/snowpark.py b/providers/src/airflow/providers/snowflake/decorators/snowpark.py index 406d817e9db37..a5f60a3a0c95d 100644 --- a/providers/src/airflow/providers/snowflake/decorators/snowpark.py +++ b/providers/src/airflow/providers/snowflake/decorators/snowpark.py @@ -17,7 +17,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, Callable from airflow.decorators.base import DecoratedOperator, task_decorator_factory from airflow.providers.snowflake.operators.snowpark import SnowparkOperator diff --git a/providers/src/airflow/providers/snowflake/hooks/snowflake.py b/providers/src/airflow/providers/snowflake/hooks/snowflake.py index 81785338e7ba5..e957c0623cb03 100644 --- a/providers/src/airflow/providers/snowflake/hooks/snowflake.py +++ b/providers/src/airflow/providers/snowflake/hooks/snowflake.py @@ -18,11 +18,12 @@ from __future__ import annotations import os +from collections.abc import Iterable, Mapping from contextlib import closing, contextmanager from functools import cached_property from io import StringIO from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, TypeVar, overload +from typing import TYPE_CHECKING, Any, Callable, TypeVar, overload from urllib.parse import urlparse from cryptography.hazmat.backends import default_backend diff --git a/providers/src/airflow/providers/snowflake/operators/snowflake.py b/providers/src/airflow/providers/snowflake/operators/snowflake.py index c7c19d740b1f0..859e88d7d27f0 100644 --- a/providers/src/airflow/providers/snowflake/operators/snowflake.py +++ b/providers/src/airflow/providers/snowflake/operators/snowflake.py @@ -18,8 +18,9 @@ from __future__ import annotations import time +from collections.abc import Iterable, Mapping, Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, ClassVar, Iterable, List, Mapping, Sequence, SupportsAbs, cast +from typing import TYPE_CHECKING, Any, ClassVar, SupportsAbs, cast from deprecated import deprecated @@ -584,7 +585,7 @@ def execute_complete(self, context: Context, event: dict[str, str | list[str]] | raise AirflowException(msg) elif "status" in event and event["status"] == "success": hook = SnowflakeSqlApiHook(snowflake_conn_id=self.snowflake_conn_id) - query_ids = cast(List[str], event["statement_query_ids"]) + query_ids = cast(list[str], event["statement_query_ids"]) hook.check_query_output(query_ids) self.log.info("%s completed successfully.", self.task_id) else: diff --git a/providers/src/airflow/providers/snowflake/operators/snowpark.py b/providers/src/airflow/providers/snowflake/operators/snowpark.py index 81ed876f3f679..98c96923ddbfa 100644 --- a/providers/src/airflow/providers/snowflake/operators/snowpark.py +++ b/providers/src/airflow/providers/snowflake/operators/snowpark.py @@ -17,7 +17,8 @@ from __future__ import annotations -from typing import Any, Callable, Collection, Mapping, Sequence +from collections.abc import Collection, Mapping, Sequence +from typing import Any, Callable from airflow.providers.common.compat.standard.operators import PythonOperator, get_current_context from airflow.providers.snowflake.hooks.snowflake import SnowflakeHook diff --git a/providers/src/airflow/providers/snowflake/transfers/copy_into_snowflake.py b/providers/src/airflow/providers/snowflake/transfers/copy_into_snowflake.py index 066ebf0a4df43..b3f0d6e545850 100644 --- a/providers/src/airflow/providers/snowflake/transfers/copy_into_snowflake.py +++ b/providers/src/airflow/providers/snowflake/transfers/copy_into_snowflake.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import Any, Sequence +from collections.abc import Sequence +from typing import Any from airflow.models import BaseOperator from airflow.providers.snowflake.hooks.snowflake import SnowflakeHook diff --git a/providers/src/airflow/providers/snowflake/triggers/snowflake_trigger.py b/providers/src/airflow/providers/snowflake/triggers/snowflake_trigger.py index 48d4c356268f2..b425b9a6250d3 100644 --- a/providers/src/airflow/providers/snowflake/triggers/snowflake_trigger.py +++ b/providers/src/airflow/providers/snowflake/triggers/snowflake_trigger.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import TYPE_CHECKING, Any from airflow.providers.snowflake.hooks.snowflake_sql_api import SnowflakeSqlApiHook from airflow.triggers.base import BaseTrigger, TriggerEvent diff --git a/providers/src/airflow/providers/sqlite/operators/sqlite.py b/providers/src/airflow/providers/sqlite/operators/sqlite.py index 1e38696263f97..25df70c8abf72 100644 --- a/providers/src/airflow/providers/sqlite/operators/sqlite.py +++ b/providers/src/airflow/providers/sqlite/operators/sqlite.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import ClassVar, Sequence +from collections.abc import Sequence +from typing import ClassVar from deprecated import deprecated diff --git a/providers/src/airflow/providers/ssh/hooks/ssh.py b/providers/src/airflow/providers/ssh/hooks/ssh.py index ecd3990d06b9a..6dd00f2c8bfd2 100644 --- a/providers/src/airflow/providers/ssh/hooks/ssh.py +++ b/providers/src/airflow/providers/ssh/hooks/ssh.py @@ -22,10 +22,11 @@ import os import warnings from base64 import decodebytes +from collections.abc import Sequence from functools import cached_property from io import StringIO from select import select -from typing import Any, Sequence +from typing import Any import paramiko from deprecated import deprecated diff --git a/providers/src/airflow/providers/ssh/operators/ssh.py b/providers/src/airflow/providers/ssh/operators/ssh.py index b8dc412681107..0ee6d111da7d0 100644 --- a/providers/src/airflow/providers/ssh/operators/ssh.py +++ b/providers/src/airflow/providers/ssh/operators/ssh.py @@ -18,8 +18,9 @@ from __future__ import annotations from base64 import b64encode +from collections.abc import Container, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Container, Sequence +from typing import TYPE_CHECKING from deprecated.classic import deprecated diff --git a/providers/src/airflow/providers/standard/hooks/subprocess.py b/providers/src/airflow/providers/standard/hooks/subprocess.py index 3beb8f4dc8dbe..cb7338be804f9 100644 --- a/providers/src/airflow/providers/standard/hooks/subprocess.py +++ b/providers/src/airflow/providers/standard/hooks/subprocess.py @@ -20,9 +20,9 @@ import os import signal from collections import namedtuple +from collections.abc import Iterator from subprocess import PIPE, STDOUT, Popen from tempfile import TemporaryDirectory, gettempdir -from typing import Iterator from airflow.hooks.base import BaseHook diff --git a/providers/src/airflow/providers/standard/operators/bash.py b/providers/src/airflow/providers/standard/operators/bash.py index b991084c295f5..242909f885c22 100644 --- a/providers/src/airflow/providers/standard/operators/bash.py +++ b/providers/src/airflow/providers/standard/operators/bash.py @@ -21,8 +21,9 @@ import shutil import tempfile import warnings +from collections.abc import Container, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Callable, Container, Sequence, cast +from typing import TYPE_CHECKING, Any, Callable, cast from airflow.exceptions import AirflowException, AirflowSkipException from airflow.models.baseoperator import BaseOperator diff --git a/providers/src/airflow/providers/standard/operators/datetime.py b/providers/src/airflow/providers/standard/operators/datetime.py index 9b1f7819eca15..cb3ce66fce202 100644 --- a/providers/src/airflow/providers/standard/operators/datetime.py +++ b/providers/src/airflow/providers/standard/operators/datetime.py @@ -17,7 +17,8 @@ from __future__ import annotations import datetime -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.operators.branch import BaseBranchOperator diff --git a/providers/src/airflow/providers/standard/operators/generic_transfer.py b/providers/src/airflow/providers/standard/operators/generic_transfer.py index 255b08c54c2ac..1cb3448f8a578 100644 --- a/providers/src/airflow/providers/standard/operators/generic_transfer.py +++ b/providers/src/airflow/providers/standard/operators/generic_transfer.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.hooks.base import BaseHook from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/standard/operators/python.py b/providers/src/airflow/providers/standard/operators/python.py index 8ff6eba0eb065..c1865f0132bf6 100644 --- a/providers/src/airflow/providers/standard/operators/python.py +++ b/providers/src/airflow/providers/standard/operators/python.py @@ -28,11 +28,11 @@ import types import warnings from abc import ABCMeta, abstractmethod -from collections.abc import Container +from collections.abc import Collection, Container, Iterable, Mapping, Sequence from functools import cache from pathlib import Path from tempfile import TemporaryDirectory -from typing import TYPE_CHECKING, Any, Callable, Collection, Iterable, Mapping, NamedTuple, Sequence, cast +from typing import TYPE_CHECKING, Any, Callable, NamedTuple, cast import lazy_object_proxy diff --git a/providers/src/airflow/providers/standard/operators/trigger_dagrun.py b/providers/src/airflow/providers/standard/operators/trigger_dagrun.py index dbe9425a1c1c9..0cd3b8861a54b 100644 --- a/providers/src/airflow/providers/standard/operators/trigger_dagrun.py +++ b/providers/src/airflow/providers/standard/operators/trigger_dagrun.py @@ -20,7 +20,8 @@ import datetime import json import time -from typing import TYPE_CHECKING, Any, Sequence, cast +from collections.abc import Sequence +from typing import TYPE_CHECKING, Any, cast from sqlalchemy import select from sqlalchemy.orm.exc import NoResultFound diff --git a/providers/src/airflow/providers/standard/operators/weekday.py b/providers/src/airflow/providers/standard/operators/weekday.py index 0c74b19d795b4..7c6f7f7a9b8bb 100644 --- a/providers/src/airflow/providers/standard/operators/weekday.py +++ b/providers/src/airflow/providers/standard/operators/weekday.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING from airflow.operators.branch import BaseBranchOperator from airflow.utils import timezone diff --git a/providers/src/airflow/providers/standard/sensors/bash.py b/providers/src/airflow/providers/standard/sensors/bash.py index 4ec90d672a9e9..def3cc688b2ef 100644 --- a/providers/src/airflow/providers/standard/sensors/bash.py +++ b/providers/src/airflow/providers/standard/sensors/bash.py @@ -18,9 +18,10 @@ from __future__ import annotations import os +from collections.abc import Sequence from subprocess import PIPE, STDOUT, Popen from tempfile import NamedTemporaryFile, TemporaryDirectory, gettempdir -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowFailException from airflow.sensors.base import BaseSensorOperator @@ -70,9 +71,10 @@ def poke(self, context: Context): """Execute the bash command in a temporary directory.""" bash_command = self.bash_command self.log.info("Tmp dir root location: %s", gettempdir()) - with TemporaryDirectory(prefix="airflowtmp") as tmp_dir, NamedTemporaryFile( - dir=tmp_dir, prefix=self.task_id - ) as f: + with ( + TemporaryDirectory(prefix="airflowtmp") as tmp_dir, + NamedTemporaryFile(dir=tmp_dir, prefix=self.task_id) as f, + ): f.write(bytes(bash_command, "utf_8")) f.flush() fname = f.name diff --git a/providers/src/airflow/providers/standard/sensors/date_time.py b/providers/src/airflow/providers/standard/sensors/date_time.py index bfc15ab38c462..44e3b44cae76d 100644 --- a/providers/src/airflow/providers/standard/sensors/date_time.py +++ b/providers/src/airflow/providers/standard/sensors/date_time.py @@ -18,8 +18,9 @@ from __future__ import annotations import datetime +from collections.abc import Sequence from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, NoReturn, Sequence +from typing import TYPE_CHECKING, Any, NoReturn from airflow.providers.standard.utils.version_references import AIRFLOW_V_3_0_PLUS from airflow.sensors.base import BaseSensorOperator diff --git a/providers/src/airflow/providers/standard/sensors/filesystem.py b/providers/src/airflow/providers/standard/sensors/filesystem.py index 4496f5d6abfa4..0a1c2d46bebff 100644 --- a/providers/src/airflow/providers/standard/sensors/filesystem.py +++ b/providers/src/airflow/providers/standard/sensors/filesystem.py @@ -19,9 +19,10 @@ import datetime import os +from collections.abc import Sequence from functools import cached_property from glob import glob -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.configuration import conf from airflow.exceptions import AirflowException diff --git a/providers/src/airflow/providers/standard/sensors/python.py b/providers/src/airflow/providers/standard/sensors/python.py index c44708b2f66f4..30031f968fb39 100644 --- a/providers/src/airflow/providers/standard/sensors/python.py +++ b/providers/src/airflow/providers/standard/sensors/python.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Callable, Mapping, Sequence +from collections.abc import Mapping, Sequence +from typing import TYPE_CHECKING, Any, Callable from airflow.sensors.base import BaseSensorOperator, PokeReturnValue from airflow.utils.context import context_merge diff --git a/providers/src/airflow/providers/standard/sensors/weekday.py b/providers/src/airflow/providers/standard/sensors/weekday.py index b3e873b70e987..4740022cd0669 100644 --- a/providers/src/airflow/providers/standard/sensors/weekday.py +++ b/providers/src/airflow/providers/standard/sensors/weekday.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Iterable +from collections.abc import Iterable +from typing import TYPE_CHECKING from airflow.sensors.base import BaseSensorOperator from airflow.utils import timezone diff --git a/providers/src/airflow/providers/tableau/operators/tableau.py b/providers/src/airflow/providers/tableau/operators/tableau.py index e4a447a654571..77a6508343446 100644 --- a/providers/src/airflow/providers/tableau/operators/tableau.py +++ b/providers/src/airflow/providers/tableau/operators/tableau.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/tableau/sensors/tableau.py b/providers/src/airflow/providers/tableau/sensors/tableau.py index 80eb684746252..04c990412441d 100644 --- a/providers/src/airflow/providers/tableau/sensors/tableau.py +++ b/providers/src/airflow/providers/tableau/sensors/tableau.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.providers.tableau.hooks.tableau import ( TableauHook, diff --git a/providers/src/airflow/providers/telegram/operators/telegram.py b/providers/src/airflow/providers/telegram/operators/telegram.py index a8bda16f26026..41da0079fe0d2 100644 --- a/providers/src/airflow/providers/telegram/operators/telegram.py +++ b/providers/src/airflow/providers/telegram/operators/telegram.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowException from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/teradata/operators/teradata.py b/providers/src/airflow/providers/teradata/operators/teradata.py index edb1331c61227..c52904952ffff 100644 --- a/providers/src/airflow/providers/teradata/operators/teradata.py +++ b/providers/src/airflow/providers/teradata/operators/teradata.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, ClassVar, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING, ClassVar from airflow.models import BaseOperator from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator diff --git a/providers/src/airflow/providers/teradata/operators/teradata_compute_cluster.py b/providers/src/airflow/providers/teradata/operators/teradata_compute_cluster.py index 6759c04ce74c1..92e4e4177b9d3 100644 --- a/providers/src/airflow/providers/teradata/operators/teradata_compute_cluster.py +++ b/providers/src/airflow/providers/teradata/operators/teradata_compute_cluster.py @@ -30,8 +30,9 @@ if TYPE_CHECKING: from airflow.utils.context import Context +from collections.abc import Sequence from datetime import timedelta -from typing import TYPE_CHECKING, Any, Sequence, cast +from typing import TYPE_CHECKING, Any, cast from airflow.providers.teradata.triggers.teradata_compute_cluster import TeradataComputeClusterSyncTrigger diff --git a/providers/src/airflow/providers/teradata/transfers/azure_blob_to_teradata.py b/providers/src/airflow/providers/teradata/transfers/azure_blob_to_teradata.py index 8fc95122f1c63..125e63119f6bd 100644 --- a/providers/src/airflow/providers/teradata/transfers/azure_blob_to_teradata.py +++ b/providers/src/airflow/providers/teradata/transfers/azure_blob_to_teradata.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from textwrap import dedent -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/teradata/transfers/s3_to_teradata.py b/providers/src/airflow/providers/teradata/transfers/s3_to_teradata.py index d0bca09165b11..6c34efa870452 100644 --- a/providers/src/airflow/providers/teradata/transfers/s3_to_teradata.py +++ b/providers/src/airflow/providers/teradata/transfers/s3_to_teradata.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from textwrap import dedent -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/teradata/transfers/teradata_to_teradata.py b/providers/src/airflow/providers/teradata/transfers/teradata_to_teradata.py index 5c003a43b8eda..f10eb6d10048f 100644 --- a/providers/src/airflow/providers/teradata/transfers/teradata_to_teradata.py +++ b/providers/src/airflow/providers/teradata/transfers/teradata_to_teradata.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.teradata.hooks.teradata import TeradataHook diff --git a/providers/src/airflow/providers/teradata/triggers/teradata_compute_cluster.py b/providers/src/airflow/providers/teradata/triggers/teradata_compute_cluster.py index 5b971535d26d2..a1a500f50ad20 100644 --- a/providers/src/airflow/providers/teradata/triggers/teradata_compute_cluster.py +++ b/providers/src/airflow/providers/teradata/triggers/teradata_compute_cluster.py @@ -17,7 +17,8 @@ from __future__ import annotations import asyncio -from typing import Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import Any from airflow.exceptions import AirflowException from airflow.providers.common.sql.hooks.sql import fetch_one_handler diff --git a/providers/src/airflow/providers/trino/hooks/trino.py b/providers/src/airflow/providers/trino/hooks/trino.py index b2936d976f0ed..129f1288e4dc9 100644 --- a/providers/src/airflow/providers/trino/hooks/trino.py +++ b/providers/src/airflow/providers/trino/hooks/trino.py @@ -19,8 +19,9 @@ import json import os +from collections.abc import Iterable, Mapping from pathlib import Path -from typing import TYPE_CHECKING, Any, Iterable, Mapping, TypeVar +from typing import TYPE_CHECKING, Any, TypeVar import trino from packaging.version import Version diff --git a/providers/src/airflow/providers/trino/operators/trino.py b/providers/src/airflow/providers/trino/operators/trino.py index 9ff9768d745d9..5a3858342a523 100644 --- a/providers/src/airflow/providers/trino/operators/trino.py +++ b/providers/src/airflow/providers/trino/operators/trino.py @@ -19,7 +19,8 @@ from __future__ import annotations -from typing import Any, ClassVar, Sequence +from collections.abc import Sequence +from typing import Any, ClassVar from deprecated import deprecated from trino.exceptions import TrinoQueryError diff --git a/providers/src/airflow/providers/trino/transfers/gcs_to_trino.py b/providers/src/airflow/providers/trino/transfers/gcs_to_trino.py index a322c63c9e83d..36fd082c84a91 100644 --- a/providers/src/airflow/providers/trino/transfers/gcs_to_trino.py +++ b/providers/src/airflow/providers/trino/transfers/gcs_to_trino.py @@ -21,8 +21,9 @@ import csv import json +from collections.abc import Iterable, Sequence from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, Iterable, Sequence +from typing import TYPE_CHECKING from airflow.models import BaseOperator from airflow.providers.google.cloud.hooks.gcs import GCSHook diff --git a/providers/src/airflow/providers/vertica/hooks/vertica.py b/providers/src/airflow/providers/vertica/hooks/vertica.py index 1c77d2fd2470c..0cb8929f56589 100644 --- a/providers/src/airflow/providers/vertica/hooks/vertica.py +++ b/providers/src/airflow/providers/vertica/hooks/vertica.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import Any, Callable, Iterable, Mapping, overload +from collections.abc import Iterable, Mapping +from typing import Any, Callable, overload from vertica_python import connect diff --git a/providers/src/airflow/providers/vertica/operators/vertica.py b/providers/src/airflow/providers/vertica/operators/vertica.py index 03cf14f000e35..1077fbaa0ee58 100644 --- a/providers/src/airflow/providers/vertica/operators/vertica.py +++ b/providers/src/airflow/providers/vertica/operators/vertica.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import Any, ClassVar, Sequence +from collections.abc import Sequence +from typing import Any, ClassVar from deprecated import deprecated diff --git a/providers/src/airflow/providers/weaviate/hooks/weaviate.py b/providers/src/airflow/providers/weaviate/hooks/weaviate.py index 916df62e66dd9..716bc3e10e6be 100644 --- a/providers/src/airflow/providers/weaviate/hooks/weaviate.py +++ b/providers/src/airflow/providers/weaviate/hooks/weaviate.py @@ -19,8 +19,9 @@ import contextlib import json +from collections.abc import Mapping, Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Sequence, cast +from typing import TYPE_CHECKING, Any, cast import requests import weaviate @@ -265,7 +266,7 @@ def _convert_dataframe_to_list(data: list[dict[str, Any]] | pd.DataFrame | None) if isinstance(data, pandas.DataFrame): data = json.loads(data.to_json(orient="records")) - return cast(List[Dict[str, Any]], data) + return cast(list[dict[str, Any]], data) def batch_data( self, @@ -785,11 +786,11 @@ def create_or_replace_document_objects( return [] if isinstance(data, Sequence) and isinstance(data[0], dict): - # This is done to narrow the type to List[Dict[str, Any]. - data = pd.json_normalize(cast(List[Dict[str, Any]], data)) + # This is done to narrow the type to list[dict[str, Any]. + data = pd.json_normalize(cast(list[dict[str, Any]], data)) elif isinstance(data, Sequence) and isinstance(data[0], pd.DataFrame): - # This is done to narrow the type to List[pd.DataFrame]. - data = pd.concat(cast(List[pd.DataFrame], data), ignore_index=True) + # This is done to narrow the type to list[pd.DataFrame]. + data = pd.concat(cast(list[pd.DataFrame], data), ignore_index=True) else: data = cast(pd.DataFrame, data) diff --git a/providers/src/airflow/providers/weaviate/operators/weaviate.py b/providers/src/airflow/providers/weaviate/operators/weaviate.py index e2f9ac0d701f1..22631f7c40c05 100644 --- a/providers/src/airflow/providers/weaviate/operators/weaviate.py +++ b/providers/src/airflow/providers/weaviate/operators/weaviate.py @@ -18,8 +18,9 @@ from __future__ import annotations import warnings +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.exceptions import AirflowProviderDeprecationWarning from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/yandex/operators/dataproc.py b/providers/src/airflow/providers/yandex/operators/dataproc.py index 79aab002e10a6..eb5ce140f55e3 100644 --- a/providers/src/airflow/providers/yandex/operators/dataproc.py +++ b/providers/src/airflow/providers/yandex/operators/dataproc.py @@ -17,8 +17,9 @@ from __future__ import annotations import warnings +from collections.abc import Iterable, Sequence from dataclasses import dataclass -from typing import TYPE_CHECKING, Iterable, Sequence +from typing import TYPE_CHECKING from airflow.exceptions import AirflowProviderDeprecationWarning from airflow.models import BaseOperator diff --git a/providers/src/airflow/providers/yandex/operators/yq.py b/providers/src/airflow/providers/yandex/operators/yq.py index 52261edd31893..babe088fed86f 100644 --- a/providers/src/airflow/providers/yandex/operators/yq.py +++ b/providers/src/airflow/providers/yandex/operators/yq.py @@ -16,8 +16,9 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from airflow.models import BaseOperator from airflow.providers.yandex.hooks.yq import YQHook diff --git a/providers/src/airflow/providers/ydb/hooks/ydb.py b/providers/src/airflow/providers/ydb/hooks/ydb.py index 03c59d72c87b4..2b1a319d3333f 100644 --- a/providers/src/airflow/providers/ydb/hooks/ydb.py +++ b/providers/src/airflow/providers/ydb/hooks/ydb.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Any, Mapping, Sequence +from collections.abc import Mapping, Sequence +from typing import TYPE_CHECKING, Any import ydb from sqlalchemy.engine import URL diff --git a/providers/src/airflow/providers/ydb/operators/ydb.py b/providers/src/airflow/providers/ydb/operators/ydb.py index 1867f227b4eb6..de55baac3d08e 100644 --- a/providers/src/airflow/providers/ydb/operators/ydb.py +++ b/providers/src/airflow/providers/ydb/operators/ydb.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import Iterable, Mapping +from collections.abc import Iterable, Mapping from airflow.exceptions import AirflowException from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator diff --git a/providers/tests/amazon/aws/hooks/test_neptune.py b/providers/tests/amazon/aws/hooks/test_neptune.py index b38cde86a411a..617d1ab9b831d 100644 --- a/providers/tests/amazon/aws/hooks/test_neptune.py +++ b/providers/tests/amazon/aws/hooks/test_neptune.py @@ -17,7 +17,7 @@ # under the License. from __future__ import annotations -from typing import Generator +from collections.abc import Generator from unittest import mock import pytest diff --git a/providers/tests/amazon/aws/hooks/test_rds.py b/providers/tests/amazon/aws/hooks/test_rds.py index 77159b4e14d66..a79c611f0dc42 100644 --- a/providers/tests/amazon/aws/hooks/test_rds.py +++ b/providers/tests/amazon/aws/hooks/test_rds.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Generator +from collections.abc import Generator +from typing import TYPE_CHECKING from unittest.mock import patch import pytest diff --git a/providers/tests/amazon/aws/operators/test_bedrock.py b/providers/tests/amazon/aws/operators/test_bedrock.py index 5e8cd32e1a4d4..a92b71b432b8c 100644 --- a/providers/tests/amazon/aws/operators/test_bedrock.py +++ b/providers/tests/amazon/aws/operators/test_bedrock.py @@ -18,7 +18,8 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING, Generator +from collections.abc import Generator +from typing import TYPE_CHECKING from unittest import mock import pytest diff --git a/providers/tests/amazon/aws/operators/test_comprehend.py b/providers/tests/amazon/aws/operators/test_comprehend.py index 170f7b6760823..9a4ef2d2f74db 100644 --- a/providers/tests/amazon/aws/operators/test_comprehend.py +++ b/providers/tests/amazon/aws/operators/test_comprehend.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Generator +from collections.abc import Generator +from typing import TYPE_CHECKING from unittest import mock import pytest diff --git a/providers/tests/amazon/aws/operators/test_glue.py b/providers/tests/amazon/aws/operators/test_glue.py index d01e807884622..6c1a2d2536228 100644 --- a/providers/tests/amazon/aws/operators/test_glue.py +++ b/providers/tests/amazon/aws/operators/test_glue.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Generator +from collections.abc import Generator +from typing import TYPE_CHECKING from unittest import mock import boto3 diff --git a/providers/tests/amazon/aws/operators/test_glue_crawler.py b/providers/tests/amazon/aws/operators/test_glue_crawler.py index 1df63a4e2ad05..0a8d0a34b874d 100644 --- a/providers/tests/amazon/aws/operators/test_glue_crawler.py +++ b/providers/tests/amazon/aws/operators/test_glue_crawler.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Generator +from collections.abc import Generator +from typing import TYPE_CHECKING from unittest import mock import pytest diff --git a/providers/tests/amazon/aws/operators/test_glue_databrew.py b/providers/tests/amazon/aws/operators/test_glue_databrew.py index 1b46549df4545..3f22779150609 100644 --- a/providers/tests/amazon/aws/operators/test_glue_databrew.py +++ b/providers/tests/amazon/aws/operators/test_glue_databrew.py @@ -17,7 +17,7 @@ # under the License. from __future__ import annotations -from typing import Generator +from collections.abc import Generator from unittest import mock import pytest diff --git a/providers/tests/amazon/aws/operators/test_kinesis_analytics.py b/providers/tests/amazon/aws/operators/test_kinesis_analytics.py index b6b92e4c0b134..35b15e85b519f 100644 --- a/providers/tests/amazon/aws/operators/test_kinesis_analytics.py +++ b/providers/tests/amazon/aws/operators/test_kinesis_analytics.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Generator +from collections.abc import Generator +from typing import TYPE_CHECKING from unittest import mock import pytest diff --git a/providers/tests/amazon/aws/operators/test_neptune.py b/providers/tests/amazon/aws/operators/test_neptune.py index 0606f06e053a1..6508bf9101eb4 100644 --- a/providers/tests/amazon/aws/operators/test_neptune.py +++ b/providers/tests/amazon/aws/operators/test_neptune.py @@ -17,7 +17,7 @@ # under the License. from __future__ import annotations -from typing import Generator +from collections.abc import Generator from unittest import mock import pytest diff --git a/providers/tests/amazon/aws/operators/test_sagemaker_notebook.py b/providers/tests/amazon/aws/operators/test_sagemaker_notebook.py index 0593b0f798429..f4cbb0335d14d 100644 --- a/providers/tests/amazon/aws/operators/test_sagemaker_notebook.py +++ b/providers/tests/amazon/aws/operators/test_sagemaker_notebook.py @@ -17,7 +17,7 @@ # under the License. from __future__ import annotations -from typing import Generator +from collections.abc import Generator from unittest import mock import pytest diff --git a/providers/tests/amazon/aws/utils/eks_test_constants.py b/providers/tests/amazon/aws/utils/eks_test_constants.py index 5e8888ca7bc08..e65c5cadf8765 100644 --- a/providers/tests/amazon/aws/utils/eks_test_constants.py +++ b/providers/tests/amazon/aws/utils/eks_test_constants.py @@ -23,7 +23,8 @@ import re from enum import Enum -from typing import Any, Pattern +from re import Pattern +from typing import Any DEFAULT_CONN_ID: str = "aws_default" DEFAULT_NAMESPACE: str = "default_namespace" diff --git a/providers/tests/amazon/aws/utils/eks_test_utils.py b/providers/tests/amazon/aws/utils/eks_test_utils.py index 8bc9bd9e26227..a9938ec0dad7a 100644 --- a/providers/tests/amazon/aws/utils/eks_test_utils.py +++ b/providers/tests/amazon/aws/utils/eks_test_utils.py @@ -19,7 +19,8 @@ import re from copy import deepcopy -from typing import TYPE_CHECKING, Pattern, Type, Union +from re import Pattern +from typing import TYPE_CHECKING, Union from providers.tests.amazon.aws.utils.eks_test_constants import ( STATUS, @@ -37,7 +38,7 @@ from airflow.providers.amazon.aws.hooks.eks import EksHook -InputTypes = Union[Type[ClusterInputs], Type[NodegroupInputs], Type[FargateProfileInputs]] +InputTypes = Union[type[ClusterInputs], type[NodegroupInputs], type[FargateProfileInputs]] def attributes_to_test( diff --git a/providers/tests/amazon/aws/waiters/test_emr.py b/providers/tests/amazon/aws/waiters/test_emr.py index 39a44fe1f4374..a02b8e5c85186 100644 --- a/providers/tests/amazon/aws/waiters/test_emr.py +++ b/providers/tests/amazon/aws/waiters/test_emr.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from unittest import mock import boto3 diff --git a/providers/tests/apache/kafka/operators/test_produce.py b/providers/tests/apache/kafka/operators/test_produce.py index 6c1b853ecef90..ed41a18a1705f 100644 --- a/providers/tests/apache/kafka/operators/test_produce.py +++ b/providers/tests/apache/kafka/operators/test_produce.py @@ -39,7 +39,7 @@ def _simple_producer(key, value) -> list[tuple[Any, Any]]: :param key: the key for the message :param value: the value for the message :return: The Key / Value pair for production via the operator - :rtype: List[Tuple[Any, Any]] + :rtype: list[tuple[Any, Any]] """ return [(key, value)] diff --git a/providers/tests/common/sql/operators/test_sql_execute.py b/providers/tests/common/sql/operators/test_sql_execute.py index 095eb1fe82fcf..606139f34f839 100644 --- a/providers/tests/common/sql/operators/test_sql_execute.py +++ b/providers/tests/common/sql/operators/test_sql_execute.py @@ -17,7 +17,8 @@ # under the License. from __future__ import annotations -from typing import Any, NamedTuple, Sequence +from collections.abc import Sequence +from typing import Any, NamedTuple from unittest import mock from unittest.mock import MagicMock diff --git a/providers/tests/databricks/hooks/test_databricks_sql.py b/providers/tests/databricks/hooks/test_databricks_sql.py index 3eb628d46c2b2..12c55ee715cae 100644 --- a/providers/tests/databricks/hooks/test_databricks_sql.py +++ b/providers/tests/databricks/hooks/test_databricks_sql.py @@ -392,9 +392,12 @@ def test_execution_timeout_exceeded( Row(id=11, value=12), ), ): - with patch( - "airflow.providers.databricks.hooks.databricks_sql.create_timeout_thread" - ) as mock_create_timeout_thread, patch.object(DatabricksSqlHook, "_run_command") as mock_run_command: + with ( + patch( + "airflow.providers.databricks.hooks.databricks_sql.create_timeout_thread" + ) as mock_create_timeout_thread, + patch.object(DatabricksSqlHook, "_run_command") as mock_run_command, + ): conn = mock.MagicMock() cur = mock.MagicMock( rowcount=len(cursor_results), diff --git a/providers/tests/edge/worker_api/routes/test_rpc_api.py b/providers/tests/edge/worker_api/routes/test_rpc_api.py index 654660a3f975c..3b81a9d3f323d 100644 --- a/providers/tests/edge/worker_api/routes/test_rpc_api.py +++ b/providers/tests/edge/worker_api/routes/test_rpc_api.py @@ -17,7 +17,8 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING, Generator +from collections.abc import Generator +from typing import TYPE_CHECKING from unittest import mock import pytest diff --git a/providers/tests/fab/auth_manager/api_endpoints/test_asset_endpoint.py b/providers/tests/fab/auth_manager/api_endpoints/test_asset_endpoint.py index 9a5435dce5475..d4576de89a3bb 100644 --- a/providers/tests/fab/auth_manager/api_endpoints/test_asset_endpoint.py +++ b/providers/tests/fab/auth_manager/api_endpoints/test_asset_endpoint.py @@ -16,7 +16,7 @@ # under the License. from __future__ import annotations -from typing import Generator +from collections.abc import Generator import pytest import time_machine diff --git a/providers/tests/google/cloud/hooks/test_datacatalog.py b/providers/tests/google/cloud/hooks/test_datacatalog.py index f535e0b36bc8f..07c952409f51d 100644 --- a/providers/tests/google/cloud/hooks/test_datacatalog.py +++ b/providers/tests/google/cloud/hooks/test_datacatalog.py @@ -17,8 +17,9 @@ from __future__ import annotations import re +from collections.abc import Sequence from copy import deepcopy -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from unittest import mock import pytest diff --git a/providers/tests/google/cloud/hooks/test_os_login.py b/providers/tests/google/cloud/hooks/test_os_login.py index e805cb34a924d..317283735051d 100644 --- a/providers/tests/google/cloud/hooks/test_os_login.py +++ b/providers/tests/google/cloud/hooks/test_os_login.py @@ -17,7 +17,8 @@ from __future__ import annotations import re -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from unittest import mock import pytest diff --git a/providers/tests/google/cloud/operators/test_datacatalog.py b/providers/tests/google/cloud/operators/test_datacatalog.py index 1d0d0c4992898..5f83b81fd7f13 100644 --- a/providers/tests/google/cloud/operators/test_datacatalog.py +++ b/providers/tests/google/cloud/operators/test_datacatalog.py @@ -16,7 +16,8 @@ # under the License. from __future__ import annotations -from typing import TYPE_CHECKING, Sequence +from collections.abc import Sequence +from typing import TYPE_CHECKING from unittest import mock from google.api_core.exceptions import AlreadyExists diff --git a/providers/tests/microsoft/conftest.py b/providers/tests/microsoft/conftest.py index 6ac4c0a03a368..e0a4a15fe74ac 100644 --- a/providers/tests/microsoft/conftest.py +++ b/providers/tests/microsoft/conftest.py @@ -21,10 +21,11 @@ import random import re import string +from collections.abc import Iterable from inspect import currentframe from json import JSONDecodeError from os.path import dirname, join -from typing import TYPE_CHECKING, Any, Iterable, TypeVar +from typing import TYPE_CHECKING, Any, TypeVar from unittest.mock import MagicMock import pytest diff --git a/providers/tests/standard/operators/test_python.py b/providers/tests/standard/operators/test_python.py index efeade9ca0939..994989be20a6e 100644 --- a/providers/tests/standard/operators/test_python.py +++ b/providers/tests/standard/operators/test_python.py @@ -27,12 +27,13 @@ import tempfile import warnings from collections import namedtuple +from collections.abc import Generator from datetime import date, datetime, timedelta, timezone as _timezone from functools import partial from importlib.util import find_spec from subprocess import CalledProcessError from tempfile import TemporaryDirectory -from typing import TYPE_CHECKING, Generator +from typing import TYPE_CHECKING from unittest import mock from unittest.mock import MagicMock diff --git a/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query.py b/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query.py index 3d97fad5aacf9..791d9ed874b73 100644 --- a/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query.py +++ b/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query.py @@ -24,10 +24,11 @@ import logging import os from collections import namedtuple +from collections.abc import Iterable from copy import deepcopy from datetime import datetime from pathlib import Path -from typing import Any, Iterable +from typing import Any from googleapiclient import discovery diff --git a/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_iam.py b/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_iam.py index 4330137d977a3..7e04c8d493f98 100644 --- a/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_iam.py +++ b/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_iam.py @@ -25,10 +25,11 @@ import os import random import string +from collections.abc import Iterable from copy import deepcopy from datetime import datetime from pathlib import Path -from typing import Any, Iterable +from typing import Any from googleapiclient import discovery diff --git a/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_ssl.py b/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_ssl.py index 69ec1784fa47c..26802d38c72ab 100644 --- a/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_ssl.py +++ b/providers/tests/system/google/cloud/cloud_sql/example_cloud_sql_query_ssl.py @@ -27,10 +27,11 @@ import os import random import string +from collections.abc import Iterable from copy import deepcopy from datetime import datetime from pathlib import Path -from typing import Any, Iterable +from typing import Any from googleapiclient import discovery diff --git a/pyproject.toml b/pyproject.toml index 719dd892383f0..7065b26ca06cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -193,12 +193,12 @@ artifacts = [ ## black settings ## [tool.black] line-length = 110 -target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] +target-version = ['py39', 'py310', 'py311', 'py312'] ## ruff settings ## [tool.ruff] -target-version = "py38" +target-version = "py39" line-length = 110 extend-exclude = [ ".eggs", diff --git a/scripts/ci/pre_commit/check_common_sql_dependency.py b/scripts/ci/pre_commit/check_common_sql_dependency.py index 9719310a7174d..b1373262e0626 100755 --- a/scripts/ci/pre_commit/check_common_sql_dependency.py +++ b/scripts/ci/pre_commit/check_common_sql_dependency.py @@ -21,7 +21,7 @@ import ast import pathlib import sys -from typing import Iterable +from collections.abc import Iterable import yaml from packaging.specifiers import SpecifierSet diff --git a/scripts/ci/pre_commit/check_deferrable_default.py b/scripts/ci/pre_commit/check_deferrable_default.py index bfde61f231643..9659a2d43e232 100755 --- a/scripts/ci/pre_commit/check_deferrable_default.py +++ b/scripts/ci/pre_commit/check_deferrable_default.py @@ -23,7 +23,7 @@ import itertools import os import sys -from typing import Iterator +from collections.abc import Iterator import libcst as cst from libcst.codemod import CodemodContext diff --git a/scripts/ci/pre_commit/check_deprecations.py b/scripts/ci/pre_commit/check_deprecations.py index 9c827c4baafe2..ca6db992c9aef 100755 --- a/scripts/ci/pre_commit/check_deprecations.py +++ b/scripts/ci/pre_commit/check_deprecations.py @@ -21,7 +21,7 @@ import ast import sys from datetime import date -from functools import lru_cache +from functools import cache from pathlib import Path from typing import Any @@ -90,7 +90,7 @@ def get_decorator_argument(decorator: ast.Call, argument_name: str) -> ast.keywo return next(filter(lambda k: k and k.arg == argument_name, decorator.keywords), None) # type: ignore[arg-type] -@lru_cache(maxsize=None) +@cache def allowed_group_warnings(group: str) -> tuple[str, tuple[str, ...]]: group_warnings = allowed_warnings[group] if len(group_warnings) == 1: diff --git a/scripts/ci/pre_commit/common_precommit_black_utils.py b/scripts/ci/pre_commit/common_precommit_black_utils.py index 4e2bf48b5f18f..3cc139c2856aa 100644 --- a/scripts/ci/pre_commit/common_precommit_black_utils.py +++ b/scripts/ci/pre_commit/common_precommit_black_utils.py @@ -18,7 +18,7 @@ import os import sys -from functools import lru_cache +from functools import cache from pathlib import Path from black import Mode, TargetVersion, format_str, parse_pyproject_toml @@ -28,7 +28,7 @@ from common_precommit_utils import AIRFLOW_BREEZE_SOURCES_PATH -@lru_cache(maxsize=None) +@cache def black_mode(is_pyi: bool = Mode.is_pyi) -> Mode: config = parse_pyproject_toml(os.fspath(AIRFLOW_BREEZE_SOURCES_PATH / "pyproject.toml")) target_versions = {TargetVersion[val.upper()] for val in config.get("target_version", ())} diff --git a/scripts/ci/pre_commit/decorator_operator_implements_custom_name.py b/scripts/ci/pre_commit/decorator_operator_implements_custom_name.py index f0ce8a5bd2b65..d99ed0a1b0f6b 100755 --- a/scripts/ci/pre_commit/decorator_operator_implements_custom_name.py +++ b/scripts/ci/pre_commit/decorator_operator_implements_custom_name.py @@ -22,7 +22,7 @@ import itertools import pathlib import sys -from typing import Iterator +from collections.abc import Iterator def iter_decorated_operators(source: pathlib.Path) -> Iterator[ast.ClassDef]: diff --git a/scripts/ci/pre_commit/update_providers_dependencies.py b/scripts/ci/pre_commit/update_providers_dependencies.py index 8a0e797d0ab6a..b7899bf0a4b33 100755 --- a/scripts/ci/pre_commit/update_providers_dependencies.py +++ b/scripts/ci/pre_commit/update_providers_dependencies.py @@ -23,7 +23,7 @@ from ast import Import, ImportFrom, NodeVisitor, parse from collections import defaultdict from pathlib import Path -from typing import Any, List +from typing import Any import yaml from rich.console import Console @@ -70,7 +70,7 @@ class ImportFinder(NodeVisitor): def __init__(self) -> None: self.imports: list[str] = [] - self.handled_import_exception = List[str] + self.handled_import_exception = list[str] self.tried_imports: list[str] = [] def process_import(self, import_name: str) -> None: diff --git a/scripts/ci/pre_commit/validate_operators_init.py b/scripts/ci/pre_commit/validate_operators_init.py index 43404020915fd..0a5f58a9bf87d 100755 --- a/scripts/ci/pre_commit/validate_operators_init.py +++ b/scripts/ci/pre_commit/validate_operators_init.py @@ -85,12 +85,12 @@ def _handle_parent_constructor_kwargs( field. TODO: Enhance this function to work with nested inheritance trees through dynamic imports. - :param missing_assignments: List[str] - List of template fields that have not been assigned a value. + :param missing_assignments: list[str] - List of template fields that have not been assigned a value. :param ctor_stmt: ast.Expr - AST node representing the constructor statement. - :param invalid_assignments: List[str] - List of template fields that have been assigned incorrectly. - :param template_fields: List[str] - List of template fields to be assigned. + :param invalid_assignments: list[str] - List of template fields that have been assigned incorrectly. + :param template_fields: list[str] - List of template fields to be assigned. - :return: List[str] - List of template fields that are still missing assignments. + :return: list[str] - List of template fields that are still missing assignments. """ if isinstance(ctor_stmt, ast.Expr): if ( diff --git a/scripts/ci/pre_commit/vendor_k8s_json_schema.py b/scripts/ci/pre_commit/vendor_k8s_json_schema.py index 3348a73840e8d..e4354b522e441 100755 --- a/scripts/ci/pre_commit/vendor_k8s_json_schema.py +++ b/scripts/ci/pre_commit/vendor_k8s_json_schema.py @@ -19,7 +19,7 @@ from __future__ import annotations import json -from typing import Iterator +from collections.abc import Iterator import requests diff --git a/scripts/ci/testing/summarize_captured_warnings.py b/scripts/ci/testing/summarize_captured_warnings.py index 3187d9ab9c92b..43daa6775c60c 100755 --- a/scripts/ci/testing/summarize_captured_warnings.py +++ b/scripts/ci/testing/summarize_captured_warnings.py @@ -23,11 +23,11 @@ import json import os import shutil -from collections.abc import Iterator +from collections.abc import Iterable, Iterator from dataclasses import asdict, dataclass, fields from itertools import groupby from pathlib import Path -from typing import Any, Callable, Iterable +from typing import Any, Callable from uuid import NAMESPACE_OID, uuid5 if __name__ not in ("__main__", "__mp_main__"): @@ -70,7 +70,7 @@ def warnings_filename(suffix: str) -> str: WARNINGS_BAD = warnings_filename("bad") -@functools.lru_cache(maxsize=None) +@functools.cache def _unique_key(*args: str | None) -> str: return str(uuid5(NAMESPACE_OID, "-".join(map(str, args)))) diff --git a/scripts/ci/testing/summarize_junit_failures.py b/scripts/ci/testing/summarize_junit_failures.py index ac15ee417510f..d7d795aa4827f 100755 --- a/scripts/ci/testing/summarize_junit_failures.py +++ b/scripts/ci/testing/summarize_junit_failures.py @@ -23,7 +23,7 @@ import xml.etree.ElementTree as ET # Do not use anything outsdie of standard library in this file! -from functools import lru_cache +from functools import cache from pathlib import Path TEXT_RED = "\033[31m" @@ -31,7 +31,7 @@ TEXT_RESET = "\033[0m" -@lru_cache(maxsize=None) +@cache def translate_classname(classname): # The pytest xunit output has "classname" in the python sense as 'dir.subdir.package.Class' -- we want to # convert that back in to a pytest "selector" of dir/subdir/package.py::Class diff --git a/scripts/in_container/run_migration_reference.py b/scripts/in_container/run_migration_reference.py index 71b0040dc6864..086eb0aa33676 100755 --- a/scripts/in_container/run_migration_reference.py +++ b/scripts/in_container/run_migration_reference.py @@ -25,8 +25,9 @@ import os import re import textwrap +from collections.abc import Iterable from pathlib import Path -from typing import TYPE_CHECKING, Iterable +from typing import TYPE_CHECKING import re2 from alembic.script import ScriptDirectory diff --git a/scripts/in_container/run_provider_yaml_files_check.py b/scripts/in_container/run_provider_yaml_files_check.py index 7d5756b2e7ef1..c23b3d0acaf81 100755 --- a/scripts/in_container/run_provider_yaml_files_check.py +++ b/scripts/in_container/run_provider_yaml_files_check.py @@ -29,8 +29,9 @@ import textwrap import warnings from collections import Counter +from collections.abc import Iterable from enum import Enum -from typing import Any, Callable, Iterable +from typing import Any, Callable import jsonschema import yaml diff --git a/scripts/in_container/verify_providers.py b/scripts/in_container/verify_providers.py index f67334c451990..61ce0fcb0ef6d 100755 --- a/scripts/in_container/verify_providers.py +++ b/scripts/in_container/verify_providers.py @@ -28,8 +28,9 @@ import traceback import warnings from enum import Enum -from inspect import isclass +from inspect import isabstract, isclass from pathlib import Path +from types import GenericAlias from typing import NamedTuple from rich.console import Console @@ -200,11 +201,23 @@ def onerror(_): for attribute_name in dir(_module): class_name = modinfo.name + "." + attribute_name attribute = getattr(_module, attribute_name) - if isclass(attribute): - imported_classes.append(class_name) - if isclass(attribute) and ( - issubclass(attribute, logging.Handler) - or issubclass(attribute, BaseSecretsBackend) + + # Skip + # - parameterized generics like Sequence[tuple[str, str]] + # - builtins like str, int, etc. + # - non-class objects + if ( + isinstance(attribute, GenericAlias) + or (hasattr(attribute, "__module__") and attribute.__module__ == "builtins") + or not isclass(attribute) + ): + continue + + imported_classes.append(class_name) + + # Handle circular imports for specific subclasses + if issubclass(attribute, logging.Handler) or ( + isabstract(attribute) and issubclass(attribute, BaseSecretsBackend) ): classes_with_potential_circular_import.append(class_name) except AirflowOptionalProviderFeatureException: diff --git a/tests/always/test_secrets_local_filesystem.py b/tests/always/test_secrets_local_filesystem.py index e4f7de7df6722..e8b179787c1b8 100644 --- a/tests/always/test_secrets_local_filesystem.py +++ b/tests/always/test_secrets_local_filesystem.py @@ -35,9 +35,10 @@ @contextmanager def mock_local_file(content): - with mock.patch( - "airflow.secrets.local_filesystem.open", mock.mock_open(read_data=content) - ) as file_mock, mock.patch("airflow.secrets.local_filesystem.os.path.exists", return_value=True): + with ( + mock.patch("airflow.secrets.local_filesystem.open", mock.mock_open(read_data=content)) as file_mock, + mock.patch("airflow.secrets.local_filesystem.os.path.exists", return_value=True), + ): yield file_mock diff --git a/tests/api_connexion/endpoints/test_asset_endpoint.py b/tests/api_connexion/endpoints/test_asset_endpoint.py index 9e9371b91ef75..48c94553a99f2 100644 --- a/tests/api_connexion/endpoints/test_asset_endpoint.py +++ b/tests/api_connexion/endpoints/test_asset_endpoint.py @@ -17,7 +17,7 @@ from __future__ import annotations import urllib -from typing import Generator +from collections.abc import Generator from unittest.mock import ANY import pytest diff --git a/tests/api_fastapi/core_api/routes/public/test_assets.py b/tests/api_fastapi/core_api/routes/public/test_assets.py index 2faed1826711c..8976af87fa13b 100644 --- a/tests/api_fastapi/core_api/routes/public/test_assets.py +++ b/tests/api_fastapi/core_api/routes/public/test_assets.py @@ -17,7 +17,7 @@ from __future__ import annotations import urllib -from typing import Generator +from collections.abc import Generator from unittest import mock import pytest diff --git a/tests/api_fastapi/core_api/routes/public/test_config.py b/tests/api_fastapi/core_api/routes/public/test_config.py index 76aa5b0b6a531..f981ae0af1021 100644 --- a/tests/api_fastapi/core_api/routes/public/test_config.py +++ b/tests/api_fastapi/core_api/routes/public/test_config.py @@ -17,7 +17,7 @@ from __future__ import annotations import textwrap -from typing import Generator +from collections.abc import Generator from unittest.mock import patch import pytest diff --git a/tests/api_internal/endpoints/test_rpc_api_endpoint.py b/tests/api_internal/endpoints/test_rpc_api_endpoint.py index 6f7b151aebff6..7050026f9c060 100644 --- a/tests/api_internal/endpoints/test_rpc_api_endpoint.py +++ b/tests/api_internal/endpoints/test_rpc_api_endpoint.py @@ -17,7 +17,8 @@ from __future__ import annotations import json -from typing import TYPE_CHECKING, Generator +from collections.abc import Generator +from typing import TYPE_CHECKING from unittest import mock import pytest diff --git a/tests/charts/helm_template_generator.py b/tests/charts/helm_template_generator.py index d3a8ed954b65e..0fb7a847d0575 100644 --- a/tests/charts/helm_template_generator.py +++ b/tests/charts/helm_template_generator.py @@ -18,7 +18,7 @@ import json import subprocess -from functools import lru_cache +from functools import cache from io import StringIO from pathlib import Path from tempfile import NamedTemporaryFile @@ -77,7 +77,7 @@ def get_schema_crd(api_version, kind): return schema -@lru_cache(maxsize=None) +@cache def create_validator(api_version, kind, kubernetes_version): schema = get_schema_crd(api_version, kind) if not schema: diff --git a/tests/cli/commands/test_fastapi_api_command.py b/tests/cli/commands/test_fastapi_api_command.py index 7f58f1ac482b3..13039c566e421 100644 --- a/tests/cli/commands/test_fastapi_api_command.py +++ b/tests/cli/commands/test_fastapi_api_command.py @@ -101,8 +101,9 @@ def test_cli_fastapi_api_background(self, tmp_path): raise def test_cli_fastapi_api_debug(self, app): - with mock.patch("subprocess.Popen") as Popen, mock.patch.object( - fastapi_api_command, "GunicornMonitor" + with ( + mock.patch("subprocess.Popen") as Popen, + mock.patch.object(fastapi_api_command, "GunicornMonitor"), ): port = "9092" hostname = "somehost" @@ -127,9 +128,11 @@ def test_cli_fastapi_api_env_var_set_unset(self, app): Test that AIRFLOW_API_APPS is set and unset in the environment when calling the airflow fastapi-api command """ - with mock.patch("subprocess.Popen") as Popen, mock.patch.object( - fastapi_api_command, "GunicornMonitor" - ), mock.patch("os.environ", autospec=True) as mock_environ: + with ( + mock.patch("subprocess.Popen") as Popen, + mock.patch.object(fastapi_api_command, "GunicornMonitor"), + mock.patch("os.environ", autospec=True) as mock_environ, + ): apps_value = "core,execution" port = "9092" hostname = "somehost" @@ -168,8 +171,9 @@ def test_cli_fastapi_api_env_var_set_unset(self, app): def test_cli_fastapi_api_args(self, ssl_cert_and_key): cert_path, key_path = ssl_cert_and_key - with mock.patch("subprocess.Popen") as Popen, mock.patch.object( - fastapi_api_command, "GunicornMonitor" + with ( + mock.patch("subprocess.Popen") as Popen, + mock.patch.object(fastapi_api_command, "GunicornMonitor"), ): args = self.parser.parse_args( [ diff --git a/tests/cli/commands/test_internal_api_command.py b/tests/cli/commands/test_internal_api_command.py index 443fa2bb49782..329e8bfbe5336 100644 --- a/tests/cli/commands/test_internal_api_command.py +++ b/tests/cli/commands/test_internal_api_command.py @@ -155,9 +155,10 @@ def test_cli_internal_api_background(self, tmp_path): @conf_vars({("core", "database_access_isolation"): "true"}) def test_cli_internal_api_debug(self, app): - with mock.patch( - "airflow.cli.commands.internal_api_command.create_app", return_value=app - ), mock.patch.object(app, "run") as app_run: + with ( + mock.patch("airflow.cli.commands.internal_api_command.create_app", return_value=app), + mock.patch.object(app, "run") as app_run, + ): args = self.parser.parse_args( [ "internal-api", @@ -175,8 +176,9 @@ def test_cli_internal_api_debug(self, app): @conf_vars({("core", "database_access_isolation"): "true"}) def test_cli_internal_api_args(self): - with mock.patch("subprocess.Popen") as Popen, mock.patch.object( - internal_api_command, "GunicornMonitor" + with ( + mock.patch("subprocess.Popen") as Popen, + mock.patch.object(internal_api_command, "GunicornMonitor"), ): args = self.parser.parse_args( [ diff --git a/tests/cli/commands/test_rotate_fernet_key_command.py b/tests/cli/commands/test_rotate_fernet_key_command.py index 8529ad0040198..0a3a859edc93a 100644 --- a/tests/cli/commands/test_rotate_fernet_key_command.py +++ b/tests/cli/commands/test_rotate_fernet_key_command.py @@ -58,21 +58,24 @@ def test_should_rotate_variable(self, session): Variable.set(key=var1_key, value="value") # Create encrypted variable - with conf_vars({("core", "fernet_key"): fernet_key1.decode()}), mock.patch( - "airflow.models.crypto._fernet", None + with ( + conf_vars({("core", "fernet_key"): fernet_key1.decode()}), + mock.patch("airflow.models.crypto._fernet", None), ): Variable.set(key=var2_key, value="value") # Rotate fernet key - with conf_vars( - {("core", "fernet_key"): f"{fernet_key2.decode()},{fernet_key1.decode()}"} - ), mock.patch("airflow.models.crypto._fernet", None): + with ( + conf_vars({("core", "fernet_key"): f"{fernet_key2.decode()},{fernet_key1.decode()}"}), + mock.patch("airflow.models.crypto._fernet", None), + ): args = self.parser.parse_args(["rotate-fernet-key"]) rotate_fernet_key_command.rotate_fernet_key(args) # Assert correctness using a new fernet key - with conf_vars({("core", "fernet_key"): fernet_key2.decode()}), mock.patch( - "airflow.models.crypto._fernet", None + with ( + conf_vars({("core", "fernet_key"): fernet_key2.decode()}), + mock.patch("airflow.models.crypto._fernet", None), ): var1 = session.query(Variable).filter(Variable.key == var1_key).first() # Unencrypted variable should be unchanged @@ -93,22 +96,25 @@ def test_should_rotate_connection(self, session): session.commit() # Create encrypted variable - with conf_vars({("core", "fernet_key"): fernet_key1.decode()}), mock.patch( - "airflow.models.crypto._fernet", None + with ( + conf_vars({("core", "fernet_key"): fernet_key1.decode()}), + mock.patch("airflow.models.crypto._fernet", None), ): session.add(Connection(conn_id=var2_key, uri="mysql://user:pass@localhost")) session.commit() # Rotate fernet key - with conf_vars( - {("core", "fernet_key"): f"{fernet_key2.decode()},{fernet_key1.decode()}"} - ), mock.patch("airflow.models.crypto._fernet", None): + with ( + conf_vars({("core", "fernet_key"): f"{fernet_key2.decode()},{fernet_key1.decode()}"}), + mock.patch("airflow.models.crypto._fernet", None), + ): args = self.parser.parse_args(["rotate-fernet-key"]) rotate_fernet_key_command.rotate_fernet_key(args) # Assert correctness using a new fernet key - with conf_vars({("core", "fernet_key"): fernet_key2.decode()}), mock.patch( - "airflow.models.crypto._fernet", None + with ( + conf_vars({("core", "fernet_key"): fernet_key2.decode()}), + mock.patch("airflow.models.crypto._fernet", None), ): # Unencrypted variable should be unchanged conn1: Connection = BaseHook.get_connection(var1_key) diff --git a/tests/cli/commands/test_task_command.py b/tests/cli/commands/test_task_command.py index f78b53c5a769e..98e63bcd40133 100644 --- a/tests/cli/commands/test_task_command.py +++ b/tests/cli/commands/test_task_command.py @@ -183,8 +183,9 @@ def test_cli_test_different_path(self, session, tmp_path): # should be able to find the dag. new_file_path = tmp_path / orig_file_path.name new_dags_folder = new_file_path.parent - with move_back(orig_file_path, new_file_path), conf_vars( - {("core", "dags_folder"): new_dags_folder.as_posix()} + with ( + move_back(orig_file_path, new_file_path), + conf_vars({("core", "dags_folder"): new_dags_folder.as_posix()}), ): ser_dag = ( session.query(SerializedDagModel) @@ -487,11 +488,12 @@ def test_cli_run_no_local_no_raw_runs_executor(self, dag_maker): from airflow.cli.commands import task_command with dag_maker(dag_id="test_executor", schedule="@daily") as dag: - with mock.patch( - "airflow.executors.executor_loader.ExecutorLoader.load_executor" - ) as loader_mock, mock.patch( - "airflow.executors.executor_loader.ExecutorLoader.get_default_executor" - ) as get_default_mock: + with ( + mock.patch("airflow.executors.executor_loader.ExecutorLoader.load_executor") as loader_mock, + mock.patch( + "airflow.executors.executor_loader.ExecutorLoader.get_default_executor" + ) as get_default_mock, + ): EmptyOperator(task_id="task1") EmptyOperator(task_id="task2", executor="foo_executor_alias") diff --git a/tests/cli/commands/test_webserver_command.py b/tests/cli/commands/test_webserver_command.py index 2eaa3950010e2..eb20b04885f13 100644 --- a/tests/cli/commands/test_webserver_command.py +++ b/tests/cli/commands/test_webserver_command.py @@ -313,9 +313,10 @@ def test_cli_webserver_shutdown_when_gunicorn_master_is_killed(self, _): assert ctx.value.code == 1 def test_cli_webserver_debug(self, app): - with mock.patch("airflow.www.app.create_app", return_value=app), mock.patch.object( - app, "run" - ) as app_run: + with ( + mock.patch("airflow.www.app.create_app", return_value=app), + mock.patch.object(app, "run") as app_run, + ): args = self.parser.parse_args( [ "webserver", diff --git a/tests/cli/test_cli_parser.py b/tests/cli/test_cli_parser.py index 0336dcb1eade3..1f14ff7b077cd 100644 --- a/tests/cli/test_cli_parser.py +++ b/tests/cli/test_cli_parser.py @@ -349,9 +349,10 @@ def test_positive_int(self): ], ) def test_executor_specific_commands_not_accessible(self, command): - with conf_vars({("core", "executor"): "SequentialExecutor"}), contextlib.redirect_stderr( - StringIO() - ) as stderr: + with ( + conf_vars({("core", "executor"): "SequentialExecutor"}), + contextlib.redirect_stderr(StringIO()) as stderr, + ): reload(executor_loader) reload(cli_parser) parser = cli_parser.get_parser() @@ -380,9 +381,10 @@ def test_executor_specific_commands_not_accessible(self, command): def test_cli_parser_executors(self, executor, expected_args): """Test that CLI commands for the configured executor are present""" for expected_arg in expected_args: - with conf_vars({("core", "executor"): executor}), contextlib.redirect_stderr( - StringIO() - ) as stderr: + with ( + conf_vars({("core", "executor"): executor}), + contextlib.redirect_stderr(StringIO()) as stderr, + ): reload(executor_loader) reload(cli_parser) parser = cli_parser.get_parser() diff --git a/tests/core/test_configuration.py b/tests/core/test_configuration.py index 1fb3b27057360..ceea18e4563d9 100644 --- a/tests/core/test_configuration.py +++ b/tests/core/test_configuration.py @@ -975,9 +975,14 @@ def test_deprecated_options(self): def test_deprecated_options_cmd(self): # Guarantee we have a deprecated setting, so we test the deprecation # lookup even if we remove this explicit fallback - with set_deprecated_options( - deprecated_options={("celery", "result_backend"): ("celery", "celery_result_backend", "2.0.0")} - ), set_sensitive_config_values(sensitive_config_values={("celery", "celery_result_backend")}): + with ( + set_deprecated_options( + deprecated_options={ + ("celery", "result_backend"): ("celery", "celery_result_backend", "2.0.0") + } + ), + set_sensitive_config_values(sensitive_config_values={("celery", "celery_result_backend")}), + ): conf.remove_option("celery", "result_backend") with conf_vars({("celery", "celery_result_backend_cmd"): "/bin/echo 99"}): with pytest.warns(DeprecationWarning): diff --git a/tests/core/test_settings.py b/tests/core/test_settings.py index 00f0d14b6d519..db1b3a5cf6ed1 100644 --- a/tests/core/test_settings.py +++ b/tests/core/test_settings.py @@ -282,9 +282,12 @@ def test_uses_updated_session_timeout_config_by_default(self): def test_sqlite_relative_path(value, expectation): from airflow import settings - with patch("os.environ", {"_AIRFLOW_SKIP_DB_TESTS": "true"}), patch( - "airflow.settings.SQL_ALCHEMY_CONN", value - ), patch("airflow.settings.Session"), patch("airflow.settings.engine"): + with ( + patch("os.environ", {"_AIRFLOW_SKIP_DB_TESTS": "true"}), + patch("airflow.settings.SQL_ALCHEMY_CONN", value), + patch("airflow.settings.Session"), + patch("airflow.settings.engine"), + ): with expectation: settings.configure_orm() diff --git a/tests/dags/test_only_empty_tasks.py b/tests/dags/test_only_empty_tasks.py index 99c0224e56e81..e5152f1f9ad34 100644 --- a/tests/dags/test_only_empty_tasks.py +++ b/tests/dags/test_only_empty_tasks.py @@ -17,8 +17,8 @@ # under the License. from __future__ import annotations +from collections.abc import Sequence from datetime import datetime -from typing import Sequence from airflow.models.dag import DAG from airflow.operators.empty import EmptyOperator diff --git a/tests/decorators/test_python.py b/tests/decorators/test_python.py index 83c6f8ab4dce2..f53ca83bb88b4 100644 --- a/tests/decorators/test_python.py +++ b/tests/decorators/test_python.py @@ -16,9 +16,10 @@ # specific language governing permissions and limitations # under the License. import sys +import typing from collections import namedtuple from datetime import date, timedelta -from typing import TYPE_CHECKING, Dict, Tuple, Union +from typing import Union import pytest @@ -49,7 +50,7 @@ pytestmark = pytest.mark.db_test -if TYPE_CHECKING: +if typing.TYPE_CHECKING: from airflow.models.dagrun import DagRun DEFAULT_DATE = timezone.datetime(2016, 1, 1) @@ -85,8 +86,8 @@ def test_python_operator_python_callable_is_callable(self): reason="PEP 585 is implemented in Python 3.9", ), ), - "Dict", - "Dict[str, int]", + "typing.Dict", + "dict[str, int]", ], ) def test_infer_multiple_outputs_using_dict_typing(self, resolve, annotation): @@ -137,20 +138,20 @@ def t1() -> Union[str, None]: assert t1().operator.multiple_outputs is False def test_infer_multiple_outputs_forward_annotation(self): - if TYPE_CHECKING: + if typing.TYPE_CHECKING: class FakeTypeCheckingOnlyClass: ... class UnresolveableName: ... @task_decorator - def t1(x: "FakeTypeCheckingOnlyClass", y: int) -> Dict[int, int]: # type: ignore[empty-body] + def t1(x: "FakeTypeCheckingOnlyClass", y: int) -> dict[int, int]: # type: ignore[empty-body] ... assert t1(5, 5).operator.multiple_outputs is True @task_decorator - def t2(x: "FakeTypeCheckingOnlyClass", y: int) -> "Dict[int, int]": # type: ignore[empty-body] + def t2(x: "FakeTypeCheckingOnlyClass", y: int) -> "dict[int, int]": # type: ignore[empty-body] ... assert t2(5, 5).operator.multiple_outputs is True @@ -176,7 +177,7 @@ def t3( # type: ignore[empty-body] def test_infer_multiple_outputs_using_other_typing(self): @task_decorator - def identity_tuple(x: int, y: int) -> Tuple[int, int]: + def identity_tuple(x: int, y: int) -> tuple[int, int]: return x, y assert identity_tuple(5, 5).operator.multiple_outputs is False @@ -195,7 +196,7 @@ def identity_notyping(x: int): # The following cases ensure invoking ``@task_decorator.__call__()`` yields the correct inference. @task_decorator() - def identity_tuple_with_decorator_call(x: int, y: int) -> Tuple[int, int]: + def identity_tuple_with_decorator_call(x: int, y: int) -> tuple[int, int]: return x, y assert identity_tuple_with_decorator_call(5, 5).operator.multiple_outputs is False @@ -215,7 +216,7 @@ def identity_notyping_with_decorator_call(x: int): @pytest.mark.skip_if_database_isolation_mode # Test is broken in db isolation mode def test_manual_multiple_outputs_false_with_typings(self): @task_decorator(multiple_outputs=False) - def identity2(x: int, y: int) -> Tuple[int, int]: + def identity2(x: int, y: int) -> tuple[int, int]: return x, y with self.dag_non_serialized: @@ -234,7 +235,7 @@ def identity2(x: int, y: int) -> Tuple[int, int]: @pytest.mark.skip_if_database_isolation_mode # Test is broken in db isolation mode def test_multiple_outputs_ignore_typing(self): @task_decorator - def identity_tuple(x: int, y: int) -> Tuple[int, int]: + def identity_tuple(x: int, y: int) -> tuple[int, int]: return x, y with self.dag_non_serialized: diff --git a/tests/integration/cli/commands/test_celery_command.py b/tests/integration/cli/commands/test_celery_command.py index ce38535ce46ae..5acb3a963a20e 100644 --- a/tests/integration/cli/commands/test_celery_command.py +++ b/tests/integration/cli/commands/test_celery_command.py @@ -43,8 +43,9 @@ def setup_class(cls): @conf_vars({("core", "executor"): "CeleryExecutor"}) def test_serve_logs_on_worker_start(self): - with mock.patch("airflow.cli.commands.celery_command.Process") as mock_process, mock.patch( - "airflow.providers.celery.executors.celery_executor.app" + with ( + mock.patch("airflow.cli.commands.celery_command.Process") as mock_process, + mock.patch("airflow.providers.celery.executors.celery_executor.app"), ): args = self.parser.parse_args(["celery", "worker", "--concurrency", "1"]) @@ -55,8 +56,9 @@ def test_serve_logs_on_worker_start(self): @conf_vars({("core", "executor"): "CeleryExecutor"}) def test_skip_serve_logs_on_worker_start(self): - with mock.patch("airflow.cli.commands.celery_command.Process") as mock_popen, mock.patch( - "airflow.providers.celery.executors.celery_executor.app" + with ( + mock.patch("airflow.cli.commands.celery_command.Process") as mock_popen, + mock.patch("airflow.providers.celery.executors.celery_executor.app"), ): args = self.parser.parse_args(["celery", "worker", "--concurrency", "1", "--skip-serve-logs"]) diff --git a/tests/integration/executors/test_celery_executor.py b/tests/integration/executors/test_celery_executor.py index 7bbe3bd29b940..a29355da2e8ee 100644 --- a/tests/integration/executors/test_celery_executor.py +++ b/tests/integration/executors/test_celery_executor.py @@ -234,11 +234,15 @@ def test_retry_on_error_sending_task(self, caplog): """Test that Airflow retries publishing tasks to Celery Broker at least 3 times""" from airflow.providers.celery.executors import celery_executor, celery_executor_utils - with _prepare_app(), caplog.at_level(logging.INFO), mock.patch.object( - # Mock `with timeout()` to _instantly_ fail. - celery_executor_utils.timeout, - "__enter__", - side_effect=AirflowTaskTimeout, + with ( + _prepare_app(), + caplog.at_level(logging.INFO), + mock.patch.object( + # Mock `with timeout()` to _instantly_ fail. + celery_executor_utils.timeout, + "__enter__", + side_effect=AirflowTaskTimeout, + ), ): executor = celery_executor.CeleryExecutor() assert executor.task_publish_retries == {} diff --git a/tests/jobs/test_scheduler_job.py b/tests/jobs/test_scheduler_job.py index 4578cc535f513..5102079c487a4 100644 --- a/tests/jobs/test_scheduler_job.py +++ b/tests/jobs/test_scheduler_job.py @@ -23,9 +23,9 @@ import os import sys from collections import Counter, deque +from collections.abc import Generator from datetime import timedelta from importlib import reload -from typing import Generator from unittest import mock from unittest.mock import MagicMock, PropertyMock, patch from uuid import uuid4 @@ -2771,9 +2771,10 @@ def test_dagrun_callbacks_commited_before_sent(self, dag_maker): ti = dr.get_task_instance("dummy") ti.set_state(State.SUCCESS, session) - with mock.patch.object(settings, "USE_JOB_SCHEDULE", False), mock.patch( - "airflow.jobs.scheduler_job_runner.prohibit_commit" - ) as mock_guard: + with ( + mock.patch.object(settings, "USE_JOB_SCHEDULE", False), + mock.patch("airflow.jobs.scheduler_job_runner.prohibit_commit") as mock_guard, + ): mock_guard.return_value.__enter__.return_value.commit.side_effect = session.commit def mock_schedule_dag_run(*args, **kwargs): @@ -4285,9 +4286,12 @@ def test_scheduler_create_dag_runs_does_not_raise_error(self, caplog, dag_maker) caplog.set_level("FATAL") caplog.clear() - with create_session() as session, caplog.at_level( - "ERROR", - logger="airflow.jobs.scheduler_job_runner", + with ( + create_session() as session, + caplog.at_level( + "ERROR", + logger="airflow.jobs.scheduler_job_runner", + ), ): self.job_runner._create_dag_runs([dag_maker.dag_model], session) assert caplog.messages == [ @@ -6568,26 +6572,29 @@ def per_test(self) -> Generator: ], ) def test_execute_queries_count_with_harvested_dags(self, expected_query_count, dag_count, task_count): - with mock.patch.dict( - "os.environ", - { - "PERF_DAGS_COUNT": str(dag_count), - "PERF_TASKS_COUNT": str(task_count), - "PERF_START_AGO": "1d", - "PERF_SCHEDULE_INTERVAL": "30m", - "PERF_SHAPE": "no_structure", - }, - ), conf_vars( - { - ("scheduler", "use_job_schedule"): "True", - ("core", "load_examples"): "False", - # For longer running tests under heavy load, the min_serialized_dag_fetch_interval - # and min_serialized_dag_update_interval might kick-in and re-retrieve the record. - # This will increase the count of serliazied_dag.py.get() count. - # That's why we keep the values high - ("core", "min_serialized_dag_update_interval"): "100", - ("core", "min_serialized_dag_fetch_interval"): "100", - } + with ( + mock.patch.dict( + "os.environ", + { + "PERF_DAGS_COUNT": str(dag_count), + "PERF_TASKS_COUNT": str(task_count), + "PERF_START_AGO": "1d", + "PERF_SCHEDULE_INTERVAL": "30m", + "PERF_SHAPE": "no_structure", + }, + ), + conf_vars( + { + ("scheduler", "use_job_schedule"): "True", + ("core", "load_examples"): "False", + # For longer running tests under heavy load, the min_serialized_dag_fetch_interval + # and min_serialized_dag_update_interval might kick-in and re-retrieve the record. + # This will increase the count of serliazied_dag.py.get() count. + # That's why we keep the values high + ("core", "min_serialized_dag_update_interval"): "100", + ("core", "min_serialized_dag_fetch_interval"): "100", + } + ), ): dagruns = [] dagbag = DagBag(dag_folder=ELASTIC_DAG_FILE, include_examples=False, read_dags_from_db=False) @@ -6663,25 +6670,28 @@ def test_execute_queries_count_with_harvested_dags(self, expected_query_count, d def test_process_dags_queries_count( self, expected_query_counts, dag_count, task_count, start_ago, schedule, shape ): - with mock.patch.dict( - "os.environ", - { - "PERF_DAGS_COUNT": str(dag_count), - "PERF_TASKS_COUNT": str(task_count), - "PERF_START_AGO": start_ago, - "PERF_SCHEDULE_INTERVAL": schedule, - "PERF_SHAPE": shape, - }, - ), conf_vars( - { - ("scheduler", "use_job_schedule"): "True", - # For longer running tests under heavy load, the min_serialized_dag_fetch_interval - # and min_serialized_dag_update_interval might kick-in and re-retrieve the record. - # This will increase the count of serliazied_dag.py.get() count. - # That's why we keep the values high - ("core", "min_serialized_dag_update_interval"): "100", - ("core", "min_serialized_dag_fetch_interval"): "100", - } + with ( + mock.patch.dict( + "os.environ", + { + "PERF_DAGS_COUNT": str(dag_count), + "PERF_TASKS_COUNT": str(task_count), + "PERF_START_AGO": start_ago, + "PERF_SCHEDULE_INTERVAL": schedule, + "PERF_SHAPE": shape, + }, + ), + conf_vars( + { + ("scheduler", "use_job_schedule"): "True", + # For longer running tests under heavy load, the min_serialized_dag_fetch_interval + # and min_serialized_dag_update_interval might kick-in and re-retrieve the record. + # This will increase the count of serliazied_dag.py.get() count. + # That's why we keep the values high + ("core", "min_serialized_dag_update_interval"): "100", + ("core", "min_serialized_dag_fetch_interval"): "100", + } + ), ): dagbag = DagBag(dag_folder=ELASTIC_DAG_FILE, include_examples=False) dagbag.sync_to_db() diff --git a/tests/models/test_dag.py b/tests/models/test_dag.py index 1f946d027dfe1..18a6d4cfec2ac 100644 --- a/tests/models/test_dag.py +++ b/tests/models/test_dag.py @@ -274,9 +274,10 @@ def test_dag_task_priority_weight_total_using_absolute(self): ], ) def test_dag_task_custom_weight_strategy(self, cls, expected): - with mock_plugin_manager(plugins=[TestPriorityWeightStrategyPlugin]), DAG( - "dag", schedule=None, start_date=DEFAULT_DATE, default_args={"owner": "owner1"} - ) as dag: + with ( + mock_plugin_manager(plugins=[TestPriorityWeightStrategyPlugin]), + DAG("dag", schedule=None, start_date=DEFAULT_DATE, default_args={"owner": "owner1"}) as dag, + ): task = EmptyOperator( task_id="empty_task", weight_rule=cls(), diff --git a/tests/models/test_dagrun.py b/tests/models/test_dagrun.py index e26fe620c0b01..570bb7897ad8f 100644 --- a/tests/models/test_dagrun.py +++ b/tests/models/test_dagrun.py @@ -18,8 +18,9 @@ from __future__ import annotations import datetime +from collections.abc import Mapping from functools import reduce -from typing import TYPE_CHECKING, Mapping +from typing import TYPE_CHECKING from unittest import mock from unittest.mock import call diff --git a/tests/models/test_trigger.py b/tests/models/test_trigger.py index af6bde061671b..76cce7ea7c7ab 100644 --- a/tests/models/test_trigger.py +++ b/tests/models/test_trigger.py @@ -18,7 +18,8 @@ import datetime import json -from typing import Any, AsyncIterator +from collections.abc import AsyncIterator +from typing import Any from unittest.mock import patch import pendulum diff --git a/tests/operators/test_trigger_dagrun.py b/tests/operators/test_trigger_dagrun.py index 3100f62d66d25..8a7f274499cd3 100644 --- a/tests/operators/test_trigger_dagrun.py +++ b/tests/operators/test_trigger_dagrun.py @@ -720,8 +720,9 @@ def test_dagstatetrigger_logical_dates_with_clear_and_reset(self, dag_maker): # Simulate the TriggerDagRunOperator task being cleared (aka executed again). A DagRunAlreadyExists # exception should be raised because of the previous DAG run. - with mock.patch.object(TriggerDagRunOperator, "defer", mock_task_defer), pytest.raises( - (DagRunAlreadyExists, TaskDeferred) + with ( + mock.patch.object(TriggerDagRunOperator, "defer", mock_task_defer), + pytest.raises((DagRunAlreadyExists, TaskDeferred)), ): task.execute({"task_instance": mock.MagicMock()}) diff --git a/tests/plugins/test_plugins_manager.py b/tests/plugins/test_plugins_manager.py index e6777901b8041..6a58c28452b86 100644 --- a/tests/plugins/test_plugins_manager.py +++ b/tests/plugins/test_plugins_manager.py @@ -222,9 +222,10 @@ class AirflowAdminMenuLinksPlugin(AirflowPlugin): menu_links = [mock.MagicMock()] - with mock_plugin_manager( - plugins=[AirflowAdminViewsPlugin(), AirflowAdminMenuLinksPlugin()] - ), caplog.at_level(logging.WARNING, logger="airflow.plugins_manager"): + with ( + mock_plugin_manager(plugins=[AirflowAdminViewsPlugin(), AirflowAdminMenuLinksPlugin()]), + caplog.at_level(logging.WARNING, logger="airflow.plugins_manager"), + ): from airflow import plugins_manager plugins_manager.initialize_web_ui_plugins() @@ -255,9 +256,10 @@ class AirflowAdminMenuLinksPlugin(AirflowPlugin): appbuilder_menu_items = [mock.MagicMock()] - with mock_plugin_manager( - plugins=[AirflowAdminViewsPlugin(), AirflowAdminMenuLinksPlugin()] - ), caplog.at_level(logging.WARNING, logger="airflow.plugins_manager"): + with ( + mock_plugin_manager(plugins=[AirflowAdminViewsPlugin(), AirflowAdminMenuLinksPlugin()]), + caplog.at_level(logging.WARNING, logger="airflow.plugins_manager"), + ): from airflow import plugins_manager plugins_manager.initialize_web_ui_plugins() @@ -277,9 +279,10 @@ class AirflowAdminMenuLinksPlugin(AirflowPlugin): menu_links = [mock.MagicMock()] appbuilder_menu_items = [mock.MagicMock()] - with mock_plugin_manager( - plugins=[AirflowAdminViewsPlugin(), AirflowAdminMenuLinksPlugin()] - ), caplog.at_level(logging.WARNING, logger="airflow.plugins_manager"): + with ( + mock_plugin_manager(plugins=[AirflowAdminViewsPlugin(), AirflowAdminMenuLinksPlugin()]), + caplog.at_level(logging.WARNING, logger="airflow.plugins_manager"), + ): from airflow import plugins_manager plugins_manager.initialize_web_ui_plugins() @@ -302,8 +305,9 @@ def test_entrypoint_plugin_errors_dont_raise_exceptions(self, mock_metadata_dist mock_entrypoint.load.side_effect = ImportError("my_fake_module not found") mock_dist.entry_points = [mock_entrypoint] - with mock_metadata_distribution(return_value=[mock_dist]), caplog.at_level( - logging.ERROR, logger="airflow.plugins_manager" + with ( + mock_metadata_distribution(return_value=[mock_dist]), + caplog.at_level(logging.ERROR, logger="airflow.plugins_manager"), ): load_entrypoint_plugins() diff --git a/tests/serialization/serializers/test_serializers.py b/tests/serialization/serializers/test_serializers.py index 157acaeb4817b..5936a95b23d6d 100644 --- a/tests/serialization/serializers/test_serializers.py +++ b/tests/serialization/serializers/test_serializers.py @@ -20,6 +20,7 @@ import decimal from importlib import metadata from unittest.mock import patch +from zoneinfo import ZoneInfo import numpy as np import pendulum @@ -29,7 +30,6 @@ from packaging import version from pendulum import DateTime from pendulum.tz.timezone import FixedTimezone, Timezone -from zoneinfo import ZoneInfo from airflow.models.param import Param, ParamsDict from airflow.serialization.serde import DATA, deserialize, serialize @@ -189,11 +189,12 @@ def test_iceberg(self): from pyiceberg.io import FileIO from pyiceberg.table import Table - with patch.object(Catalog, "__abstractmethods__", set()), patch.object( - FileIO, "__abstractmethods__", set() - ), patch("pyiceberg.catalog.Catalog.load_table") as mock_load_table, patch( - "pyiceberg.catalog.load_catalog" - ) as mock_load_catalog: + with ( + patch.object(Catalog, "__abstractmethods__", set()), + patch.object(FileIO, "__abstractmethods__", set()), + patch("pyiceberg.catalog.Catalog.load_table") as mock_load_table, + patch("pyiceberg.catalog.load_catalog") as mock_load_catalog, + ): uri = "http://rest.no.where" catalog = Catalog("catalog", uri=uri) identifier = ("catalog", "schema", "table") @@ -211,9 +212,12 @@ def test_iceberg(self): def test_deltalake(selfa): deltalake = pytest.importorskip("deltalake") - with patch("deltalake.table.Metadata"), patch("deltalake.table.RawDeltaTable"), patch.object( - deltalake.DeltaTable, "version", return_value=0 - ), patch.object(deltalake.DeltaTable, "table_uri", new_callable=lambda: "/tmp/bucket/path"): + with ( + patch("deltalake.table.Metadata"), + patch("deltalake.table.RawDeltaTable"), + patch.object(deltalake.DeltaTable, "version", return_value=0), + patch.object(deltalake.DeltaTable, "table_uri", new_callable=lambda: "/tmp/bucket/path"), + ): uri = "/tmp/bucket/path" i = deltalake.DeltaTable(uri, storage_options={"key": "value"}) diff --git a/tests/serialization/test_dag_serialization.py b/tests/serialization/test_dag_serialization.py index ced00fd65ab62..7071adc3a45c7 100644 --- a/tests/serialization/test_dag_serialization.py +++ b/tests/serialization/test_dag_serialization.py @@ -29,11 +29,12 @@ import pickle import re import sys +from collections.abc import Generator from datetime import datetime, timedelta, timezone as dt_timezone from glob import glob from pathlib import Path from textwrap import dedent -from typing import TYPE_CHECKING, Generator +from typing import TYPE_CHECKING from unittest import mock import attr diff --git a/tests/serialization/test_serialized_objects.py b/tests/serialization/test_serialized_objects.py index a7d775f82c3d2..7eb82d08f19cf 100644 --- a/tests/serialization/test_serialized_objects.py +++ b/tests/serialization/test_serialized_objects.py @@ -20,9 +20,9 @@ import inspect import json import warnings +from collections.abc import Iterator from datetime import datetime, timedelta from importlib import import_module -from typing import Iterator import pendulum import pytest diff --git a/tests/ti_deps/deps/test_trigger_rule_dep.py b/tests/ti_deps/deps/test_trigger_rule_dep.py index 9f3699d09c33d..16b7457f9dcb6 100644 --- a/tests/ti_deps/deps/test_trigger_rule_dep.py +++ b/tests/ti_deps/deps/test_trigger_rule_dep.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Iterator from datetime import datetime -from typing import TYPE_CHECKING, Iterator +from typing import TYPE_CHECKING from unittest import mock from unittest.mock import Mock diff --git a/tests/utils/test_cli_util.py b/tests/utils/test_cli_util.py index 097119fbb5691..67b3e8593f25c 100644 --- a/tests/utils/test_cli_util.py +++ b/tests/utils/test_cli_util.py @@ -131,9 +131,10 @@ def test_cli_create_user_supplied_password_is_masked( exec_date = timezone.utcnow() namespace = Namespace(dag_id="foo", task_id="bar", subcommand="test", logical_date=exec_date) - with mock.patch.object(sys, "argv", args), mock.patch( - "airflow.utils.session.create_session" - ) as mock_create_session: + with ( + mock.patch.object(sys, "argv", args), + mock.patch("airflow.utils.session.create_session") as mock_create_session, + ): metrics = cli._build_metrics(args[1], namespace) # Make it so the default_action_log doesn't actually commit the txn, by giving it a next txn # instead @@ -189,9 +190,10 @@ def test_cli_set_variable_supplied_sensitive_value_is_masked( exec_date = timezone.utcnow() namespace = Namespace(dag_id="foo", task_id="bar", subcommand="test", execution_date=exec_date) - with mock.patch.object(sys, "argv", args), mock.patch( - "airflow.utils.session.create_session" - ) as mock_create_session: + with ( + mock.patch.object(sys, "argv", args), + mock.patch("airflow.utils.session.create_session") as mock_create_session, + ): metrics = cli._build_metrics(args[1], namespace) # Make it so the default_action_log doesn't actually commit the txn, by giving it a next txn # instead diff --git a/tests/utils/test_db_cleanup.py b/tests/utils/test_db_cleanup.py index 5df2c37cddb32..7633812d18086 100644 --- a/tests/utils/test_db_cleanup.py +++ b/tests/utils/test_db_cleanup.py @@ -421,8 +421,9 @@ def test_confirm_drop_archives(self, mock_ask_yesno, tables): expected += f"\n {table}" mock_ask_yesno.return_value = True - with patch("sys.stdout", new=StringIO()) as fake_out, patch( - "builtins.input", side_effect=["drop archived tables"] + with ( + patch("sys.stdout", new=StringIO()) as fake_out, + patch("builtins.input", side_effect=["drop archived tables"]), ): _confirm_drop_archives(tables=tables) output = fake_out.getvalue().strip() @@ -431,8 +432,9 @@ def test_confirm_drop_archives(self, mock_ask_yesno, tables): def test_user_did_not_confirm(self): tables = ["table1", "table2"] - with pytest.raises(SystemExit) as cm, patch( - "builtins.input", side_effect=["not drop archived tables"] + with ( + pytest.raises(SystemExit) as cm, + patch("builtins.input", side_effect=["not drop archived tables"]), ): _confirm_drop_archives(tables=tables) assert str(cm.value) == "User did not confirm; exiting." diff --git a/tests/utils/test_entry_points.py b/tests/utils/test_entry_points.py index 22537245fc31d..d1a7f0fc5b635 100644 --- a/tests/utils/test_entry_points.py +++ b/tests/utils/test_entry_points.py @@ -17,7 +17,7 @@ # under the License. from __future__ import annotations -from typing import Iterable +from collections.abc import Iterable from unittest import mock from airflow.utils.entry_points import entry_points_with_dist, metadata diff --git a/tests/utils/test_usage_data_collection.py b/tests/utils/test_usage_data_collection.py index 143bce39eca4d..4cb9325c1f278 100644 --- a/tests/utils/test_usage_data_collection.py +++ b/tests/utils/test_usage_data_collection.py @@ -34,8 +34,9 @@ @pytest.mark.parametrize("is_enabled, is_prerelease", [(False, True), (True, True)]) @mock.patch("httpx.get") def test_scarf_analytics_disabled(mock_get, is_enabled, is_prerelease): - with mock.patch("airflow.settings.is_usage_data_collection_enabled", return_value=is_enabled), mock.patch( - "airflow.utils.usage_data_collection._version_is_prerelease", return_value=is_prerelease + with ( + mock.patch("airflow.settings.is_usage_data_collection_enabled", return_value=is_enabled), + mock.patch("airflow.utils.usage_data_collection._version_is_prerelease", return_value=is_prerelease), ): usage_data_collection() mock_get.assert_not_called() diff --git a/tests/www/test_app.py b/tests/www/test_app.py index cc9f24ca6a8e2..1752259ebd08a 100644 --- a/tests/www/test_app.py +++ b/tests/www/test_app.py @@ -263,8 +263,9 @@ def test_should_respect_caching_hash_method_invalid(self): class TestFlaskCli: @dont_initialize_flask_app_submodules(skip_all_except=["init_appbuilder"]) def test_flask_cli_should_display_routes(self, capsys): - with mock.patch.dict("os.environ", FLASK_APP="airflow.www.app:cached_app"), mock.patch.object( - sys, "argv", ["flask", "routes"] + with ( + mock.patch.dict("os.environ", FLASK_APP="airflow.www.app:cached_app"), + mock.patch.object(sys, "argv", ["flask", "routes"]), ): # Import from flask.__main__ with a combination of mocking With mocking sys.argv # will invoke ``flask routes`` command. diff --git a/tests/www/views/conftest.py b/tests/www/views/conftest.py index 3a82136b715fe..2ac6dea568a8f 100644 --- a/tests/www/views/conftest.py +++ b/tests/www/views/conftest.py @@ -17,8 +17,9 @@ # under the License. from __future__ import annotations +from collections.abc import Generator from contextlib import contextmanager -from typing import Any, Generator, NamedTuple +from typing import Any, NamedTuple import flask import jinja2 diff --git a/tests_common/_internals/capture_warnings.py b/tests_common/_internals/capture_warnings.py index aa694e7366a2d..d0cb2a0361581 100644 --- a/tests_common/_internals/capture_warnings.py +++ b/tests_common/_internals/capture_warnings.py @@ -24,10 +24,11 @@ import site import sys import warnings +from collections.abc import Generator from contextlib import contextmanager from dataclasses import asdict, dataclass from pathlib import Path -from typing import Callable, Generator +from typing import Callable import pytest from typing_extensions import Literal @@ -36,12 +37,12 @@ TESTS_DIR = Path(__file__).parents[1].resolve() -@functools.lru_cache(maxsize=None) +@functools.cache def _sites_locations() -> tuple[str, ...]: return tuple([*site.getsitepackages(), site.getusersitepackages()]) -@functools.lru_cache(maxsize=None) +@functools.cache def _resolve_warning_filepath(path: str, rootpath: str): if path.startswith(_sites_locations()): for site_loc in _sites_locations(): diff --git a/tests_common/pytest_plugin.py b/tests_common/pytest_plugin.py index 350073c120ebf..966a4a14e8bf2 100644 --- a/tests_common/pytest_plugin.py +++ b/tests_common/pytest_plugin.py @@ -23,10 +23,11 @@ import re import subprocess import sys +from collections.abc import Generator from contextlib import ExitStack, suppress from datetime import datetime, timedelta, timezone from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Generator, Protocol, TypeVar +from typing import TYPE_CHECKING, Any, Callable, Protocol, TypeVar import pytest import time_machine diff --git a/tests_common/test_utils/gcp_system_helpers.py b/tests_common/test_utils/gcp_system_helpers.py index 1b932033ef731..d0662d9e0275d 100644 --- a/tests_common/test_utils/gcp_system_helpers.py +++ b/tests_common/test_utils/gcp_system_helpers.py @@ -19,10 +19,10 @@ import os import tempfile +from collections.abc import Sequence from contextlib import contextmanager from pathlib import Path from tempfile import TemporaryDirectory -from typing import Sequence from unittest import mock import pytest @@ -84,10 +84,10 @@ def provide_gcp_context( key_file_path = resolve_full_gcp_key_path(key_file_path) # type: ignore if project_id is None: project_id = os.environ.get("GCP_PROJECT_ID") - with provide_gcp_conn_and_credentials( - key_file_path, scopes, project_id - ), tempfile.TemporaryDirectory() as gcloud_config_tmp, mock.patch.dict( - "os.environ", {CLOUD_SDK_CONFIG_DIR: gcloud_config_tmp} + with ( + provide_gcp_conn_and_credentials(key_file_path, scopes, project_id), + tempfile.TemporaryDirectory() as gcloud_config_tmp, + mock.patch.dict("os.environ", {CLOUD_SDK_CONFIG_DIR: gcloud_config_tmp}), ): executor = CommandExecutor() diff --git a/tests_common/test_utils/mock_operators.py b/tests_common/test_utils/mock_operators.py index 6a88f41c22ade..f48ff17ed93eb 100644 --- a/tests_common/test_utils/mock_operators.py +++ b/tests_common/test_utils/mock_operators.py @@ -16,8 +16,8 @@ # under the License. from __future__ import annotations -from collections.abc import Mapping -from typing import TYPE_CHECKING, Any, Sequence +from collections.abc import Mapping, Sequence +from typing import TYPE_CHECKING, Any import attr diff --git a/tests_common/test_utils/reset_warning_registry.py b/tests_common/test_utils/reset_warning_registry.py index 4c6ae8d26b1a2..08a80ab3b3e26 100644 --- a/tests_common/test_utils/reset_warning_registry.py +++ b/tests_common/test_utils/reset_warning_registry.py @@ -19,7 +19,7 @@ import re import sys -from typing import Match +from re import Match # We need to explicitly clear the warning registry context # https://docs.python.org/2/library/warnings.html