diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4644bf195abb5..abb3ffe463a36 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -512,6 +512,13 @@ repos: entry: ./scripts/ci/pre_commit/pre_commit_decorator_operator_implements_custom_name.py pass_filenames: true files: ^airflow/.*\.py$ + - id: check-core-deprecation-classes + language: pygrep + name: Verify using of dedicated Airflow deprecation classes in core + entry: category=DeprecationWarning|category=PendingDeprecationWarning + files: \.py$ + exclude: ^airflow/configuration.py|^airflow/providers|^scripts/in_container/verify_providers.py + pass_filenames: true - id: check-provide-create-sessions-imports language: pygrep name: Check provide_session and create_session imports diff --git a/STATIC_CODE_CHECKS.rst b/STATIC_CODE_CHECKS.rst index fb6b92be86ae0..cce6d1b9c6069 100644 --- a/STATIC_CODE_CHECKS.rst +++ b/STATIC_CODE_CHECKS.rst @@ -155,6 +155,8 @@ require Breeze Docker image to be build locally. +--------------------------------------------------------+------------------------------------------------------------------+---------+ | check-changelog-has-no-duplicates | Check changelogs for duplicate entries | | +--------------------------------------------------------+------------------------------------------------------------------+---------+ +| check-core-deprecation-classes | Verify using of dedicated Airflow deprecation classes in core | | ++--------------------------------------------------------+------------------------------------------------------------------+---------+ | check-daysago-import-from-utils | Make sure days_ago is imported from airflow.utils.dates | | +--------------------------------------------------------+------------------------------------------------------------------+---------+ | check-decorated-operator-implements-custom-name | Check @task decorator implements custom_operator_name | | diff --git a/airflow/cli/commands/dag_command.py b/airflow/cli/commands/dag_command.py index 515dcf2d809cf..559c0e75c3be2 100644 --- a/airflow/cli/commands/dag_command.py +++ b/airflow/cli/commands/dag_command.py @@ -33,7 +33,7 @@ from airflow.api.client import get_current_api_client from airflow.cli.simple_table import AirflowConsole from airflow.configuration import conf -from airflow.exceptions import AirflowException, BackfillUnfinished +from airflow.exceptions import AirflowException, BackfillUnfinished, RemovedInAirflow3Warning from airflow.executors.debug_executor import DebugExecutor from airflow.jobs.base_job import BaseJob from airflow.models import DagBag, DagModel, DagRun, TaskInstance @@ -59,7 +59,7 @@ def dag_backfill(args, dag=None): warnings.warn( '--ignore-first-depends-on-past is deprecated as the value is always set to True', - category=PendingDeprecationWarning, + category=RemovedInAirflow3Warning, ) if args.ignore_first_depends_on_past is False: diff --git a/airflow/exceptions.py b/airflow/exceptions.py index 3fdd19b7335ba..8754158847b62 100644 --- a/airflow/exceptions.py +++ b/airflow/exceptions.py @@ -338,3 +338,17 @@ class TaskDeferralError(AirflowException): class PodReconciliationError(AirflowException): """Raised when an error is encountered while trying to merge pod configs.""" + + +class RemovedInAirflow3Warning(DeprecationWarning): + """Issued for usage of deprecated features that will be removed in Airflow3.""" + + deprecated_since: Optional[str] = None + "Indicates the airflow version that started raising this deprecation warning" + + +class AirflowProviderDeprecationWarning(DeprecationWarning): + """Issued for usage of deprecated features of Airflow provider.""" + + deprecated_provider_since: Optional[str] = None + "Indicates the provider version that started raising this deprecation warning" diff --git a/airflow/executors/base_executor.py b/airflow/executors/base_executor.py index 2175199d3c344..0168106c2d4ac 100644 --- a/airflow/executors/base_executor.py +++ b/airflow/executors/base_executor.py @@ -23,6 +23,7 @@ from airflow.callbacks.base_callback_sink import BaseCallbackSink from airflow.callbacks.callback_requests import CallbackRequest from airflow.configuration import conf +from airflow.exceptions import RemovedInAirflow3Warning from airflow.models.taskinstance import TaskInstance, TaskInstanceKey from airflow.stats import Stats from airflow.utils.log.logging_mixin import LoggingMixin @@ -344,7 +345,7 @@ def validate_command(command: List[str]) -> None: """ The `validate_command` method is deprecated. Please use ``validate_airflow_tasks_run_command`` """, - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) BaseExecutor.validate_airflow_tasks_run_command(command) diff --git a/airflow/hooks/S3_hook.py b/airflow/hooks/S3_hook.py index b59311a1ba9e4..1a0bf5bfc9c6b 100644 --- a/airflow/hooks/S3_hook.py +++ b/airflow/hooks/S3_hook.py @@ -21,10 +21,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.hooks.s3 import S3Hook, provide_bucket_name # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.hooks.s3`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/base.py b/airflow/hooks/base.py index aa506cf62de28..9bd7854ab2a87 100644 --- a/airflow/hooks/base.py +++ b/airflow/hooks/base.py @@ -20,6 +20,7 @@ import warnings from typing import TYPE_CHECKING, Any, Dict, List +from airflow.exceptions import RemovedInAirflow3Warning from airflow.typing_compat import Protocol from airflow.utils.log.logging_mixin import LoggingMixin @@ -49,7 +50,7 @@ def get_connections(cls, conn_id: str) -> List["Connection"]: warnings.warn( "`BaseHook.get_connections` method will be deprecated in the future." "Please use `BaseHook.get_connection` instead.", - PendingDeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return [cls.get_connection(conn_id)] diff --git a/airflow/hooks/base_hook.py b/airflow/hooks/base_hook.py index cf1594d18d284..161278eabbd56 100644 --- a/airflow/hooks/base_hook.py +++ b/airflow/hooks/base_hook.py @@ -19,6 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.hooks.base import BaseHook # noqa -warnings.warn("This module is deprecated. Please use `airflow.hooks.base`.", DeprecationWarning, stacklevel=2) +warnings.warn( + "This module is deprecated. Please use `airflow.hooks.base`.", + RemovedInAirflow3Warning, + stacklevel=2, +) diff --git a/airflow/hooks/dbapi.py b/airflow/hooks/dbapi.py index 1dc2908eb9062..a5e38bad6f998 100644 --- a/airflow/hooks/dbapi.py +++ b/airflow/hooks/dbapi.py @@ -17,11 +17,12 @@ # under the License. import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.common.sql.hooks.sql import ConnectorProtocol # noqa from airflow.providers.common.sql.hooks.sql import DbApiHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.common.sql.hooks.sql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/dbapi_hook.py b/airflow/hooks/dbapi_hook.py index 6445db78814d9..0ea5fdcfa4439 100644 --- a/airflow/hooks/dbapi_hook.py +++ b/airflow/hooks/dbapi_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.common.sql.hooks.sql import DbApiHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.common.sql.hooks.sql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/docker_hook.py b/airflow/hooks/docker_hook.py index aaedd7e637d93..b2f56430de945 100644 --- a/airflow/hooks/docker_hook.py +++ b/airflow/hooks/docker_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.docker.hooks.docker import DockerHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.docker.hooks.docker`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/druid_hook.py b/airflow/hooks/druid_hook.py index 0a43debbabddc..9ce11f8078a85 100644 --- a/airflow/hooks/druid_hook.py +++ b/airflow/hooks/druid_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.druid.hooks.druid import DruidDbApiHook, DruidHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.druid.hooks.druid`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/hdfs_hook.py b/airflow/hooks/hdfs_hook.py index fd13e7337e262..7d7b115959ac7 100644 --- a/airflow/hooks/hdfs_hook.py +++ b/airflow/hooks/hdfs_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hdfs.hooks.hdfs import HDFSHook, HDFSHookException # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hdfs.hooks.hdfs`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/hive_hooks.py b/airflow/hooks/hive_hooks.py index 74d7863c8d947..bc8ebed405261 100644 --- a/airflow/hooks/hive_hooks.py +++ b/airflow/hooks/hive_hooks.py @@ -19,6 +19,7 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.hooks.hive import ( # noqa HIVE_QUEUE_PRIORITIES, HiveCliHook, @@ -28,6 +29,6 @@ warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.hooks.hive`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/http_hook.py b/airflow/hooks/http_hook.py index 5b8c1fdf9b776..7eceec52915e9 100644 --- a/airflow/hooks/http_hook.py +++ b/airflow/hooks/http_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.http.hooks.http import HttpHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.http.hooks.http`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/jdbc_hook.py b/airflow/hooks/jdbc_hook.py index a032ab0e2598b..6e73645dfd311 100644 --- a/airflow/hooks/jdbc_hook.py +++ b/airflow/hooks/jdbc_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.jdbc.hooks.jdbc import JdbcHook, jaydebeapi # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.jdbc.hooks.jdbc`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/mssql_hook.py b/airflow/hooks/mssql_hook.py index 64943eeea7905..f9922c64806c7 100644 --- a/airflow/hooks/mssql_hook.py +++ b/airflow/hooks/mssql_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.microsoft.mssql.hooks.mssql import MsSqlHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.microsoft.mssql.hooks.mssql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/mysql_hook.py b/airflow/hooks/mysql_hook.py index 437313680b09c..6520ef62e05e6 100644 --- a/airflow/hooks/mysql_hook.py +++ b/airflow/hooks/mysql_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.mysql.hooks.mysql import MySqlHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.mysql.hooks.mysql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/oracle_hook.py b/airflow/hooks/oracle_hook.py index 0dfe33a78ae2a..95fbecb61c313 100644 --- a/airflow/hooks/oracle_hook.py +++ b/airflow/hooks/oracle_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.oracle.hooks.oracle import OracleHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.oracle.hooks.oracle`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/pig_hook.py b/airflow/hooks/pig_hook.py index 3ead3df6c826e..ebcb068b6e319 100644 --- a/airflow/hooks/pig_hook.py +++ b/airflow/hooks/pig_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.pig.hooks.pig import PigCliHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.pig.hooks.pig`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/postgres_hook.py b/airflow/hooks/postgres_hook.py index 16f79dc329593..ce1f690aee108 100644 --- a/airflow/hooks/postgres_hook.py +++ b/airflow/hooks/postgres_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.postgres.hooks.postgres import PostgresHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.postgres.hooks.postgres`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/presto_hook.py b/airflow/hooks/presto_hook.py index 0c33e1423d35d..71e3964dec264 100644 --- a/airflow/hooks/presto_hook.py +++ b/airflow/hooks/presto_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.presto.hooks.presto import PrestoHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.presto.hooks.presto`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/samba_hook.py b/airflow/hooks/samba_hook.py index b4c7cf83b05a6..c0465c4bd1230 100644 --- a/airflow/hooks/samba_hook.py +++ b/airflow/hooks/samba_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.samba.hooks.samba import SambaHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.samba.hooks.samba`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/slack_hook.py b/airflow/hooks/slack_hook.py index 43636b2c6eeef..da5ccbbd8ac04 100644 --- a/airflow/hooks/slack_hook.py +++ b/airflow/hooks/slack_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.slack.hooks.slack import SlackHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.slack.hooks.slack`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/sqlite_hook.py b/airflow/hooks/sqlite_hook.py index 773900400ccbc..c9d0e03dd70d8 100644 --- a/airflow/hooks/sqlite_hook.py +++ b/airflow/hooks/sqlite_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.sqlite.hooks.sqlite import SqliteHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.sqlite.hooks.sqlite`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/webhdfs_hook.py b/airflow/hooks/webhdfs_hook.py index 1c4353835cf00..a16f4dee00649 100644 --- a/airflow/hooks/webhdfs_hook.py +++ b/airflow/hooks/webhdfs_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hdfs.hooks.webhdfs import WebHDFSHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hdfs.hooks.webhdfs`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/hooks/zendesk_hook.py b/airflow/hooks/zendesk_hook.py index 38323c5880d74..6aaae2b3884da 100644 --- a/airflow/hooks/zendesk_hook.py +++ b/airflow/hooks/zendesk_hook.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.zendesk.hooks.zendesk import ZendeskHook # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.zendesk.hooks.zendesk`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/jobs/scheduler_job.py b/airflow/jobs/scheduler_job.py index e2a6cd54c9890..6a63aaa47425a 100644 --- a/airflow/jobs/scheduler_job.py +++ b/airflow/jobs/scheduler_job.py @@ -39,6 +39,7 @@ from airflow.callbacks.pipe_callback_sink import PipeCallbackSink from airflow.configuration import conf from airflow.dag_processing.manager import DagFileProcessorAgent +from airflow.exceptions import RemovedInAirflow3Warning from airflow.executors.executor_loader import UNPICKLEABLE_EXECUTORS from airflow.jobs.base_job import BaseJob from airflow.jobs.local_task_job import LocalTaskJob @@ -132,7 +133,7 @@ def __init__( warnings.warn( "The 'processor_poll_interval' parameter is deprecated. " "Please use 'scheduler_idle_sleep_time'.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) scheduler_idle_sleep_time = processor_poll_interval diff --git a/airflow/kubernetes/pod.py b/airflow/kubernetes/pod.py index a5b6cde0e335b..b3540a494cf84 100644 --- a/airflow/kubernetes/pod.py +++ b/airflow/kubernetes/pod.py @@ -23,12 +23,14 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning + with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) from airflow.providers.cncf.kubernetes.backcompat.pod import Port, Resources # noqa: autoflake warnings.warn( "This module is deprecated. Please use `kubernetes.client.models` for `V1ResourceRequirements` and `Port`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/kubernetes/pod_generator.py b/airflow/kubernetes/pod_generator.py index 705c108b79da6..17f5e82503658 100644 --- a/airflow/kubernetes/pod_generator.py +++ b/airflow/kubernetes/pod_generator.py @@ -34,7 +34,7 @@ from kubernetes.client import models as k8s from kubernetes.client.api_client import ApiClient -from airflow.exceptions import AirflowConfigException, PodReconciliationError +from airflow.exceptions import AirflowConfigException, PodReconciliationError, RemovedInAirflow3Warning from airflow.kubernetes.pod_generator_deprecated import PodDefaults, PodGenerator as PodGeneratorDeprecated from airflow.utils import yaml from airflow.version import version as airflow_version @@ -172,7 +172,7 @@ def from_obj(obj) -> Optional[Union[dict, k8s.V1Pod]]: 'Using a dictionary for the executor_config is deprecated and will soon be removed.' 'please use a `kubernetes.client.models.V1Pod` class with a "pod_override" key' ' instead. ', - category=DeprecationWarning, + category=RemovedInAirflow3Warning, ) return PodGenerator.from_legacy_obj(obj) else: diff --git a/airflow/kubernetes/pod_launcher_deprecated.py b/airflow/kubernetes/pod_launcher_deprecated.py index 97845dad51d5a..acff26b7872d8 100644 --- a/airflow/kubernetes/pod_launcher_deprecated.py +++ b/airflow/kubernetes/pod_launcher_deprecated.py @@ -30,7 +30,7 @@ from kubernetes.stream import stream as kubernetes_stream from requests.exceptions import HTTPError -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning from airflow.kubernetes.kube_client import get_kube_client from airflow.kubernetes.pod_generator import PodDefaults from airflow.settings import pod_mutation_hook @@ -46,7 +46,7 @@ https://pypi.org/project/apache-airflow-providers-cncf-kubernetes/ """, - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/kubernetes/pod_runtime_info_env.py b/airflow/kubernetes/pod_runtime_info_env.py index a51f3b96fc39a..1c81d4eb1341d 100644 --- a/airflow/kubernetes/pod_runtime_info_env.py +++ b/airflow/kubernetes/pod_runtime_info_env.py @@ -18,12 +18,14 @@ """This module is deprecated. Please use :mod:`kubernetes.client.models.V1EnvVar`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning + with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) from airflow.providers.cncf.kubernetes.backcompat.pod_runtime_info_env import PodRuntimeInfoEnv # noqa warnings.warn( "This module is deprecated. Please use `kubernetes.client.models.V1EnvVar`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/kubernetes/volume.py b/airflow/kubernetes/volume.py index 81b4fda3a15da..c48e0a72ce137 100644 --- a/airflow/kubernetes/volume.py +++ b/airflow/kubernetes/volume.py @@ -18,12 +18,14 @@ """This module is deprecated. Please use :mod:`kubernetes.client.models.V1Volume`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning + with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) from airflow.providers.cncf.kubernetes.backcompat.volume import Volume # noqa: autoflake warnings.warn( "This module is deprecated. Please use `kubernetes.client.models.V1Volume`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/kubernetes/volume_mount.py b/airflow/kubernetes/volume_mount.py index f558425881752..0b9543d1e07cd 100644 --- a/airflow/kubernetes/volume_mount.py +++ b/airflow/kubernetes/volume_mount.py @@ -18,12 +18,14 @@ """This module is deprecated. Please use :mod:`kubernetes.client.models.V1VolumeMount`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning + with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) from airflow.providers.cncf.kubernetes.backcompat.volume_mount import VolumeMount # noqa: autoflake warnings.warn( "This module is deprecated. Please use `kubernetes.client.models.V1VolumeMount`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py index b8a57d8ff3a59..77a92b4924322 100644 --- a/airflow/models/baseoperator.py +++ b/airflow/models/baseoperator.py @@ -56,7 +56,7 @@ from sqlalchemy.orm.exc import NoResultFound from airflow.configuration import conf -from airflow.exceptions import AirflowException, TaskDeferred +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning, TaskDeferred from airflow.lineage import apply_lineage, prepare_lineage from airflow.models.abstractoperator import ( DEFAULT_IGNORE_FIRST_DEPENDS_ON_PAST, @@ -762,7 +762,7 @@ def __init__( f'Invalid arguments were passed to {self.__class__.__name__} (task_id: {task_id}). ' 'Support for passing such arguments will be dropped in future. ' f'Invalid arguments were:\n**kwargs: {kwargs}', - category=PendingDeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=3, ) validate_key(task_id) @@ -814,7 +814,7 @@ def __init__( if trigger_rule == "dummy": warnings.warn( "dummy Trigger Rule is deprecated. Please use `TriggerRule.ALWAYS`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) trigger_rule = TriggerRule.ALWAYS @@ -823,7 +823,7 @@ def __init__( warnings.warn( "none_failed_or_skipped Trigger Rule is deprecated. " "Please use `none_failed_min_one_success`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) trigger_rule = TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS @@ -869,7 +869,7 @@ def __init__( # TODO: Remove in Airflow 3.0 warnings.warn( "The 'task_concurrency' parameter is deprecated. Please use 'max_active_tis_per_dag'.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) max_active_tis_per_dag = task_concurrency diff --git a/airflow/models/connection.py b/airflow/models/connection.py index 20059907c6865..72624ba0704ea 100644 --- a/airflow/models/connection.py +++ b/airflow/models/connection.py @@ -28,7 +28,7 @@ from sqlalchemy.orm import reconstructor, synonym from airflow.configuration import ensure_secrets_loaded -from airflow.exceptions import AirflowException, AirflowNotFoundException +from airflow.exceptions import AirflowException, AirflowNotFoundException, RemovedInAirflow3Warning from airflow.models.base import ID_LEN, Base from airflow.models.crypto import get_fernet from airflow.providers_manager import ProvidersManager @@ -41,7 +41,7 @@ def parse_netloc_to_hostname(*args, **kwargs): """This method is deprecated.""" - warnings.warn("This method is deprecated.", DeprecationWarning) + warnings.warn("This method is deprecated.", RemovedInAirflow3Warning) return _parse_netloc_to_hostname(*args, **kwargs) @@ -155,14 +155,14 @@ def _validate_extra(extra, conn_id) -> None: "Encountered JSON value in `extra` which does not parse as a dictionary in " f"connection {conn_id!r}. From Airflow 3.0, the `extra` field must contain a JSON " "representation of a Python dict.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) except json.JSONDecodeError: warnings.warn( f"Encountered non-JSON in `extra` field for connection {conn_id!r}. Support for " "non-JSON `extra` will be removed in Airflow 3.0", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return None @@ -175,7 +175,8 @@ def on_db_load(self): def parse_from_uri(self, **uri): """This method is deprecated. Please use uri parameter in constructor.""" warnings.warn( - "This method is deprecated. Please use uri parameter in constructor.", DeprecationWarning + "This method is deprecated. Please use uri parameter in constructor.", + RemovedInAirflow3Warning, ) self._parse_from_uri(**uri) @@ -349,7 +350,7 @@ def log_info(self): warnings.warn( "This method is deprecated. You can read each field individually or " "use the default representation (__repr__).", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return ( @@ -366,7 +367,7 @@ def debug_info(self): warnings.warn( "This method is deprecated. You can read each field individually or " "use the default representation (__repr__).", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return ( diff --git a/airflow/models/dag.py b/airflow/models/dag.py index 384ed840f1da4..49f6688141fb7 100644 --- a/airflow/models/dag.py +++ b/airflow/models/dag.py @@ -66,7 +66,13 @@ from airflow import settings, utils from airflow.compat.functools import cached_property from airflow.configuration import conf -from airflow.exceptions import AirflowDagInconsistent, AirflowException, DuplicateTaskIdFound, TaskNotFound +from airflow.exceptions import ( + AirflowDagInconsistent, + AirflowException, + DuplicateTaskIdFound, + RemovedInAirflow3Warning, + TaskNotFound, +) from airflow.models.abstractoperator import AbstractOperator from airflow.models.base import Base, StringID from airflow.models.dagbag import DagBag @@ -409,7 +415,7 @@ def __init__( if full_filepath: warnings.warn( "Passing full_filepath to DAG() is deprecated and has no effect", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -420,7 +426,7 @@ def __init__( # TODO: Remove in Airflow 3.0 warnings.warn( "The 'concurrency' parameter is deprecated. Please use 'max_active_tasks'.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) max_active_tasks = concurrency @@ -473,14 +479,14 @@ def __init__( warnings.warn( "Param `schedule_interval` is deprecated and will be removed in a future release. " "Please use `schedule` instead. ", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) if timetable is not None: warnings.warn( "Param `timetable` is deprecated and will be removed in a future release. " "Please use `schedule` instead. ", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -525,7 +531,7 @@ def __init__( elif default_view == 'tree': warnings.warn( "`default_view` of 'tree' has been renamed to 'grid' -- please update your DAG", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) self._default_view = 'grid' @@ -697,7 +703,7 @@ def _upgrade_outdated_dag_access_control(access_control=None): warnings.warn( "The 'can_dag_read' and 'can_dag_edit' permissions are deprecated. " "Please use 'can_read' and 'can_edit', respectively.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) @@ -711,14 +717,14 @@ def date_range( ) -> List[datetime]: message = "`DAG.date_range()` is deprecated." if num is not None: - warnings.warn(message, category=DeprecationWarning, stacklevel=2) + warnings.warn(message, category=RemovedInAirflow3Warning, stacklevel=2) with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) return utils_date_range( start_date=start_date, num=num, delta=self.normalized_schedule_interval ) message += " Please use `DAG.iter_dagrun_infos_between(..., align=False)` instead." - warnings.warn(message, category=DeprecationWarning, stacklevel=2) + warnings.warn(message, category=RemovedInAirflow3Warning, stacklevel=2) if end_date is None: coerced_end_date = timezone.utcnow() else: @@ -729,7 +735,7 @@ def date_range( def is_fixed_time_schedule(self): warnings.warn( "`DAG.is_fixed_time_schedule()` is deprecated.", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) try: @@ -746,7 +752,7 @@ def following_schedule(self, dttm): """ warnings.warn( "`DAG.following_schedule()` is deprecated. Use `DAG.next_dagrun_info(restricted=False)` instead.", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) data_interval = self.infer_automated_data_interval(timezone.coerce_datetime(dttm)) @@ -760,7 +766,7 @@ def previous_schedule(self, dttm): warnings.warn( "`DAG.previous_schedule()` is deprecated.", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) if not isinstance(self.timetable, _DataIntervalTimetable): @@ -867,7 +873,7 @@ def next_dagrun_info( if isinstance(last_automated_dagrun, datetime): warnings.warn( "Passing a datetime to DAG.next_dagrun_info is deprecated. Use a DataInterval instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) data_interval = self.infer_automated_data_interval( @@ -896,7 +902,7 @@ def next_dagrun_info( def next_dagrun_after_date(self, date_last_automated_dagrun: Optional[pendulum.DateTime]): warnings.warn( "`DAG.next_dagrun_after_date()` is deprecated. Please use `DAG.next_dagrun_info()` instead.", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) if date_last_automated_dagrun is None: @@ -1019,7 +1025,7 @@ def get_run_dates(self, start_date, end_date=None): """ warnings.warn( "`DAG.get_run_dates()` is deprecated. Please use `DAG.iter_dagrun_infos_between()` instead.", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) earliest = timezone.coerce_datetime(start_date) @@ -1032,16 +1038,16 @@ def get_run_dates(self, start_date, end_date=None): def normalize_schedule(self, dttm): warnings.warn( "`DAG.normalize_schedule()` is deprecated.", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) following = self.following_schedule(dttm) if not following: # in case of @once return dttm with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) previous_of_following = self.previous_schedule(following) if previous_of_following != dttm: return following @@ -1079,7 +1085,7 @@ def full_filepath(self) -> str: """:meta private:""" warnings.warn( "DAG.full_filepath is deprecated in favour of fileloc", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.fileloc @@ -1088,7 +1094,7 @@ def full_filepath(self) -> str: def full_filepath(self, value) -> None: warnings.warn( "DAG.full_filepath is deprecated in favour of fileloc", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) self.fileloc = value @@ -1098,7 +1104,7 @@ def concurrency(self) -> int: # TODO: Remove in Airflow 3.0 warnings.warn( "The 'DAG.concurrency' attribute is deprecated. Please use 'DAG.max_active_tasks'.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self._max_active_tasks @@ -1169,7 +1175,9 @@ def task_group(self) -> "TaskGroup": def filepath(self) -> str: """:meta private:""" warnings.warn( - "filepath is deprecated, use relative_fileloc instead", DeprecationWarning, stacklevel=2 + "filepath is deprecated, use relative_fileloc instead", + RemovedInAirflow3Warning, + stacklevel=2, ) return str(self.relative_fileloc) @@ -1220,7 +1228,7 @@ def concurrency_reached(self): """This attribute is deprecated. Please use `airflow.models.DAG.get_concurrency_reached` method.""" warnings.warn( "This attribute is deprecated. Please use `airflow.models.DAG.get_concurrency_reached` method.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.get_concurrency_reached() @@ -1240,7 +1248,7 @@ def is_paused(self): """This attribute is deprecated. Please use `airflow.models.DAG.get_is_paused` method.""" warnings.warn( "This attribute is deprecated. Please use `airflow.models.DAG.get_is_paused` method.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.get_is_paused() @@ -1249,7 +1257,7 @@ def is_paused(self): def normalized_schedule_interval(self) -> ScheduleInterval: warnings.warn( "DAG.normalized_schedule_interval() is deprecated.", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) if isinstance(self.schedule_interval, str) and self.schedule_interval in cron_presets: @@ -1384,7 +1392,7 @@ def latest_execution_date(self): """This attribute is deprecated. Please use `airflow.models.DAG.get_latest_execution_date`.""" warnings.warn( "This attribute is deprecated. Please use `airflow.models.DAG.get_latest_execution_date`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.get_latest_execution_date() @@ -1898,7 +1906,7 @@ def set_dag_runs_state( ) -> None: warnings.warn( "This method is deprecated and will be removed in a future version.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) dag_ids = dag_ids or [self.dag_id] @@ -1953,7 +1961,7 @@ def clear( if get_tis: warnings.warn( "Passing `get_tis` to dag.clear() is deprecated. Use `dry_run` parameter instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) dry_run = True @@ -1961,13 +1969,13 @@ def clear( if recursion_depth: warnings.warn( "Passing `recursion_depth` to dag.clear() is deprecated.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) if max_recursion_depth: warnings.warn( "Passing `max_recursion_depth` to dag.clear() is deprecated.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -2101,7 +2109,7 @@ def sub_dag(self, *args, **kwargs): """This method is deprecated in favor of partial_subset""" warnings.warn( "This method is deprecated and will be removed in a future version. Please use partial_subset", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.partial_subset(*args, **kwargs) @@ -2461,7 +2469,7 @@ def create_dagrun( if data_interval is None and logical_date is not None: warnings.warn( "Calling `DAG.create_dagrun()` without an explicit data interval is deprecated", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) if run_type == DagRunType.MANUAL: @@ -2489,7 +2497,7 @@ def create_dagrun( warnings.warn( "Using forward slash ('/') in a DAG run ID is deprecated. Note that this character " "also makes the run impossible to retrieve via Airflow's REST API.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) @@ -2528,7 +2536,7 @@ def bulk_sync_to_db(cls, dags: Collection["DAG"], session=NEW_SESSION): """This method is deprecated in favor of bulk_write_to_db""" warnings.warn( "This method is deprecated and will be removed in a future version. Please use bulk_write_to_db", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return cls.bulk_write_to_db(dags, session) @@ -3015,7 +3023,7 @@ def __init__(self, concurrency=None, **kwargs): if concurrency: warnings.warn( "The 'DagModel.concurrency' parameter is deprecated. Please use 'max_active_tasks'.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) self.max_active_tasks = concurrency @@ -3229,7 +3237,7 @@ def calculate_dagrun_date_fields( warnings.warn( "Passing a datetime to `DagModel.calculate_dagrun_date_fields` is deprecated. " "Provide a data interval instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) most_recent_data_interval = dag.infer_automated_data_interval(most_recent_dag_run) diff --git a/airflow/models/dagbag.py b/airflow/models/dagbag.py index 3b66d6be5fd13..3183f8a8f1dae 100644 --- a/airflow/models/dagbag.py +++ b/airflow/models/dagbag.py @@ -42,6 +42,7 @@ AirflowDagInconsistent, AirflowTimetableInvalid, ParamValidationError, + RemovedInAirflow3Warning, ) from airflow.stats import Stats from airflow.utils import timezone @@ -105,7 +106,7 @@ def __init__( warnings.warn( "The store_serialized_dags parameter has been deprecated. " "You should pass the read_dags_from_db parameter.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) read_dags_from_db = store_serialized_dags @@ -143,7 +144,7 @@ def store_serialized_dags(self) -> bool: """Whether or not to read dags from DB""" warnings.warn( "The store_serialized_dags property has been deprecated. Use read_dags_from_db instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.read_dags_from_db diff --git a/airflow/models/dagparam.py b/airflow/models/dagparam.py index 83a2f2c05532b..51d845ddd6415 100644 --- a/airflow/models/dagparam.py +++ b/airflow/models/dagparam.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.models.param import DagParam # noqa warnings.warn( "This module is deprecated. Please use `airflow.models.param`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/models/dagrun.py b/airflow/models/dagrun.py index 772bd76d939c6..4dd0493551ef4 100644 --- a/airflow/models/dagrun.py +++ b/airflow/models/dagrun.py @@ -60,7 +60,7 @@ from airflow import settings from airflow.callbacks.callback_requests import DagCallbackRequest from airflow.configuration import conf as airflow_conf -from airflow.exceptions import AirflowException, TaskNotFound +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning, TaskNotFound from airflow.models.base import Base, StringID from airflow.models.mappedoperator import MappedOperator from airflow.models.taskinstance import TaskInstance as TI @@ -1136,7 +1136,7 @@ def get_run(session: Session, dag_id: str, execution_date: datetime) -> Optional """ warnings.warn( "This method is deprecated. Please use SQLAlchemy directly", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return ( @@ -1249,7 +1249,7 @@ def get_log_template(self, *, session: Session = NEW_SESSION) -> LogTemplate: def get_log_filename_template(self, *, session: Session = NEW_SESSION) -> str: warnings.warn( "This method is deprecated. Please use get_log_template instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.get_log_template(session=session).filename diff --git a/airflow/models/param.py b/airflow/models/param.py index 1179dd9fd6d0c..32cae22fee15c 100644 --- a/airflow/models/param.py +++ b/airflow/models/param.py @@ -20,7 +20,7 @@ import warnings from typing import TYPE_CHECKING, Any, Dict, ItemsView, MutableMapping, Optional, ValuesView -from airflow.exceptions import AirflowException, ParamValidationError +from airflow.exceptions import AirflowException, ParamValidationError, RemovedInAirflow3Warning from airflow.utils.context import Context from airflow.utils.types import NOTSET, ArgNotSet @@ -59,7 +59,7 @@ def _warn_if_not_json(value): warnings.warn( "The use of non-json-serializable params is deprecated and will be removed in " "a future release", - DeprecationWarning, + RemovedInAirflow3Warning, ) def resolve(self, value: Any = NOTSET, suppress_exception: bool = False) -> Any: diff --git a/airflow/models/skipmixin.py b/airflow/models/skipmixin.py index 20e42b524a56a..46a5b5a57c5be 100644 --- a/airflow/models/skipmixin.py +++ b/airflow/models/skipmixin.py @@ -19,6 +19,7 @@ import warnings from typing import TYPE_CHECKING, Iterable, Optional, Sequence, Union +from airflow.exceptions import RemovedInAirflow3Warning from airflow.models.taskinstance import TaskInstance from airflow.utils import timezone from airflow.utils.log.logging_mixin import LoggingMixin @@ -104,7 +105,7 @@ def skip( warnings.warn( "Passing an execution_date to `skip()` is deprecated in favour of passing a dag_run", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py index c836c93b3a1af..606a173f14403 100644 --- a/airflow/models/taskinstance.py +++ b/airflow/models/taskinstance.py @@ -88,6 +88,7 @@ AirflowSkipException, AirflowTaskTimeout, DagRunNotFound, + RemovedInAirflow3Warning, TaskDeferralError, TaskDeferred, UnmappableXComLengthPushed, @@ -257,7 +258,7 @@ def clear_task_instances( warnings.warn( "`activate_dag_runs` parameter to clear_task_instances function is deprecated. " "Please use `dag_run_state`", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) if not activate_dag_runs: @@ -541,7 +542,7 @@ def __init__( warnings.warn( "Passing an execution_date to `TaskInstance()` is deprecated in favour of passing a run_id", - DeprecationWarning, + RemovedInAirflow3Warning, # Stack level is 4 because SQLA adds some wrappers around the constructor stacklevel=4, ) @@ -1057,7 +1058,7 @@ def previous_ti(self) -> Optional['TaskInstance']: This attribute is deprecated. Please use `airflow.models.taskinstance.TaskInstance.get_previous_ti` method. """, - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.get_previous_ti() @@ -1073,7 +1074,7 @@ def previous_ti_success(self) -> Optional['TaskInstance']: This attribute is deprecated. Please use `airflow.models.taskinstance.TaskInstance.get_previous_ti` method. """, - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.get_previous_ti(state=DagRunState.SUCCESS) @@ -1120,7 +1121,7 @@ def previous_start_date_success(self) -> Optional[pendulum.DateTime]: This attribute is deprecated. Please use `airflow.models.taskinstance.TaskInstance.get_previous_start_date` method. """, - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.get_previous_start_date(state=DagRunState.SUCCESS) @@ -2057,7 +2058,7 @@ def get_prev_execution_date(): if dag_run.external_trigger: return logical_date with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) return dag.previous_schedule(logical_date) @cache @@ -2364,7 +2365,7 @@ def xcom_push( ) elif execution_date is not None: message = "Passing 'execution_date' to 'TaskInstance.xcom_push()' is deprecated." - warnings.warn(message, DeprecationWarning, stacklevel=3) + warnings.warn(message, RemovedInAirflow3Warning, stacklevel=3) XCom.set( key=key, diff --git a/airflow/models/taskmixin.py b/airflow/models/taskmixin.py index 85d6505972400..9566ffb686085 100644 --- a/airflow/models/taskmixin.py +++ b/airflow/models/taskmixin.py @@ -21,7 +21,7 @@ import pendulum -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning from airflow.serialization.enums import DagAttributeTypes if TYPE_CHECKING: @@ -96,7 +96,7 @@ class TaskMixin(DependencyMixin): def __init_subclass__(cls) -> None: warnings.warn( f"TaskMixin has been renamed to DependencyMixin, please update {cls.__name__}", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) return super().__init_subclass__() diff --git a/airflow/models/xcom.py b/airflow/models/xcom.py index 9970e3c1b81a5..847e8454758b1 100644 --- a/airflow/models/xcom.py +++ b/airflow/models/xcom.py @@ -41,6 +41,7 @@ from sqlalchemy.orm.exc import NoResultFound from airflow.configuration import conf +from airflow.exceptions import RemovedInAirflow3Warning from airflow.models.base import COLLATION_ARGS, ID_LEN, Base from airflow.utils import timezone from airflow.utils.helpers import exactly_one, is_container @@ -187,7 +188,7 @@ def set( if run_id is None: message = "Passing 'execution_date' to 'XCom.set()' is deprecated. Use 'run_id' instead." - warnings.warn(message, DeprecationWarning, stacklevel=3) + warnings.warn(message, RemovedInAirflow3Warning, stacklevel=3) try: dag_run_id, run_id = ( session.query(DagRun.id, DagRun.run_id) @@ -350,10 +351,10 @@ def get_one( ) elif execution_date is not None: message = "Passing 'execution_date' to 'XCom.get_one()' is deprecated. Use 'run_id' instead." - warnings.warn(message, PendingDeprecationWarning, stacklevel=3) + warnings.warn(message, RemovedInAirflow3Warning, stacklevel=3) with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) query = cls.get_many( execution_date=execution_date, key=key, @@ -450,7 +451,7 @@ def get_many( ) if execution_date is not None: message = "Passing 'execution_date' to 'XCom.get_many()' is deprecated. Use 'run_id' instead." - warnings.warn(message, PendingDeprecationWarning, stacklevel=3) + warnings.warn(message, RemovedInAirflow3Warning, stacklevel=3) query = session.query(cls).join(cls.dag_run) @@ -566,7 +567,7 @@ def clear( if execution_date is not None: message = "Passing 'execution_date' to 'XCom.clear()' is deprecated. Use 'run_id' instead." - warnings.warn(message, DeprecationWarning, stacklevel=3) + warnings.warn(message, RemovedInAirflow3Warning, stacklevel=3) run_id = ( session.query(DagRun.run_id) .filter(DagRun.dag_id == dag_id, DagRun.execution_date == execution_date) @@ -648,7 +649,7 @@ def _shim(**kwargs): f"Method `serialize_value` in XCom backend {XCom.__name__} is using outdated signature and" f"must be updated to accept all params in `BaseXCom.set` except `session`. Support will be " f"removed in a future release.", - DeprecationWarning, + RemovedInAirflow3Warning, ) return old_serializer(**kwargs) diff --git a/airflow/operators/bash_operator.py b/airflow/operators/bash_operator.py index 3b7764dfbd316..c9435e465aacf 100644 --- a/airflow/operators/bash_operator.py +++ b/airflow/operators/bash_operator.py @@ -19,8 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.bash import BashOperator # noqa warnings.warn( - "This module is deprecated. Please use `airflow.operators.bash`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.operators.bash`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/operators/branch_operator.py b/airflow/operators/branch_operator.py index b4c71d5bc1f88..03131a8b14b1a 100644 --- a/airflow/operators/branch_operator.py +++ b/airflow/operators/branch_operator.py @@ -19,8 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.branch import BaseBranchOperator # noqa warnings.warn( - "This module is deprecated. Please use `airflow.operators.branch`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.operators.branch`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/operators/check_operator.py b/airflow/operators/check_operator.py index 0575211a01cb3..14cdce3ce8d71 100644 --- a/airflow/operators/check_operator.py +++ b/airflow/operators/check_operator.py @@ -20,6 +20,7 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.common.sql.operators.sql import ( SQLCheckOperator, SQLIntervalCheckOperator, @@ -29,7 +30,7 @@ warnings.warn( "This module is deprecated. Please use `airflow.providers.common.sql.operators.sql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -44,7 +45,7 @@ def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.providers.common.sql.operators.sql.SQLCheckOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(**kwargs) @@ -60,7 +61,7 @@ def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.providers.common.sql.operators.sql.SQLIntervalCheckOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(**kwargs) @@ -76,7 +77,7 @@ def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.providers.common.sql.operators.sql.SQLThresholdCheckOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(**kwargs) @@ -92,7 +93,7 @@ def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.providers.common.sql.operators.sql.SQLValueCheckOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(**kwargs) diff --git a/airflow/operators/dagrun_operator.py b/airflow/operators/dagrun_operator.py index bdcc6671516af..44b1fbbfb0b0b 100644 --- a/airflow/operators/dagrun_operator.py +++ b/airflow/operators/dagrun_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.trigger_dagrun import TriggerDagRunLink, TriggerDagRunOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.operators.trigger_dagrun`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/datetime.py b/airflow/operators/datetime.py index c5a423d563868..81e68e651551a 100644 --- a/airflow/operators/datetime.py +++ b/airflow/operators/datetime.py @@ -19,7 +19,7 @@ import warnings from typing import Iterable, Union -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning from airflow.operators.branch import BaseBranchOperator from airflow.utils import timezone from airflow.utils.context import Context @@ -71,7 +71,7 @@ def __init__( self.use_task_logical_date = use_task_execution_date warnings.warn( "Parameter ``use_task_execution_date`` is deprecated. Use ``use_task_logical_date``.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/docker_operator.py b/airflow/operators/docker_operator.py index 88235b4382461..408c8871a369f 100644 --- a/airflow/operators/docker_operator.py +++ b/airflow/operators/docker_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.docker.operators.docker import DockerOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.docker.operators.docker`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/druid_check_operator.py b/airflow/operators/druid_check_operator.py index 217c306f6dd60..6e103f54f8e06 100644 --- a/airflow/operators/druid_check_operator.py +++ b/airflow/operators/druid_check_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.druid.operators.druid_check import DruidCheckOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.common.sql.operators.sql` module.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/dummy.py b/airflow/operators/dummy.py index b2912e92586f0..23f0bce9857c0 100644 --- a/airflow/operators/dummy.py +++ b/airflow/operators/dummy.py @@ -19,11 +19,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.empty import EmptyOperator warnings.warn( "This module is deprecated. Please use `airflow.operators.empty`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -38,7 +39,7 @@ def inherits_from_dummy_operator(self): def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.operators.empty.EmptyOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) self.inherits_from_empty_operator = self.inherits_from_dummy_operator diff --git a/airflow/operators/dummy_operator.py b/airflow/operators/dummy_operator.py index 2b46095027875..cc791336bddfc 100644 --- a/airflow/operators/dummy_operator.py +++ b/airflow/operators/dummy_operator.py @@ -19,10 +19,13 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.empty import EmptyOperator warnings.warn( - "This module is deprecated. Please use `airflow.operators.empty`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.operators.empty`.", + RemovedInAirflow3Warning, + stacklevel=2, ) @@ -32,7 +35,7 @@ class DummyOperator(EmptyOperator): def __init__(self, *args, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.operators.empty.EmptyOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(*args, **kwargs) diff --git a/airflow/operators/email_operator.py b/airflow/operators/email_operator.py index 80901d010f669..c88c23d7063fe 100644 --- a/airflow/operators/email_operator.py +++ b/airflow/operators/email_operator.py @@ -19,8 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.email import EmailOperator # noqa warnings.warn( - "This module is deprecated. Please use `airflow.operators.email`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.operators.email`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/operators/gcs_to_s3.py b/airflow/operators/gcs_to_s3.py index d02bc7f224ea9..90d258d8b8b72 100644 --- a/airflow/operators/gcs_to_s3.py +++ b/airflow/operators/gcs_to_s3.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.transfers.gcs_to_s3 import GCSToS3Operator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.transfers.gcs_to_s3`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/google_api_to_s3_transfer.py b/airflow/operators/google_api_to_s3_transfer.py index 9566cddc77641..82425c122af8c 100644 --- a/airflow/operators/google_api_to_s3_transfer.py +++ b/airflow/operators/google_api_to_s3_transfer.py @@ -22,11 +22,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.transfers.google_api_to_s3 import GoogleApiToS3Operator warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.transfers.google_api_to_s3`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -44,7 +45,7 @@ def __init__(self, **kwargs): "Please use " "`airflow.providers.amazon.aws.transfers." "google_api_to_s3_transfer.GoogleApiToS3Operator`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/hive_operator.py b/airflow/operators/hive_operator.py index b49cf097305ea..3d0bc875b7a3f 100644 --- a/airflow/operators/hive_operator.py +++ b/airflow/operators/hive_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.operators.hive import HiveOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.operators.hive`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/hive_stats_operator.py b/airflow/operators/hive_stats_operator.py index af1e260a4a155..2bde99bbddc5c 100644 --- a/airflow/operators/hive_stats_operator.py +++ b/airflow/operators/hive_stats_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.operators.hive_stats import HiveStatsCollectionOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.operators.hive_stats`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/hive_to_druid.py b/airflow/operators/hive_to_druid.py index a6537a1337a56..52782fa5ed647 100644 --- a/airflow/operators/hive_to_druid.py +++ b/airflow/operators/hive_to_druid.py @@ -22,11 +22,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.druid.transfers.hive_to_druid import HiveToDruidOperator warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.druid.transfers.hive_to_druid`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -43,7 +44,7 @@ def __init__(self, **kwargs): """This class is deprecated. Please use `airflow.providers.apache.druid.transfers.hive_to_druid.HiveToDruidOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/hive_to_mysql.py b/airflow/operators/hive_to_mysql.py index 0a13c7666a4cb..d4db82607553b 100644 --- a/airflow/operators/hive_to_mysql.py +++ b/airflow/operators/hive_to_mysql.py @@ -22,11 +22,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.transfers.hive_to_mysql import HiveToMySqlOperator warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.transfers.hive_to_mysql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -43,7 +44,7 @@ def __init__(self, **kwargs): """This class is deprecated. Please use `airflow.providers.apache.hive.transfers.hive_to_mysql.HiveToMySqlOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/hive_to_samba_operator.py b/airflow/operators/hive_to_samba_operator.py index ed3b180b3e7c4..86883edefbe23 100644 --- a/airflow/operators/hive_to_samba_operator.py +++ b/airflow/operators/hive_to_samba_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.transfers.hive_to_samba import HiveToSambaOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.transfers.hive_to_samba`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/http_operator.py b/airflow/operators/http_operator.py index 6e2ab56df4e58..3a0ecb9f13c07 100644 --- a/airflow/operators/http_operator.py +++ b/airflow/operators/http_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.http.operators.http import SimpleHttpOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.http.operators.http`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/jdbc_operator.py b/airflow/operators/jdbc_operator.py index ff36f9f5d6467..eb47f5ea4aa07 100644 --- a/airflow/operators/jdbc_operator.py +++ b/airflow/operators/jdbc_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.jdbc.operators.jdbc import JdbcOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.jdbc.operators.jdbc`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/latest_only_operator.py b/airflow/operators/latest_only_operator.py index 07644f4a82c10..6a2392b244d09 100644 --- a/airflow/operators/latest_only_operator.py +++ b/airflow/operators/latest_only_operator.py @@ -18,8 +18,11 @@ """This module is deprecated. Please use :mod:`airflow.operators.latest_only`""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.latest_only import LatestOnlyOperator # noqa warnings.warn( - "This module is deprecated. Please use `airflow.operators.latest_only`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.operators.latest_only`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/operators/mssql_operator.py b/airflow/operators/mssql_operator.py index d1047b827a722..704bc6dae8c1f 100644 --- a/airflow/operators/mssql_operator.py +++ b/airflow/operators/mssql_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.microsoft.mssql.operators.mssql import MsSqlOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.microsoft.mssql.operators.mssql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/mssql_to_hive.py b/airflow/operators/mssql_to_hive.py index 02edb36b89b15..c40690c4fe38a 100644 --- a/airflow/operators/mssql_to_hive.py +++ b/airflow/operators/mssql_to_hive.py @@ -22,11 +22,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.transfers.mssql_to_hive import MsSqlToHiveOperator warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.transfers.mssql_to_hive`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -43,7 +44,7 @@ def __init__(self, **kwargs): """This class is deprecated. Please use `airflow.providers.apache.hive.transfers.mssql_to_hive.MsSqlToHiveOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/mysql_operator.py b/airflow/operators/mysql_operator.py index 82a94edd66add..f7423fec29a35 100644 --- a/airflow/operators/mysql_operator.py +++ b/airflow/operators/mysql_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.mysql.operators.mysql import MySqlOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.mysql.operators.mysql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/mysql_to_hive.py b/airflow/operators/mysql_to_hive.py index 95bd4302e7961..6a8e948928f99 100644 --- a/airflow/operators/mysql_to_hive.py +++ b/airflow/operators/mysql_to_hive.py @@ -19,11 +19,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.transfers.mysql_to_hive import MySqlToHiveOperator warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.transfers.mysql_to_hive`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -38,7 +39,7 @@ def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.providers.apache.hive.transfers.mysql_to_hive.MySqlToHiveOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/oracle_operator.py b/airflow/operators/oracle_operator.py index 8ad61db754dcb..a25f63750e221 100644 --- a/airflow/operators/oracle_operator.py +++ b/airflow/operators/oracle_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.oracle.operators.oracle import OracleOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.oracle.operators.oracle`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/papermill_operator.py b/airflow/operators/papermill_operator.py index 5d63e38e13721..1772d4103c50d 100644 --- a/airflow/operators/papermill_operator.py +++ b/airflow/operators/papermill_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.papermill.operators.papermill import PapermillOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.papermill.operators.papermill`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/pig_operator.py b/airflow/operators/pig_operator.py index 3b2ea0e05ac99..9e02730c78c17 100644 --- a/airflow/operators/pig_operator.py +++ b/airflow/operators/pig_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.pig.operators.pig import PigOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.pig.operators.pig`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/postgres_operator.py b/airflow/operators/postgres_operator.py index e5dc53c82bde6..917d018f1c230 100644 --- a/airflow/operators/postgres_operator.py +++ b/airflow/operators/postgres_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.postgres.operators.postgres import Mapping, PostgresOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.postgres.operators.postgres`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/presto_check_operator.py b/airflow/operators/presto_check_operator.py index 810eef39a48e5..d24b4395e4726 100644 --- a/airflow/operators/presto_check_operator.py +++ b/airflow/operators/presto_check_operator.py @@ -19,6 +19,7 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.common.sql.operators.sql import ( SQLCheckOperator, SQLIntervalCheckOperator, @@ -27,7 +28,7 @@ warnings.warn( "This module is deprecated. Please use `airflow.providers.common.sql.operators.sql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -42,7 +43,7 @@ def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.providers.common.sql.operators.sql.SQLCheckOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(**kwargs) @@ -60,7 +61,7 @@ def __init__(self, **kwargs): This class is deprecated.l Please use `airflow.providers.common.sql.operators.sql.SQLIntervalCheckOperator`. """, - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(**kwargs) @@ -78,7 +79,7 @@ def __init__(self, **kwargs): This class is deprecated.l Please use `airflow.providers.common.sql.operators.sql.SQLValueCheckOperator`. """, - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(**kwargs) diff --git a/airflow/operators/presto_to_mysql.py b/airflow/operators/presto_to_mysql.py index bfc117327d672..9a179b54c50c5 100644 --- a/airflow/operators/presto_to_mysql.py +++ b/airflow/operators/presto_to_mysql.py @@ -22,11 +22,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.mysql.transfers.presto_to_mysql import PrestoToMySqlOperator warnings.warn( "This module is deprecated. Please use `airflow.providers.mysql.transfers.presto_to_mysql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -43,7 +44,7 @@ def __init__(self, **kwargs): """This class is deprecated. Please use `airflow.providers.mysql.transfers.presto_to_mysql.PrestoToMySqlOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/python.py b/airflow/operators/python.py index c83d2d17b491c..8a96e215d1bc7 100644 --- a/airflow/operators/python.py +++ b/airflow/operators/python.py @@ -28,7 +28,7 @@ import dill -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning from airflow.models.baseoperator import BaseOperator from airflow.models.skipmixin import SkipMixin from airflow.models.taskinstance import _CURRENT_CONTEXT @@ -68,7 +68,7 @@ def my_task() from airflow.decorators import task @task def my_task()""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return python_task(python_callable=python_callable, multiple_outputs=multiple_outputs, **kwargs) @@ -147,7 +147,7 @@ def __init__( if kwargs.get("provide_context"): warnings.warn( "provide_context is deprecated as of 2.0 and is no longer required", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) kwargs.pop('provide_context', None) diff --git a/airflow/operators/python_operator.py b/airflow/operators/python_operator.py index ac8c6448d241d..02031f4677cbd 100644 --- a/airflow/operators/python_operator.py +++ b/airflow/operators/python_operator.py @@ -19,6 +19,7 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.python import ( # noqa BranchPythonOperator, PythonOperator, @@ -27,5 +28,7 @@ ) warnings.warn( - "This module is deprecated. Please use `airflow.operators.python`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.operators.python`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/operators/redshift_to_s3_operator.py b/airflow/operators/redshift_to_s3_operator.py index 9fceb700d42c7..8a0f70924dd9a 100644 --- a/airflow/operators/redshift_to_s3_operator.py +++ b/airflow/operators/redshift_to_s3_operator.py @@ -22,11 +22,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.transfers.redshift_to_s3 import RedshiftToS3Operator warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.transfers.redshift_to_s3`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -42,7 +43,7 @@ def __init__(self, **kwargs): """This class is deprecated. Please use `airflow.providers.amazon.aws.transfers.redshift_to_s3.RedshiftToS3Operator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/s3_file_transform_operator.py b/airflow/operators/s3_file_transform_operator.py index 828031d814102..7a43aa39beb64 100644 --- a/airflow/operators/s3_file_transform_operator.py +++ b/airflow/operators/s3_file_transform_operator.py @@ -22,10 +22,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.operators.s3_file_transform import S3FileTransformOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.operators.s3_file_transform`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/s3_to_hive_operator.py b/airflow/operators/s3_to_hive_operator.py index b0e1f6b69258a..50dd11e95cabf 100644 --- a/airflow/operators/s3_to_hive_operator.py +++ b/airflow/operators/s3_to_hive_operator.py @@ -19,11 +19,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.transfers.s3_to_hive import S3ToHiveOperator warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.transfers.s3_to_hive`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -38,7 +39,7 @@ def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.providers.apache.hive.transfers.s3_to_hive.S3ToHiveOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/s3_to_redshift_operator.py b/airflow/operators/s3_to_redshift_operator.py index f14a2912a8e8f..4679c3d6c8651 100644 --- a/airflow/operators/s3_to_redshift_operator.py +++ b/airflow/operators/s3_to_redshift_operator.py @@ -22,11 +22,12 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.transfers.s3_to_redshift import S3ToRedshiftOperator warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.transfers.s3_to_redshift`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -43,7 +44,7 @@ def __init__(self, **kwargs): """This class is deprecated. Please use `airflow.providers.amazon.aws.transfers.s3_to_redshift.S3ToRedshiftOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) super().__init__(**kwargs) diff --git a/airflow/operators/slack_operator.py b/airflow/operators/slack_operator.py index 3af49e222218e..9e46cd2a2c69d 100644 --- a/airflow/operators/slack_operator.py +++ b/airflow/operators/slack_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.slack.operators.slack import SlackAPIOperator, SlackAPIPostOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.slack.operators.slack`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/sql.py b/airflow/operators/sql.py index 9bbe159c17f24..a10f04766e9d8 100644 --- a/airflow/operators/sql.py +++ b/airflow/operators/sql.py @@ -17,6 +17,7 @@ # under the License. import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.common.sql.operators.sql import ( # noqa BaseSQLOperator, BranchSQLOperator, @@ -32,6 +33,6 @@ warnings.warn( "This module is deprecated. Please use `airflow.providers.common.sql.operators.sql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/sql_branch_operator.py b/airflow/operators/sql_branch_operator.py index 90d5fcbc1b4f1..897a35cbe6f74 100644 --- a/airflow/operators/sql_branch_operator.py +++ b/airflow/operators/sql_branch_operator.py @@ -17,11 +17,12 @@ """This module is deprecated. Please use :mod:`airflow.providers.common.sql.operators.sql`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.common.sql.operators.sql import BranchSQLOperator warnings.warn( "This module is deprecated. Please use :mod:`airflow.providers.common.sql.operators.sql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -36,7 +37,7 @@ def __init__(self, **kwargs): warnings.warn( """This class is deprecated. Please use `airflow.providers.common.sql.operators.sql.BranchSQLOperator`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) super().__init__(**kwargs) diff --git a/airflow/operators/sqlite_operator.py b/airflow/operators/sqlite_operator.py index 68791d69846c0..4966a22017902 100644 --- a/airflow/operators/sqlite_operator.py +++ b/airflow/operators/sqlite_operator.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.sqlite.operators.sqlite import SqliteOperator # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.sqlite.operators.sqlite`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/operators/subdag.py b/airflow/operators/subdag.py index bd81314dda8fd..60dba836dd4ec 100644 --- a/airflow/operators/subdag.py +++ b/airflow/operators/subdag.py @@ -28,7 +28,7 @@ from sqlalchemy.orm.session import Session from airflow.api.common.experimental.get_task_instance import get_task_instance -from airflow.exceptions import AirflowException, TaskInstanceNotFound +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning, TaskInstanceNotFound from airflow.models import DagRun from airflow.models.dag import DAG, DagContext from airflow.models.pool import Pool @@ -91,7 +91,7 @@ def __init__( warnings.warn( """This class is deprecated. Please use `airflow.utils.task_group.TaskGroup`.""", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=4, ) diff --git a/airflow/operators/subdag_operator.py b/airflow/operators/subdag_operator.py index bb5a088d23b6d..322999c7a738e 100644 --- a/airflow/operators/subdag_operator.py +++ b/airflow/operators/subdag_operator.py @@ -19,8 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.subdag import SkippedStatePropagationOptions, SubDagOperator # noqa warnings.warn( - "This module is deprecated. Please use `airflow.operators.subdag`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.operators.subdag`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/operators/weekday.py b/airflow/operators/weekday.py index b23d57e9fb1d4..2d3aa0bda9d56 100644 --- a/airflow/operators/weekday.py +++ b/airflow/operators/weekday.py @@ -18,6 +18,7 @@ import warnings from typing import Iterable, Union +from airflow.exceptions import RemovedInAirflow3Warning from airflow.operators.branch import BaseBranchOperator from airflow.utils import timezone from airflow.utils.context import Context @@ -65,7 +66,7 @@ def __init__( self.use_task_logical_date = use_task_execution_day warnings.warn( "Parameter ``use_task_execution_day`` is deprecated. Use ``use_task_logical_date``.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) self._week_day_num = WeekDay.validate_week_day(week_day) diff --git a/airflow/providers/amazon/aws/hooks/base_aws.py b/airflow/providers/amazon/aws/hooks/base_aws.py index 92ffd4e676f09..12e09767d10ef 100644 --- a/airflow/providers/amazon/aws/hooks/base_aws.py +++ b/airflow/providers/amazon/aws/hooks/base_aws.py @@ -325,7 +325,7 @@ def _get_region_name(self) -> Optional[str]: warnings.warn( "`BaseSessionFactory._get_region_name` method deprecated and will be removed " "in a future releases. Please use `BaseSessionFactory.region_name` property instead.", - PendingDeprecationWarning, + DeprecationWarning, stacklevel=2, ) return self.region_name @@ -334,7 +334,7 @@ def _read_role_arn_from_extra_config(self) -> Optional[str]: warnings.warn( "`BaseSessionFactory._read_role_arn_from_extra_config` method deprecated and will be removed " "in a future releases. Please use `BaseSessionFactory.role_arn` property instead.", - PendingDeprecationWarning, + DeprecationWarning, stacklevel=2, ) return self.role_arn @@ -344,7 +344,7 @@ def _read_credentials_from_connection(self) -> Tuple[Optional[str], Optional[str "`BaseSessionFactory._read_credentials_from_connection` method deprecated and will be removed " "in a future releases. Please use `BaseSessionFactory.conn.aws_access_key_id` and " "`BaseSessionFactory.aws_secret_access_key` properties instead.", - PendingDeprecationWarning, + DeprecationWarning, stacklevel=2, ) return self.conn.aws_access_key_id, self.conn.aws_secret_access_key diff --git a/airflow/providers/amazon/aws/secrets/secrets_manager.py b/airflow/providers/amazon/aws/secrets/secrets_manager.py index fa389a3086997..f333ee5584157 100644 --- a/airflow/providers/amazon/aws/secrets/secrets_manager.py +++ b/airflow/providers/amazon/aws/secrets/secrets_manager.py @@ -142,7 +142,7 @@ def __init__( "The `secret_values_are_urlencoded` kwarg only exists to assist in migrating away from" " URL-encoding secret values when `full_url_mode` is False. It will be considered deprecated" " when values are not required to be URL-encoded by default.", - PendingDeprecationWarning, + DeprecationWarning, stacklevel=2, ) if full_url_mode and not are_secret_values_urlencoded: diff --git a/airflow/providers/hashicorp/secrets/vault.py b/airflow/providers/hashicorp/secrets/vault.py index 52b019eeac12e..cb720b17c25d7 100644 --- a/airflow/providers/hashicorp/secrets/vault.py +++ b/airflow/providers/hashicorp/secrets/vault.py @@ -180,7 +180,7 @@ def get_conn_uri(self, conn_id: str) -> Optional[str]: warnings.warn( f"Method `{self.__class__.__name__}.get_conn_uri` is deprecated and will be removed " "in a future release.", - PendingDeprecationWarning, + DeprecationWarning, stacklevel=2, ) response = self.get_response(conn_id) diff --git a/airflow/providers/sendgrid/utils/emailer.py b/airflow/providers/sendgrid/utils/emailer.py index 58a1968180914..8e511b9f90125 100644 --- a/airflow/providers/sendgrid/utils/emailer.py +++ b/airflow/providers/sendgrid/utils/emailer.py @@ -133,7 +133,7 @@ def _post_sendgrid_mail(mail_data: Dict, conn_id: str = "sendgrid_default") -> N warnings.warn( "Fetching Sendgrid credentials from environment variables will be deprecated in a future " "release. Please set credentials using a connection instead.", - PendingDeprecationWarning, + DeprecationWarning, stacklevel=2, ) api_key = os.environ.get('SENDGRID_API_KEY') diff --git a/airflow/secrets/base_secrets.py b/airflow/secrets/base_secrets.py index a9942e9586385..a79351fbd39c0 100644 --- a/airflow/secrets/base_secrets.py +++ b/airflow/secrets/base_secrets.py @@ -18,6 +18,8 @@ from abc import ABC from typing import TYPE_CHECKING, List, Optional +from airflow.exceptions import RemovedInAirflow3Warning + if TYPE_CHECKING: from airflow.models.connection import Connection @@ -93,7 +95,7 @@ def get_connection(self, conn_id: str) -> Optional['Connection']: not_implemented_get_conn_value = True warnings.warn( "Method `get_conn_uri` is deprecated. Please use `get_conn_value`.", - PendingDeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -121,7 +123,7 @@ def get_connections(self, conn_id: str) -> List['Connection']: warnings.warn( "This method is deprecated. Please use " "`airflow.secrets.base_secrets.BaseSecretsBackend.get_connection`.", - PendingDeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) conn = self.get_connection(conn_id=conn_id) diff --git a/airflow/secrets/environment_variables.py b/airflow/secrets/environment_variables.py index 41883ba33d128..49e723fd352a1 100644 --- a/airflow/secrets/environment_variables.py +++ b/airflow/secrets/environment_variables.py @@ -21,6 +21,7 @@ import warnings from typing import Optional +from airflow.exceptions import RemovedInAirflow3Warning from airflow.secrets import BaseSecretsBackend CONN_ENV_PREFIX = "AIRFLOW_CONN_" @@ -39,7 +40,7 @@ def get_conn_uri(self, conn_id: str) -> Optional[str]: warnings.warn( "This method is deprecated. Please use " "`airflow.secrets.environment_variables.EnvironmentVariablesBackend.get_conn_value`.", - PendingDeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return self.get_conn_value(conn_id) diff --git a/airflow/secrets/local_filesystem.py b/airflow/secrets/local_filesystem.py index 25c4eed3db966..bfbef8bee3c77 100644 --- a/airflow/secrets/local_filesystem.py +++ b/airflow/secrets/local_filesystem.py @@ -30,6 +30,7 @@ AirflowFileParseException, ConnectionNotUnique, FileSyntaxError, + RemovedInAirflow3Warning, ) from airflow.secrets.base_secrets import BaseSecretsBackend from airflow.utils import yaml @@ -244,7 +245,7 @@ def load_connections(file_path) -> Dict[str, List[Any]]: """This function is deprecated. Please use `airflow.secrets.local_filesystem.load_connections_dict`.",""" warnings.warn( "This function is deprecated. Please use `airflow.secrets.local_filesystem.load_connections_dict`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return {k: [v] for k, v in load_connections_dict(file_path).values()} @@ -322,7 +323,7 @@ def get_connections(self, conn_id: str) -> List[Any]: warnings.warn( "This method is deprecated. Please use " "`airflow.secrets.local_filesystem.LocalFilesystemBackend.get_connection`.", - PendingDeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) conn = self.get_connection(conn_id=conn_id) diff --git a/airflow/secrets/metastore.py b/airflow/secrets/metastore.py index 100a35d8fd2c2..360db4a3fd88f 100644 --- a/airflow/secrets/metastore.py +++ b/airflow/secrets/metastore.py @@ -19,6 +19,7 @@ import warnings from typing import TYPE_CHECKING, List, Optional +from airflow.exceptions import RemovedInAirflow3Warning from airflow.secrets import BaseSecretsBackend from airflow.utils.session import provide_session @@ -42,7 +43,7 @@ def get_connections(self, conn_id, session=None) -> List['Connection']: warnings.warn( "This method is deprecated. Please use " "`airflow.secrets.metastore.MetastoreBackend.get_connection`.", - PendingDeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) conn = self.get_connection(conn_id=conn_id, session=session) diff --git a/airflow/sensors/base_sensor_operator.py b/airflow/sensors/base_sensor_operator.py index 716f03141ace9..1ad050eeb5367 100644 --- a/airflow/sensors/base_sensor_operator.py +++ b/airflow/sensors/base_sensor_operator.py @@ -19,8 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.sensors.base import BaseSensorOperator # noqa warnings.warn( - "This module is deprecated. Please use `airflow.sensors.base`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.sensors.base`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/sensors/date_time_sensor.py b/airflow/sensors/date_time_sensor.py index 63a221685af7c..1ee8bda4c873a 100644 --- a/airflow/sensors/date_time_sensor.py +++ b/airflow/sensors/date_time_sensor.py @@ -19,8 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.sensors.date_time import DateTimeSensor # noqa warnings.warn( - "This module is deprecated. Please use `airflow.sensors.date_time`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.sensors.date_time`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/sensors/external_task.py b/airflow/sensors/external_task.py index 19005ea19ec1a..27348a31f621f 100644 --- a/airflow/sensors/external_task.py +++ b/airflow/sensors/external_task.py @@ -24,7 +24,7 @@ import attr from sqlalchemy import func -from airflow.exceptions import AirflowException, AirflowSkipException +from airflow.exceptions import AirflowException, AirflowSkipException, RemovedInAirflow3Warning from airflow.models.baseoperator import BaseOperatorLink from airflow.models.dag import DagModel from airflow.models.dagbag import DagBag @@ -420,6 +420,6 @@ def __attrs_post_init__(self): warnings.warn( "This external link is deprecated. " "Please use :class:`airflow.sensors.external_task.ExternalDagLink`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/external_task_sensor.py b/airflow/sensors/external_task_sensor.py index bc24a4d1f27eb..4bb0901a7170f 100644 --- a/airflow/sensors/external_task_sensor.py +++ b/airflow/sensors/external_task_sensor.py @@ -19,6 +19,7 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.sensors.external_task import ( # noqa ExternalTaskMarker, ExternalTaskSensor, @@ -26,5 +27,7 @@ ) warnings.warn( - "This module is deprecated. Please use `airflow.sensors.external_task`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.sensors.external_task`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/sensors/hdfs_sensor.py b/airflow/sensors/hdfs_sensor.py index 0d5690085beb9..7f95259216def 100644 --- a/airflow/sensors/hdfs_sensor.py +++ b/airflow/sensors/hdfs_sensor.py @@ -20,10 +20,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hdfs.sensors.hdfs import HdfsSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hdfs.sensors.hdfs`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/hive_partition_sensor.py b/airflow/sensors/hive_partition_sensor.py index 8f6f08ae3f552..0b4599740e0e7 100644 --- a/airflow/sensors/hive_partition_sensor.py +++ b/airflow/sensors/hive_partition_sensor.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.sensors.hive_partition import HivePartitionSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.sensors.hive_partition`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/http_sensor.py b/airflow/sensors/http_sensor.py index 96dce065b50e8..c14ae99b0e19d 100644 --- a/airflow/sensors/http_sensor.py +++ b/airflow/sensors/http_sensor.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.http.sensors.http import HttpSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.http.sensors.http`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/metastore_partition_sensor.py b/airflow/sensors/metastore_partition_sensor.py index 812c86fc57c0a..693afba4b1b11 100644 --- a/airflow/sensors/metastore_partition_sensor.py +++ b/airflow/sensors/metastore_partition_sensor.py @@ -22,10 +22,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.sensors.metastore_partition import MetastorePartitionSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.sensors.metastore_partition`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/named_hive_partition_sensor.py b/airflow/sensors/named_hive_partition_sensor.py index 574c2ce04402c..cdae0f7ae39b6 100644 --- a/airflow/sensors/named_hive_partition_sensor.py +++ b/airflow/sensors/named_hive_partition_sensor.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hive.sensors.named_hive_partition import NamedHivePartitionSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hive.sensors.named_hive_partition`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/s3_key_sensor.py b/airflow/sensors/s3_key_sensor.py index e802f744f633a..450f769b9872d 100644 --- a/airflow/sensors/s3_key_sensor.py +++ b/airflow/sensors/s3_key_sensor.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.sensors.s3 import S3KeySensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.sensors.s3_key`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/sql.py b/airflow/sensors/sql.py index c52fe691434e1..79ccab040bad7 100644 --- a/airflow/sensors/sql.py +++ b/airflow/sensors/sql.py @@ -17,10 +17,11 @@ # under the License. import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.common.sql.sensors.sql import SqlSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.common.sql.sensors.sql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/sql_sensor.py b/airflow/sensors/sql_sensor.py index 6f7b1e46c0930..22ea90dc26f26 100644 --- a/airflow/sensors/sql_sensor.py +++ b/airflow/sensors/sql_sensor.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.common.sql.sensors.sql import SqlSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.common.sql.sensors.sql`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/time_delta_sensor.py b/airflow/sensors/time_delta_sensor.py index 73f32c2fc82fc..02f03b78e5b1f 100644 --- a/airflow/sensors/time_delta_sensor.py +++ b/airflow/sensors/time_delta_sensor.py @@ -19,8 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.sensors.time_delta import TimeDeltaSensor # noqa warnings.warn( - "This module is deprecated. Please use `airflow.sensors.time_delta`.", DeprecationWarning, stacklevel=2 + "This module is deprecated. Please use `airflow.sensors.time_delta`.", + RemovedInAirflow3Warning, + stacklevel=2, ) diff --git a/airflow/sensors/web_hdfs_sensor.py b/airflow/sensors/web_hdfs_sensor.py index 8f9324e7c2b7b..6a046ad4a75a0 100644 --- a/airflow/sensors/web_hdfs_sensor.py +++ b/airflow/sensors/web_hdfs_sensor.py @@ -19,10 +19,11 @@ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.apache.hdfs.sensors.web_hdfs import WebHdfsSensor # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.apache.hdfs.sensors.web_hdfs`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/sensors/weekday.py b/airflow/sensors/weekday.py index 5bb4db646f7c4..ec5abbb413793 100644 --- a/airflow/sensors/weekday.py +++ b/airflow/sensors/weekday.py @@ -17,6 +17,7 @@ # under the License. import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.sensors.base import BaseSensorOperator from airflow.utils import timezone from airflow.utils.context import Context @@ -79,7 +80,7 @@ def __init__(self, *, week_day, use_task_logical_date=False, use_task_execution_ self.use_task_logical_date = use_task_execution_day warnings.warn( "Parameter ``use_task_execution_day`` is deprecated. Use ``use_task_logical_date``.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) self._week_day_num = WeekDay.validate_week_day(week_day) diff --git a/airflow/serialization/serialized_objects.py b/airflow/serialization/serialized_objects.py index 8fa467483f765..15c7eacafced6 100644 --- a/airflow/serialization/serialized_objects.py +++ b/airflow/serialization/serialized_objects.py @@ -34,7 +34,7 @@ from airflow.compat.functools import cache from airflow.configuration import conf from airflow.datasets import Dataset -from airflow.exceptions import AirflowException, SerializationError +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning, SerializationError from airflow.models.baseoperator import BaseOperator, BaseOperatorLink from airflow.models.connection import Connection from airflow.models.dag import DAG, create_timetable @@ -903,7 +903,7 @@ def get_custom_dep() -> List[DagDependency]: warnings.warn( "Use of a custom dependency detector is deprecated. " "Support will be removed in a future release.", - DeprecationWarning, + RemovedInAirflow3Warning, ) dep = custom_dependency_detector_cls().detect_task_dependencies(op) if type(dep) is DagDependency: diff --git a/airflow/settings.py b/airflow/settings.py index beaed3b4599b0..6bcb0f2edf245 100644 --- a/airflow/settings.py +++ b/airflow/settings.py @@ -33,6 +33,7 @@ from sqlalchemy.pool import NullPool from airflow.configuration import AIRFLOW_HOME, WEBSERVER_CONFIG, conf # NOQA F401 +from airflow.exceptions import RemovedInAirflow3Warning from airflow.executors import executor_constants from airflow.logging_config import configure_logging from airflow.utils.orm_event_handlers import setup_event_handlers @@ -496,7 +497,7 @@ def get_session_lifetime_config(): 'renamed to `session_lifetime_minutes`. The new option allows to configure ' 'session lifetime in minutes. The `force_log_out_after` option has been removed ' 'from `[webserver]` section. Please update your configuration.', - category=DeprecationWarning, + category=RemovedInAirflow3Warning, ) if session_lifetime_days: session_lifetime_minutes = minutes_per_day * int(session_lifetime_days) diff --git a/airflow/utils/context.py b/airflow/utils/context.py index 8141b3068dc85..6880c23edbb42 100644 --- a/airflow/utils/context.py +++ b/airflow/utils/context.py @@ -39,6 +39,7 @@ import lazy_object_proxy +from airflow.exceptions import RemovedInAirflow3Warning from airflow.utils.types import NOTSET # NOTE: Please keep this in sync with Context in airflow/utils/context.pyi. @@ -136,11 +137,11 @@ def get(self, key: str, default_conn: Any = None) -> Any: return default_conn -class AirflowContextDeprecationWarning(DeprecationWarning): +class AirflowContextDeprecationWarning(RemovedInAirflow3Warning): """Warn for usage of deprecated context variables in a task.""" -def _create_deprecation_warning(key: str, replacements: List[str]) -> DeprecationWarning: +def _create_deprecation_warning(key: str, replacements: List[str]) -> RemovedInAirflow3Warning: message = f"Accessing {key!r} from the template is deprecated and will be removed in a future version." if not replacements: return AirflowContextDeprecationWarning(message) diff --git a/airflow/utils/dag_cycle_tester.py b/airflow/utils/dag_cycle_tester.py index 90119c28c7cbd..ef587f6ba87e7 100644 --- a/airflow/utils/dag_cycle_tester.py +++ b/airflow/utils/dag_cycle_tester.py @@ -18,7 +18,7 @@ from collections import defaultdict, deque from typing import TYPE_CHECKING, Deque, Dict -from airflow.exceptions import AirflowDagCycleException +from airflow.exceptions import AirflowDagCycleException, RemovedInAirflow3Warning if TYPE_CHECKING: from airflow.models.dag import DAG @@ -38,7 +38,7 @@ def test_cycle(dag: 'DAG') -> None: warn( "Deprecated, please use `check_cycle` at the same module instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return check_cycle(dag) diff --git a/airflow/utils/dates.py b/airflow/utils/dates.py index e9f01eb184ffd..4536b7e2b6527 100644 --- a/airflow/utils/dates.py +++ b/airflow/utils/dates.py @@ -23,6 +23,7 @@ from croniter import croniter from dateutil.relativedelta import relativedelta # for doctest +from airflow.exceptions import RemovedInAirflow3Warning from airflow.utils import timezone cron_presets: Dict[str, str] = { @@ -71,7 +72,7 @@ def date_range( """ warnings.warn( "`airflow.utils.dates.date_range()` is deprecated. Please use `airflow.timetables`.", - category=DeprecationWarning, + category=RemovedInAirflow3Warning, stacklevel=2, ) @@ -256,7 +257,7 @@ def days_ago(n, hour=0, minute=0, second=0, microsecond=0): warnings.warn( "Function `days_ago` is deprecated and will be removed in Airflow 3.0. " "You can achieve equivalent behavior with `pendulum.today('UTC').add(days=-N, ...)`", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/utils/decorators.py b/airflow/utils/decorators.py index ea5a536a522c3..f774e59b16cfe 100644 --- a/airflow/utils/decorators.py +++ b/airflow/utils/decorators.py @@ -21,6 +21,8 @@ from functools import wraps from typing import Callable, TypeVar, cast +from airflow.exceptions import RemovedInAirflow3Warning + T = TypeVar('T', bound=Callable) @@ -40,7 +42,7 @@ def apply_defaults(func: T) -> T: "`default_args` feature to work properly.\n" "\n" "In current version, it is optional. The decorator is applied automatically using the metaclass.\n", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) diff --git a/airflow/utils/email.py b/airflow/utils/email.py index 868574379cfd9..af735884519c6 100644 --- a/airflow/utils/email.py +++ b/airflow/utils/email.py @@ -28,7 +28,7 @@ from typing import Any, Dict, Iterable, List, Optional, Tuple, Union from airflow.configuration import conf -from airflow.exceptions import AirflowConfigException, AirflowException +from airflow.exceptions import AirflowConfigException, AirflowException, RemovedInAirflow3Warning log = logging.getLogger(__name__) @@ -214,7 +214,7 @@ def send_mime_email( warnings.warn( "Fetching SMTP credentials from configuration variables will be deprecated in a future " "release. Please set credentials using a connection instead.", - PendingDeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) try: diff --git a/airflow/utils/file.py b/airflow/utils/file.py index 1209d81d2cac9..f559287b2bb70 100644 --- a/airflow/utils/file.py +++ b/airflow/utils/file.py @@ -28,6 +28,7 @@ from typing_extensions import Protocol from airflow.configuration import conf +from airflow.exceptions import RemovedInAirflow3Warning if TYPE_CHECKING: import pathlib @@ -125,7 +126,7 @@ def TemporaryDirectory(*args, **kwargs): warnings.warn( "This function is deprecated. Please use `tempfile.TemporaryDirectory`", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) @@ -144,7 +145,7 @@ def mkdirs(path, mode): warnings.warn( f"This function is deprecated. Please use `pathlib.Path({path}).mkdir`", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) Path(path).mkdir(mode=mode, parents=True, exist_ok=True) diff --git a/airflow/utils/helpers.py b/airflow/utils/helpers.py index b502cb5f25122..8d695e094b405 100644 --- a/airflow/utils/helpers.py +++ b/airflow/utils/helpers.py @@ -38,7 +38,7 @@ ) from airflow.configuration import conf -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning from airflow.utils.context import Context from airflow.utils.module_loading import import_string from airflow.utils.types import NOTSET @@ -235,7 +235,7 @@ def chain(*args, **kwargs): """This function is deprecated. Please use `airflow.models.baseoperator.chain`.""" warnings.warn( "This function is deprecated. Please use `airflow.models.baseoperator.chain`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return import_string('airflow.models.baseoperator.chain')(*args, **kwargs) @@ -245,7 +245,7 @@ def cross_downstream(*args, **kwargs): """This function is deprecated. Please use `airflow.models.baseoperator.cross_downstream`.""" warnings.warn( "This function is deprecated. Please use `airflow.models.baseoperator.cross_downstream`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return import_string('airflow.models.baseoperator.cross_downstream')(*args, **kwargs) diff --git a/airflow/utils/log/cloudwatch_task_handler.py b/airflow/utils/log/cloudwatch_task_handler.py index cdb7b7958629a..1d09c984a50b1 100644 --- a/airflow/utils/log/cloudwatch_task_handler.py +++ b/airflow/utils/log/cloudwatch_task_handler.py @@ -18,10 +18,11 @@ """This module is deprecated. Please use :mod:`airflow.providers.amazon.aws.log.cloudwatch_task_handler`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.log.cloudwatch_task_handler import CloudwatchTaskHandler # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.log.cloudwatch_task_handler`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/utils/log/es_task_handler.py b/airflow/utils/log/es_task_handler.py index 30ec16a1c3d30..6008e072f475f 100644 --- a/airflow/utils/log/es_task_handler.py +++ b/airflow/utils/log/es_task_handler.py @@ -18,10 +18,11 @@ """This module is deprecated. Please use :mod:`airflow.providers.elasticsearch.log.es_task_handler`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.elasticsearch.log.es_task_handler import ElasticsearchTaskHandler # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.elasticsearch.log.es_task_handler`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/utils/log/file_task_handler.py b/airflow/utils/log/file_task_handler.py index ad05e9447a22d..812633e17131f 100644 --- a/airflow/utils/log/file_task_handler.py +++ b/airflow/utils/log/file_task_handler.py @@ -23,6 +23,7 @@ from typing import TYPE_CHECKING, Optional from airflow.configuration import AirflowConfigException, conf +from airflow.exceptions import RemovedInAirflow3Warning from airflow.utils.context import Context from airflow.utils.helpers import parse_template_string, render_template_to_string from airflow.utils.jwt_signer import JWTSigner @@ -51,7 +52,7 @@ def __init__(self, base_log_folder: str, filename_template: Optional[str] = None if filename_template is not None: warnings.warn( "Passing filename_template to a log handler is deprecated and has no effect", - DeprecationWarning, + RemovedInAirflow3Warning, # We want to reference the stack that actually instantiates the # handler, not the one that calls super()__init__. stacklevel=(2 if type(self) == FileTaskHandler else 3), diff --git a/airflow/utils/log/gcs_task_handler.py b/airflow/utils/log/gcs_task_handler.py index 69ae32f8a077e..41a9e5718e40b 100644 --- a/airflow/utils/log/gcs_task_handler.py +++ b/airflow/utils/log/gcs_task_handler.py @@ -18,10 +18,11 @@ """This module is deprecated. Please use :mod:`airflow.providers.google.cloud.log.gcs_task_handler`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.google.cloud.log.gcs_task_handler import GCSTaskHandler # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.google.cloud.log.gcs_task_handler`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/utils/log/s3_task_handler.py b/airflow/utils/log/s3_task_handler.py index 01365c6760e6d..f71856f576ee3 100644 --- a/airflow/utils/log/s3_task_handler.py +++ b/airflow/utils/log/s3_task_handler.py @@ -18,10 +18,11 @@ """This module is deprecated. Please use :mod:`airflow.providers.amazon.aws.log.s3_task_handler`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.amazon.aws.log.s3_task_handler import S3TaskHandler # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.amazon.aws.log.s3_task_handler`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/utils/log/stackdriver_task_handler.py b/airflow/utils/log/stackdriver_task_handler.py index da2eda1af41c4..b891c4b18ce0e 100644 --- a/airflow/utils/log/stackdriver_task_handler.py +++ b/airflow/utils/log/stackdriver_task_handler.py @@ -20,10 +20,11 @@ """ import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.google.cloud.log.stackdriver_task_handler import StackdriverTaskHandler # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.google.cloud.log.stackdriver_task_handler`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/utils/log/wasb_task_handler.py b/airflow/utils/log/wasb_task_handler.py index adfa94f593ffd..5f08dc574b2b5 100644 --- a/airflow/utils/log/wasb_task_handler.py +++ b/airflow/utils/log/wasb_task_handler.py @@ -18,10 +18,11 @@ """This module is deprecated. Please use :mod:`airflow.providers.microsoft.azure.log.wasb_task_handler`.""" import warnings +from airflow.exceptions import RemovedInAirflow3Warning from airflow.providers.microsoft.azure.log.wasb_task_handler import WasbTaskHandler # noqa warnings.warn( "This module is deprecated. Please use `airflow.providers.microsoft.azure.log.wasb_task_handler`.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) diff --git a/airflow/www/app.py b/airflow/www/app.py index 21b595e981513..2165d80742cab 100644 --- a/airflow/www/app.py +++ b/airflow/www/app.py @@ -29,7 +29,7 @@ from airflow import settings from airflow.configuration import conf -from airflow.exceptions import AirflowConfigException +from airflow.exceptions import AirflowConfigException, RemovedInAirflow3Warning from airflow.logging_config import configure_logging from airflow.utils.json import AirflowJsonEncoder from airflow.www.extensions.init_appbuilder import init_appbuilder @@ -96,7 +96,7 @@ def create_app(config=None, testing=False): warnings.warn( "Old deprecated value found for `cookie_samesite` option in `[webserver]` section. " "Using `Lax` instead. Change the value to `Lax` in airflow.cfg to remove this warning.", - DeprecationWarning, + RemovedInAirflow3Warning, ) cookie_samesite_config = "Lax" flask_app.config['SESSION_COOKIE_SAMESITE'] = cookie_samesite_config diff --git a/airflow/www/extensions/init_views.py b/airflow/www/extensions/init_views.py index 4a2d4a5119e0b..c04971ecae869 100644 --- a/airflow/www/extensions/init_views.py +++ b/airflow/www/extensions/init_views.py @@ -24,6 +24,7 @@ from airflow.api_connexion.exceptions import common_error_handler from airflow.configuration import conf +from airflow.exceptions import RemovedInAirflow3Warning from airflow.security import permissions from airflow.www.views import lazy_add_provider_discovered_options_to_connection_form @@ -214,7 +215,7 @@ def init_api_experimental(app): "The experimental REST API is deprecated. Please migrate to the stable REST API. " "Please note that the experimental API do not have access control. " "The authenticated user has full access.", - DeprecationWarning, + RemovedInAirflow3Warning, ) app.register_blueprint(endpoints.api_experimental, url_prefix='/api/experimental') app.extensions['csrf'].exempt(endpoints.api_experimental) diff --git a/airflow/www/security.py b/airflow/www/security.py index 99d7c3ce901e2..dbf2705d01daf 100644 --- a/airflow/www/security.py +++ b/airflow/www/security.py @@ -24,7 +24,7 @@ from sqlalchemy import or_ from sqlalchemy.orm import joinedload -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning from airflow.models import DagBag, DagModel from airflow.security import permissions from airflow.utils.log.logging_mixin import LoggingMixin @@ -220,7 +220,7 @@ def init_role(self, role_name, perms): """ warnings.warn( "`init_role` has been deprecated. Please use `bulk_sync_roles` instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) self.bulk_sync_roles([{'role': role_name, 'perms': perms}]) @@ -274,29 +274,29 @@ def get_readable_dags(self, user): """Gets the DAGs readable by authenticated user.""" warnings.warn( "`get_readable_dags` has been deprecated. Please use `get_readable_dag_ids` instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) return self.get_accessible_dags([permissions.ACTION_CAN_READ], user) def get_editable_dags(self, user): """Gets the DAGs editable by authenticated user.""" warnings.warn( "`get_editable_dags` has been deprecated. Please use `get_editable_dag_ids` instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) return self.get_accessible_dags([permissions.ACTION_CAN_EDIT], user) @provide_session def get_accessible_dags(self, user_actions, user, session=None): warnings.warn( "`get_accessible_dags` has been deprecated. Please use `get_accessible_dag_ids` instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=3, ) dag_ids = self.get_accessible_dag_ids(user, user_actions, session) @@ -382,7 +382,7 @@ def prefixed_dag_id(self, dag_id): warnings.warn( "`prefixed_dag_id` has been deprecated. " "Please use `airflow.security.permissions.resource_name_for_dag` instead.", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) root_dag_id = self._get_root_dag_id(dag_id) diff --git a/airflow/www/utils.py b/airflow/www/utils.py index 8b13374d4e049..fff2b8a48fe7e 100644 --- a/airflow/www/utils.py +++ b/airflow/www/utils.py @@ -38,6 +38,7 @@ from sqlalchemy.ext.associationproxy import AssociationProxy from airflow import models +from airflow.exceptions import RemovedInAirflow3Warning from airflow.models import errors from airflow.models.dagwarning import DagWarning from airflow.models.taskinstance import TaskInstance @@ -167,7 +168,7 @@ def get_sensitive_variables_fields(): warnings.warn( "This function is deprecated. Please use " "`airflow.utils.log.secrets_masker.get_sensitive_variables_fields`", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return get_sensitive_variables_fields() @@ -181,7 +182,7 @@ def should_hide_value_for_key(key_name): warnings.warn( "This function is deprecated. Please use " "`airflow.utils.log.secrets_masker.should_hide_value_for_key`", - DeprecationWarning, + RemovedInAirflow3Warning, stacklevel=2, ) return should_hide_value_for_key(key_name) diff --git a/airflow/www/views.py b/airflow/www/views.py index 2aec0df07815c..d366892fcaa99 100644 --- a/airflow/www/views.py +++ b/airflow/www/views.py @@ -101,7 +101,7 @@ from airflow.compat.functools import cached_property from airflow.configuration import AIRFLOW_CONFIG, conf from airflow.datasets import Dataset -from airflow.exceptions import AirflowException, ParamValidationError +from airflow.exceptions import AirflowException, ParamValidationError, RemovedInAirflow3Warning from airflow.executors.executor_loader import ExecutorLoader from airflow.jobs.base_job import BaseJob from airflow.jobs.scheduler_job import SchedulerJob @@ -1751,7 +1751,7 @@ def task(self, session): ] # Some fields on TI are deprecated, but we don't want those warnings here. with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) + warnings.simplefilter("ignore", RemovedInAirflow3Warning) all_ti_attrs = ( (name, getattr(ti, name)) for name in dir(ti) diff --git a/dev/breeze/src/airflow_breeze/pre_commit_ids.py b/dev/breeze/src/airflow_breeze/pre_commit_ids.py index ac7d2ca684b80..217ae56d788ac 100644 --- a/dev/breeze/src/airflow_breeze/pre_commit_ids.py +++ b/dev/breeze/src/airflow_breeze/pre_commit_ids.py @@ -34,6 +34,7 @@ 'check-breeze-top-dependencies-limited', 'check-builtin-literals', 'check-changelog-has-no-duplicates', + 'check-core-deprecation-classes', 'check-daysago-import-from-utils', 'check-decorated-operator-implements-custom-name', 'check-docstring-param-types', diff --git a/images/breeze/output-commands-hash.txt b/images/breeze/output-commands-hash.txt index 8a01b7b0b392c..78189637f9f5a 100644 --- a/images/breeze/output-commands-hash.txt +++ b/images/breeze/output-commands-hash.txt @@ -32,7 +32,7 @@ setup:self-upgrade:d02f70c7a230eae3463ceec2056b63fa setup:version:d11da4c17a23179830079b646160149c shell:1cefbacc29c6aff3c5fb2d1be2cd1950 start-airflow:3e793b11dc2158c54bfc189bfe20d6f2 -static-checks:a86b25f9281c47abf362a221b316c7a2 +static-checks:5563b797f9a95e55e9f6f06e125f12eb stop:8ebd8a42f1003495d37b884de5ac7ce6 testing:docker-compose-tests:8ae3b6211fd31db81a750d1c6b96ec3d testing:helm-tests:fa8fb6376ead71125103972b73de6b93 diff --git a/images/breeze/output_static-checks.svg b/images/breeze/output_static-checks.svg index da385d5682bd9..67cb69949c69e 100644 --- a/images/breeze/output_static-checks.svg +++ b/images/breeze/output_static-checks.svg @@ -1,4 +1,4 @@ - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - Command: static-checks + Command: static-checks - + - - -Usage: breeze static-checks [OPTIONS] [PRECOMMIT_ARGS]... - -Run static checks. - -╭─ Pre-commit flags ───────────────────────────────────────────────────────────────────────────────────────────────────╮ ---type-tType(s) of the static checks to run (multiple can be added).                             -(all | black | blacken-docs | check-airflow-2-2-compatibility |                          -check-airflow-config-yaml-consistent | check-apache-license-rat |                        -check-base-operator-partial-arguments | check-base-operator-usage |                      -check-boring-cyborg-configuration | check-breeze-top-dependencies-limited |              -check-builtin-literals | check-changelog-has-no-duplicates |                             -check-daysago-import-from-utils | check-decorated-operator-implements-custom-name |      -check-docstring-param-types | check-example-dags-urls | check-executables-have-shebangs  -| check-extra-packages-references | check-extras-order | check-for-inclusive-language |  -check-hooks-apply | check-incorrect-use-of-LoggingMixin |                                -check-integrations-are-consistent | check-lazy-logging | check-merge-conflict |          -check-newsfragments-are-valid | check-no-providers-in-core-examples |                    -check-no-relative-imports | check-persist-credentials-disabled-in-github-workflows |     -check-pre-commit-information-consistent | check-provide-create-sessions-imports |        -check-provider-yaml-valid | check-providers-init-file-missing |                          -check-providers-subpackages-init-file-exist | check-pydevd-left-in-code |                -check-revision-heads-map | check-safe-filter-usage-in-html | check-setup-order |         -check-start-date-not-used-in-defaults | check-system-tests-present |                     -check-system-tests-tocs | check-xml | codespell | compile-www-assets |                   -compile-www-assets-dev | create-missing-init-py-files-tests | debug-statements |         -detect-private-key | doctoc | end-of-file-fixer | fix-encoding-pragma | flynt | identity -| insert-license | isort | lint-chart-schema | lint-css | lint-dockerfile |              -lint-helm-chart | lint-javascript | lint-json-schema | lint-markdown | lint-openapi |    -mixed-line-ending | pretty-format-json | pydocstyle | python-no-log-warn | pyupgrade |   -replace-bad-characters | rst-backticks | run-flake8 | run-mypy | run-shellcheck |        -static-check-autoflake | trailing-whitespace | ts-compile-and-lint-javascript |          -update-breeze-cmd-output | update-breeze-readme-config-hash | update-extras |            -update-in-the-wild-to-be-sorted | update-inlined-dockerfile-scripts |                    -update-local-yml-file | update-migration-references | update-providers-dependencies |    -update-setup-cfg-file | update-spelling-wordlist-to-be-sorted |                          -update-supported-versions | update-vendored-in-k8s-json-schema | update-version |        -yamllint | yesqa)                                                                        ---file-fList of files to run the checks on.(PATH) ---all-files-aRun checks on all files. ---show-diff-on-failure-sShow diff for files modified by the checks. ---last-commit-cRun checks for all files in last commit. Mutually exclusive with --commit-ref. ---commit-ref-rRun checks for this commit reference only (can be any git commit-ish reference).         -Mutually exclusive with --last-commit.                                                   -(TEXT)                                                                                   -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Common options ─────────────────────────────────────────────────────────────────────────────────────────────────────╮ ---verbose-vPrint verbose information about performed steps. ---dry-run-DIf dry-run is set, commands are only printed, not executed. ---github-repository-gGitHub repository used to pull, push run images.(TEXT)[default: apache/airflow] ---help-hShow this message and exit. -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + +Usage: breeze static-checks [OPTIONS] [PRECOMMIT_ARGS]... + +Run static checks. + +╭─ Pre-commit flags ───────────────────────────────────────────────────────────────────────────────────────────────────╮ +--type-tType(s) of the static checks to run (multiple can be added).                             +(all | black | blacken-docs | check-airflow-2-2-compatibility |                          +check-airflow-config-yaml-consistent | check-apache-license-rat |                        +check-base-operator-partial-arguments | check-base-operator-usage |                      +check-boring-cyborg-configuration | check-breeze-top-dependencies-limited |              +check-builtin-literals | check-changelog-has-no-duplicates |                             +check-core-deprecation-classes | check-daysago-import-from-utils |                       +check-decorated-operator-implements-custom-name | check-docstring-param-types |          +check-example-dags-urls | check-executables-have-shebangs |                              +check-extra-packages-references | check-extras-order | check-for-inclusive-language |    +check-hooks-apply | check-incorrect-use-of-LoggingMixin |                                +check-integrations-are-consistent | check-lazy-logging | check-merge-conflict |          +check-newsfragments-are-valid | check-no-providers-in-core-examples |                    +check-no-relative-imports | check-persist-credentials-disabled-in-github-workflows |     +check-pre-commit-information-consistent | check-provide-create-sessions-imports |        +check-provider-yaml-valid | check-providers-init-file-missing |                          +check-providers-subpackages-init-file-exist | check-pydevd-left-in-code |                +check-revision-heads-map | check-safe-filter-usage-in-html | check-setup-order |         +check-start-date-not-used-in-defaults | check-system-tests-present |                     +check-system-tests-tocs | check-xml | codespell | compile-www-assets |                   +compile-www-assets-dev | create-missing-init-py-files-tests | debug-statements |         +detect-private-key | doctoc | end-of-file-fixer | fix-encoding-pragma | flynt | identity +| insert-license | isort | lint-chart-schema | lint-css | lint-dockerfile |              +lint-helm-chart | lint-javascript | lint-json-schema | lint-markdown | lint-openapi |    +mixed-line-ending | pretty-format-json | pydocstyle | python-no-log-warn | pyupgrade |   +replace-bad-characters | rst-backticks | run-flake8 | run-mypy | run-shellcheck |        +static-check-autoflake | trailing-whitespace | ts-compile-and-lint-javascript |          +update-breeze-cmd-output | update-breeze-readme-config-hash | update-extras |            +update-in-the-wild-to-be-sorted | update-inlined-dockerfile-scripts |                    +update-local-yml-file | update-migration-references | update-providers-dependencies |    +update-setup-cfg-file | update-spelling-wordlist-to-be-sorted |                          +update-supported-versions | update-vendored-in-k8s-json-schema | update-version |        +yamllint | yesqa)                                                                        +--file-fList of files to run the checks on.(PATH) +--all-files-aRun checks on all files. +--show-diff-on-failure-sShow diff for files modified by the checks. +--last-commit-cRun checks for all files in last commit. Mutually exclusive with --commit-ref. +--commit-ref-rRun checks for this commit reference only (can be any git commit-ish reference).         +Mutually exclusive with --last-commit.                                                   +(TEXT)                                                                                   +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Common options ─────────────────────────────────────────────────────────────────────────────────────────────────────╮ +--verbose-vPrint verbose information about performed steps. +--dry-run-DIf dry-run is set, commands are only printed, not executed. +--github-repository-gGitHub repository used to pull, push run images.(TEXT)[default: apache/airflow] +--help-hShow this message and exit. +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ diff --git a/tests/models/test_baseoperator.py b/tests/models/test_baseoperator.py index fe3b349dc4d84..1bda88b4973f5 100644 --- a/tests/models/test_baseoperator.py +++ b/tests/models/test_baseoperator.py @@ -26,7 +26,7 @@ import pytest from airflow.decorators import task as task_decorator -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, RemovedInAirflow3Warning from airflow.lineage.entities import File from airflow.models import DAG from airflow.models.baseoperator import BaseOperator, BaseOperatorMeta, chain, cross_downstream @@ -143,7 +143,7 @@ def test_illegal_args(self): """ msg = r'Invalid arguments were passed to BaseOperator \(task_id: test_illegal_args\)' with conf_vars({('operators', 'allow_illegal_arguments'): 'True'}): - with pytest.warns(PendingDeprecationWarning, match=msg): + with pytest.warns(RemovedInAirflow3Warning, match=msg): BaseOperator( task_id='test_illegal_args', illegal_argument_1234='hello?',