This is an automated email from the ASF dual-hosted git repository.
ash pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-0-test by this push:
new 041128b6d13 [v3-0-test] Upgrade ruff to latest version (0.12.1)
(#52562) (#54406)
041128b6d13 is described below
commit 041128b6d138d60974fef7bd6a33839260476a13
Author: Ash Berlin-Taylor <[email protected]>
AuthorDate: Wed Aug 13 06:42:54 2025 +0100
[v3-0-test] Upgrade ruff to latest version (0.12.1) (#52562) (#54406)
---
.pre-commit-config.yaml | 4 +-
.../src/airflow/utils/log/logging_mixin.py | 6 +-
.../tests/unit/always/test_providers_manager.py | 10 +-
.../versions/head/test_task_instances.py | 2 +-
airflow-core/tests/unit/core/test_configuration.py | 49 ++---
airflow-core/tests/unit/datasets/test_dataset.py | 7 +-
.../tests/unit/listeners/test_listeners.py | 12 +-
.../tests/unit/models/test_taskinstance.py | 6 +-
airflow-core/tests/unit/models/test_timestamp.py | 4 +-
airflow-core/tests/unit/utils/test_warnings.py | 2 +-
devel-common/pyproject.toml | 2 +-
.../airflow_aux/test_container_lifecycle.py | 3 +
.../airflow_aux/test_pod_template_file.py | 3 +
.../amazon/tests/unit/amazon/aws/hooks/test_eks.py | 3 +
.../amazon/aws/utils/test_connection_wrapper.py | 2 +-
.../unit/celery/executors/test_celery_executor.py | 2 +-
.../executors/test_kubernetes_executor.py | 2 +-
.../unit/databricks/hooks/test_databricks_sql.py | 3 +
.../tests/unit/google/cloud/hooks/test_bigquery.py | 34 ++--
.../cloud/hooks/vertex_ai/test_generative_model.py | 2 +-
.../unit/google/cloud/operators/test_automl.py | 4 +-
.../unit/google/cloud/operators/test_bigquery.py | 220 +++++++++++----------
.../google/cloud/operators/test_life_sciences.py | 8 +-
.../operators/vertex_ai/test_generative_model.py | 3 +
.../unit/microsoft/azure/operators/test_msgraph.py | 54 ++---
.../unit/microsoft/azure/sensors/test_msgraph.py | 28 +--
.../slack/tests/unit/slack/hooks/test_slack.py | 6 +-
.../tests/unit/slack/hooks/test_slack_webhook.py | 6 +-
.../tests/unit/standard/decorators/test_bash.py | 4 +-
.../tests/unit/standard/decorators/test_python.py | 20 +-
.../tests/unit/standard/operators/test_python.py | 16 +-
.../tests/unit/standard/sensors/test_time_delta.py | 8 +-
task-sdk/pyproject.toml | 2 +-
.../src/airflow/sdk/execution_time/supervisor.py | 10 +-
task-sdk/tests/task_sdk/bases/test_operator.py | 16 +-
task-sdk/tests/task_sdk/definitions/test_asset.py | 2 +-
36 files changed, 297 insertions(+), 268 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9af2a51d886..ddb84dc46bd 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -409,7 +409,7 @@ repos:
types_or: [python, pyi]
args: [--fix]
require_serial: true
- additional_dependencies: ['ruff==0.11.13']
+ additional_dependencies: ['ruff==0.12.1']
exclude:
^airflow-core/tests/unit/dags/test_imports\.py$|^performance/tests/test_.*\.py$
- id: ruff-format
name: Run 'ruff format'
@@ -419,7 +419,7 @@ repos:
types_or: [python, pyi]
args: []
require_serial: true
- additional_dependencies: ['ruff==0.11.13']
+ additional_dependencies: ['ruff==0.12.1']
exclude: ^airflow-core/tests/unit/dags/test_imports\.py$
- id: replace-bad-characters
name: Replace bad characters
diff --git a/airflow-core/src/airflow/utils/log/logging_mixin.py
b/airflow-core/src/airflow/utils/log/logging_mixin.py
index 2e22c6999cb..1b3e24442df 100644
--- a/airflow-core/src/airflow/utils/log/logging_mixin.py
+++ b/airflow-core/src/airflow/utils/log/logging_mixin.py
@@ -24,7 +24,7 @@ import re
import sys
from io import TextIOBase, UnsupportedOperation
from logging import Handler, StreamHandler
-from typing import IO, TYPE_CHECKING, Any, Optional, TypeVar, cast
+from typing import IO, TYPE_CHECKING, Any, TypeVar, cast
if TYPE_CHECKING:
from logging import Logger
@@ -72,9 +72,9 @@ class LoggingMixin:
# Parent logger used by this class. It should match one of the loggers
defined in the
# `logging_config_class`. By default, this attribute is used to create the
final name of the logger, and
# will prefix the `_logger_name` with a separating dot.
- _log_config_logger_name: Optional[str] = None # noqa: UP007
+ _log_config_logger_name: str | None = None
- _logger_name: Optional[str] = None # noqa: UP007
+ _logger_name: str | None = None
def __init__(self, context=None):
self._set_context(context)
diff --git a/airflow-core/tests/unit/always/test_providers_manager.py
b/airflow-core/tests/unit/always/test_providers_manager.py
index 933e5b40764..c69660b4990 100644
--- a/airflow-core/tests/unit/always/test_providers_manager.py
+++ b/airflow-core/tests/unit/always/test_providers_manager.py
@@ -72,12 +72,12 @@ class TestProviderManager:
assert self._caplog.records == []
def test_hooks_deprecation_warnings_generated(self):
+ providers_manager = ProvidersManager()
+ providers_manager._provider_dict["test-package"] = ProviderInfo(
+ version="0.0.1",
+ data={"hook-class-names":
["airflow.providers.sftp.hooks.sftp.SFTPHook"]},
+ )
with pytest.warns(expected_warning=DeprecationWarning,
match="hook-class-names") as warning_records:
- providers_manager = ProvidersManager()
- providers_manager._provider_dict["test-package"] = ProviderInfo(
- version="0.0.1",
- data={"hook-class-names":
["airflow.providers.sftp.hooks.sftp.SFTPHook"]},
- )
providers_manager._discover_hooks()
assert warning_records
diff --git
a/airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py
b/airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py
index 4f1e28a11f6..d18b18b673e 100644
---
a/airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py
+++
b/airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py
@@ -1911,7 +1911,7 @@ class TestGetTaskStates:
},
}
- def test_get_task_group_states_with_logical_dates(self, client, session,
dag_maker, serialized=True):
+ def test_get_task_group_states_with_logical_dates(self, client, session,
dag_maker):
with dag_maker("test_get_task_group_states_with_logical_dates",
serialized=True):
with TaskGroup("group1"):
EmptyOperator(task_id="task1")
diff --git a/airflow-core/tests/unit/core/test_configuration.py
b/airflow-core/tests/unit/core/test_configuration.py
index 4c3ceaad049..0408152d80d 100644
--- a/airflow-core/tests/unit/core/test_configuration.py
+++ b/airflow-core/tests/unit/core/test_configuration.py
@@ -1040,11 +1040,14 @@ class TestDeprecatedConf:
# Remove it so we are sure we use the right setting
conf.remove_option("celery", "worker_concurrency")
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(DeprecationWarning, match="celeryd_concurrency"):
with mock.patch.dict("os.environ",
AIRFLOW__CELERY__CELERYD_CONCURRENCY="99"):
assert conf.getint("celery", "worker_concurrency") == 99
- with pytest.warns(DeprecationWarning), conf_vars({("celery",
"celeryd_concurrency"): "99"}):
+ with (
+ pytest.warns(DeprecationWarning, match="celeryd_concurrency"),
+ conf_vars({("celery", "celeryd_concurrency"): "99"}),
+ ):
assert conf.getint("celery", "worker_concurrency") == 99
@pytest.mark.parametrize(
@@ -1109,13 +1112,13 @@ class TestDeprecatedConf:
):
conf.remove_option("celery", "result_backend")
with conf_vars({("celery", "celery_result_backend_cmd"):
"/bin/echo 99"}):
- with pytest.warns(DeprecationWarning):
- tmp = None
- if "AIRFLOW__CELERY__RESULT_BACKEND" in os.environ:
- tmp = os.environ.pop("AIRFLOW__CELERY__RESULT_BACKEND")
+ tmp = None
+ if "AIRFLOW__CELERY__RESULT_BACKEND" in os.environ:
+ tmp = os.environ.pop("AIRFLOW__CELERY__RESULT_BACKEND")
+ with pytest.warns(DeprecationWarning, match="result_backend"):
assert conf.getint("celery", "result_backend") == 99
- if tmp:
- os.environ["AIRFLOW__CELERY__RESULT_BACKEND"] = tmp
+ if tmp:
+ os.environ["AIRFLOW__CELERY__RESULT_BACKEND"] = tmp
def test_deprecated_values_from_conf(self):
test_conf = AirflowConfigParser(
@@ -1135,7 +1138,7 @@ sql_alchemy_conn=sqlite://test
with pytest.warns(FutureWarning):
test_conf.validate()
- assert test_conf.get("core", "hostname_callable") ==
"airflow.utils.net.getfqdn"
+ assert test_conf.get("core", "hostname_callable") ==
"airflow.utils.net.getfqdn"
@pytest.mark.parametrize(
"old, new",
@@ -1160,19 +1163,19 @@ sql_alchemy_conn=sqlite://test
old_env_var = test_conf._env_var_name(old_section, old_key)
new_env_var = test_conf._env_var_name(new_section, new_key)
- with pytest.warns(FutureWarning):
- with mock.patch.dict("os.environ", **{old_env_var: old_value}):
- # Can't start with the new env var existing...
- os.environ.pop(new_env_var, None)
+ with mock.patch.dict("os.environ", **{old_env_var: old_value}):
+ # Can't start with the new env var existing...
+ os.environ.pop(new_env_var, None)
+ with pytest.warns(FutureWarning):
test_conf.validate()
- assert test_conf.get(new_section, new_key) == new_value
- # We also need to make sure the deprecated env var is removed
- # so that any subprocesses don't use it in place of our updated
- # value.
- assert old_env_var not in os.environ
- # and make sure we track the old value as well, under the new
section/key
- assert test_conf.upgraded_values[(new_section, new_key)] ==
old_value
+ assert test_conf.get(new_section, new_key) == new_value
+ # We also need to make sure the deprecated env var is removed
+ # so that any subprocesses don't use it in place of our updated
+ # value.
+ assert old_env_var not in os.environ
+ # and make sure we track the old value as well, under the new
section/key
+ assert test_conf.upgraded_values[(new_section, new_key)] ==
old_value
@pytest.mark.parametrize(
"conf_dict",
@@ -1200,10 +1203,10 @@ sql_alchemy_conn=sqlite://test
test_conf.validate()
return test_conf
- with pytest.warns(FutureWarning):
- with mock.patch.dict("os.environ",
AIRFLOW__CORE__HOSTNAME_CALLABLE="airflow.utils.net:getfqdn"):
+ with mock.patch.dict("os.environ",
AIRFLOW__CORE__HOSTNAME_CALLABLE="airflow.utils.net:getfqdn"):
+ with pytest.warns(FutureWarning):
test_conf = make_config()
- assert test_conf.get("core", "hostname_callable") ==
"airflow.utils.net.getfqdn"
+ assert test_conf.get("core", "hostname_callable") ==
"airflow.utils.net.getfqdn"
with reset_warning_registry():
with warnings.catch_warnings(record=True) as warning:
diff --git a/airflow-core/tests/unit/datasets/test_dataset.py
b/airflow-core/tests/unit/datasets/test_dataset.py
index 44e62839fa9..06c22ac4f28 100644
--- a/airflow-core/tests/unit/datasets/test_dataset.py
+++ b/airflow-core/tests/unit/datasets/test_dataset.py
@@ -68,11 +68,14 @@ import pytest
),
)
def test_backward_compat_import_before_airflow_3_2(module_path, attr_name,
warning_message):
- with pytest.warns() as record:
- import importlib
+ import importlib
+ with pytest.warns() as record:
mod = importlib.import_module(module_path, __name__)
getattr(mod, attr_name)
assert record[0].category is DeprecationWarning
assert str(record[0].message) == warning_message
+
+
+# ruff: noqa: PT031
diff --git a/airflow-core/tests/unit/listeners/test_listeners.py
b/airflow-core/tests/unit/listeners/test_listeners.py
index 3fceaaf0843..9a4c85cb504 100644
--- a/airflow-core/tests/unit/listeners/test_listeners.py
+++ b/airflow-core/tests/unit/listeners/test_listeners.py
@@ -69,7 +69,7 @@ def clean_listener_manager():
@provide_session
-def test_listener_gets_calls(create_task_instance, session=None):
+def test_listener_gets_calls(create_task_instance, session):
lm = get_listener_manager()
lm.add_listener(full_listener)
@@ -84,7 +84,7 @@ def test_listener_gets_calls(create_task_instance,
session=None):
@provide_session
-def test_multiple_listeners(create_task_instance, session=None):
+def test_multiple_listeners(create_task_instance, session):
lm = get_listener_manager()
lm.add_listener(full_listener)
lm.add_listener(lifecycle_listener)
@@ -105,7 +105,7 @@ def test_multiple_listeners(create_task_instance,
session=None):
@provide_session
-def test_listener_gets_only_subscribed_calls(create_task_instance,
session=None):
+def test_listener_gets_only_subscribed_calls(create_task_instance, session):
lm = get_listener_manager()
lm.add_listener(partial_listener)
@@ -130,7 +130,7 @@ def
test_listener_suppresses_exceptions(create_task_instance, session, cap_struc
@provide_session
-def
test_listener_captures_failed_taskinstances(create_task_instance_of_operator,
session=None):
+def
test_listener_captures_failed_taskinstances(create_task_instance_of_operator,
session):
lm = get_listener_manager()
lm.add_listener(full_listener)
@@ -145,7 +145,7 @@ def
test_listener_captures_failed_taskinstances(create_task_instance_of_operator
@provide_session
-def
test_listener_captures_longrunning_taskinstances(create_task_instance_of_operator,
session=None):
+def
test_listener_captures_longrunning_taskinstances(create_task_instance_of_operator,
session):
lm = get_listener_manager()
lm.add_listener(full_listener)
@@ -159,7 +159,7 @@ def
test_listener_captures_longrunning_taskinstances(create_task_instance_of_ope
@provide_session
-def test_class_based_listener(create_task_instance, session=None):
+def test_class_based_listener(create_task_instance, session):
lm = get_listener_manager()
listener = class_listener.ClassBasedListener()
lm.add_listener(listener)
diff --git a/airflow-core/tests/unit/models/test_taskinstance.py
b/airflow-core/tests/unit/models/test_taskinstance.py
index cb2ab917a23..5d46281dbbe 100644
--- a/airflow-core/tests/unit/models/test_taskinstance.py
+++ b/airflow-core/tests/unit/models/test_taskinstance.py
@@ -402,7 +402,7 @@ class TestTaskInstance:
)
@provide_session
- def test_ti_updates_with_task(self, create_task_instance, session=None):
+ def test_ti_updates_with_task(self, create_task_instance, session):
"""
test that updating the executor_config propagates to the TaskInstance
DB
"""
@@ -1261,7 +1261,7 @@ class TestTaskInstance:
)
@provide_session
def test_are_dependents_done(
- self, downstream_ti_state, expected_are_dependents_done,
create_task_instance, session=None
+ self, downstream_ti_state, expected_are_dependents_done,
create_task_instance, session
):
ti = create_task_instance(session=session)
dag = ti.task.dag
@@ -2280,7 +2280,7 @@ class TestTaskInstance:
ti.task.render_template('{{ var.json.get("missing_variable") }}',
context)
@provide_session
- def test_handle_failure(self, create_dummy_dag, session=None):
+ def test_handle_failure(self, create_dummy_dag, session):
start_date = timezone.datetime(2016, 6, 1)
clear_db_runs()
diff --git a/airflow-core/tests/unit/models/test_timestamp.py
b/airflow-core/tests/unit/models/test_timestamp.py
index 912347c602e..5aaa956829d 100644
--- a/airflow-core/tests/unit/models/test_timestamp.py
+++ b/airflow-core/tests/unit/models/test_timestamp.py
@@ -54,7 +54,7 @@ def add_log(execdate, session, dag_maker,
timezone_override=None):
@provide_session
-def test_timestamp_behaviour(dag_maker, session=None):
+def test_timestamp_behaviour(dag_maker, session):
execdate = timezone.utcnow()
with time_machine.travel(execdate, tick=False):
current_time = timezone.utcnow()
@@ -66,7 +66,7 @@ def test_timestamp_behaviour(dag_maker, session=None):
@provide_session
-def test_timestamp_behaviour_with_timezone(dag_maker, session=None):
+def test_timestamp_behaviour_with_timezone(dag_maker, session):
execdate = timezone.utcnow()
with time_machine.travel(execdate, tick=False):
current_time = timezone.utcnow()
diff --git a/airflow-core/tests/unit/utils/test_warnings.py
b/airflow-core/tests/unit/utils/test_warnings.py
index 666e565d796..642a4e58127 100644
--- a/airflow-core/tests/unit/utils/test_warnings.py
+++ b/airflow-core/tests/unit/utils/test_warnings.py
@@ -38,7 +38,7 @@ class TestCaptureWithReraise:
assert cw == []
def test_capture_warnings(self):
- with pytest.warns(UserWarning, match="(Foo|Bar|Baz)") as ctx:
+ with pytest.warns(UserWarning, match="(Foo|Bar|Baz)") as ctx: # noqa:
PT031
with capture_with_reraise() as cw:
self.raise_warnings()
assert len(cw) == 3
diff --git a/devel-common/pyproject.toml b/devel-common/pyproject.toml
index e538a27fc55..5452350e8df 100644
--- a/devel-common/pyproject.toml
+++ b/devel-common/pyproject.toml
@@ -35,7 +35,7 @@ dependencies = [
"kgb>=7.2.0",
"requests_mock>=1.11.0",
"rich>=13.6.0",
- "ruff==0.11.2",
+ "ruff==0.12.1",
"semver>=3.0.2",
"time-machine>=2.13.0",
"wheel>=0.42.0",
diff --git
a/helm-tests/tests/helm_tests/airflow_aux/test_container_lifecycle.py
b/helm-tests/tests/helm_tests/airflow_aux/test_container_lifecycle.py
index 77e8cb09a33..440dc68b4da 100644
--- a/helm-tests/tests/helm_tests/airflow_aux/test_container_lifecycle.py
+++ b/helm-tests/tests/helm_tests/airflow_aux/test_container_lifecycle.py
@@ -223,3 +223,6 @@ class TestContainerLifecycleHooks:
assert lifecycle_hook_params["lifecycle_parsed"] ==
jmespath.search(
f"spec.template.spec.containers[1].lifecycle.{hook_type}", doc
)
+
+
+# ruff: noqa: PT028
diff --git a/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py
b/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py
index 71bfa306eb5..0eaa94f358c 100644
--- a/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py
+++ b/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py
@@ -1092,3 +1092,6 @@ class TestPodTemplateFile:
scheduler_env = jmespath.search("spec.containers[0].env[*].name",
docs[0])
assert set(["KRB5_CONFIG", "KRB5CCNAME"]).issubset(scheduler_env)
+
+
+# ruff: noqa: PT028
diff --git a/providers/amazon/tests/unit/amazon/aws/hooks/test_eks.py
b/providers/amazon/tests/unit/amazon/aws/hooks/test_eks.py
index ed95a4f75e5..ebd45661cd3 100644
--- a/providers/amazon/tests/unit/amazon/aws/hooks/test_eks.py
+++ b/providers/amazon/tests/unit/amazon/aws/hooks/test_eks.py
@@ -1360,3 +1360,6 @@ def assert_is_valid_uri(value: str) -> None:
assert all([result.scheme, result.netloc, result.path])
assert REGION in value
+
+
+# ruff: noqa: PT028
diff --git
a/providers/amazon/tests/unit/amazon/aws/utils/test_connection_wrapper.py
b/providers/amazon/tests/unit/amazon/aws/utils/test_connection_wrapper.py
index 02275cccaea..796d1057241 100644
--- a/providers/amazon/tests/unit/amazon/aws/utils/test_connection_wrapper.py
+++ b/providers/amazon/tests/unit/amazon/aws/utils/test_connection_wrapper.py
@@ -120,7 +120,7 @@ class TestAwsConnectionWrapper:
warning_message = f"expected connection type 'aws', got '{conn_type}'"
with pytest.warns(UserWarning, match=warning_message):
wrap_conn =
AwsConnectionWrapper(conn=mock_connection_factory(conn_type=conn_type))
- assert wrap_conn.conn_type == conn_type
+ assert wrap_conn.conn_type == conn_type
@pytest.mark.parametrize("aws_session_token", [None,
"mock-aws-session-token"])
@pytest.mark.parametrize("aws_secret_access_key",
["mock-aws-secret-access-key"])
diff --git
a/providers/celery/tests/unit/celery/executors/test_celery_executor.py
b/providers/celery/tests/unit/celery/executors/test_celery_executor.py
index 22dbd59a914..715bdda8649 100644
--- a/providers/celery/tests/unit/celery/executors/test_celery_executor.py
+++ b/providers/celery/tests/unit/celery/executors/test_celery_executor.py
@@ -260,7 +260,7 @@ class TestCeleryExecutor:
executor.running = {ti.key}
executor.tasks = {ti.key: AsyncResult("231")}
assert executor.has_task(ti)
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(DeprecationWarning,
match="cleanup_stuck_queued_tasks"):
executor.cleanup_stuck_queued_tasks(tis=tis)
executor.sync()
assert executor.tasks == {}
diff --git
a/providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py
b/providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py
index b1d1585d012..3c1de234f98 100644
---
a/providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py
+++
b/providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py
@@ -1259,7 +1259,7 @@ class TestKubernetesExecutor:
executor.kube_scheduler = mock.MagicMock()
ti.refresh_from_db()
tis = [ti]
- with pytest.warns(DeprecationWarning):
+ with pytest.warns(DeprecationWarning,
match="cleanup_stuck_queued_tasks"):
executor.cleanup_stuck_queued_tasks(tis=tis)
executor.kube_scheduler.delete_pod.assert_called_once()
assert executor.running == set()
diff --git
a/providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py
b/providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py
index 34284213810..8fa51e6bd80 100644
--- a/providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py
+++ b/providers/databricks/tests/unit/databricks/hooks/test_databricks_sql.py
@@ -435,3 +435,6 @@ def test_create_timeout_thread_no_timeout(
thread = create_timeout_thread(cur=cur, execution_timeout=None)
mock_timer.assert_not_called()
assert thread is None
+
+
+# ruff: noqa: PT028
diff --git a/providers/google/tests/unit/google/cloud/hooks/test_bigquery.py
b/providers/google/tests/unit/google/cloud/hooks/test_bigquery.py
index 45eb7cf2d68..e35d87b2536 100644
--- a/providers/google/tests/unit/google/cloud/hooks/test_bigquery.py
+++ b/providers/google/tests/unit/google/cloud/hooks/test_bigquery.py
@@ -829,7 +829,7 @@ class TestTableOperations(_BigQueryBaseTestClass):
view=view,
retry=DEFAULT_RETRY,
)
- assert_warning("create_empty_table", warnings)
+ assert_warning("create_empty_table", warnings)
body = {"tableReference": TABLE_REFERENCE_REPR, "view": view}
mock_table.from_api_repr.assert_called_once_with(body)
@@ -868,7 +868,7 @@ class TestTableOperations(_BigQueryBaseTestClass):
def test_create_empty_table_succeed(self, mock_bq_client, mock_table):
with pytest.warns(AirflowProviderDeprecationWarning) as warnings:
self.hook.create_empty_table(project_id=PROJECT_ID,
dataset_id=DATASET_ID, table_id=TABLE_ID)
- assert_warning("create_empty_table", warnings)
+ assert_warning("create_empty_table", warnings)
body = {
"tableReference": {
@@ -921,22 +921,22 @@ class TestTableOperations(_BigQueryBaseTestClass):
time_partitioning=time_partitioning,
cluster_fields=cluster_fields,
)
- assert_warning("create_empty_table", warnings)
+ assert_warning("create_empty_table", warnings)
- body = {
- "tableReference": {
- "tableId": TABLE_ID,
- "projectId": PROJECT_ID,
- "datasetId": DATASET_ID,
- },
- "schema": {"fields": schema_fields},
- "timePartitioning": time_partitioning,
- "clustering": {"fields": cluster_fields},
- }
- mock_table.from_api_repr.assert_called_once_with(body)
- mock_bq_client.return_value.create_table.assert_called_once_with(
- table=mock_table.from_api_repr.return_value, exists_ok=True,
retry=DEFAULT_RETRY
- )
+ body = {
+ "tableReference": {
+ "tableId": TABLE_ID,
+ "projectId": PROJECT_ID,
+ "datasetId": DATASET_ID,
+ },
+ "schema": {"fields": schema_fields},
+ "timePartitioning": time_partitioning,
+ "clustering": {"fields": cluster_fields},
+ }
+ mock_table.from_api_repr.assert_called_once_with(body)
+ mock_bq_client.return_value.create_table.assert_called_once_with(
+ table=mock_table.from_api_repr.return_value, exists_ok=True,
retry=DEFAULT_RETRY
+ )
@mock.patch("airflow.providers.google.cloud.hooks.bigquery.Table.from_api_repr")
@mock.patch("airflow.providers.google.cloud.hooks.bigquery.Client")
diff --git
a/providers/google/tests/unit/google/cloud/hooks/vertex_ai/test_generative_model.py
b/providers/google/tests/unit/google/cloud/hooks/vertex_ai/test_generative_model.py
index 3987f35b183..5cb3cd5378a 100644
---
a/providers/google/tests/unit/google/cloud/hooks/vertex_ai/test_generative_model.py
+++
b/providers/google/tests/unit/google/cloud/hooks/vertex_ai/test_generative_model.py
@@ -161,7 +161,7 @@ class TestGenerativeModelWithDefaultProjectIdHook:
top_p=TEST_TOP_P,
top_k=TEST_TOP_K,
)
- assert_warning("generative_model_generate_content", warnings)
+ assert_warning("generative_model_generate_content", warnings)
@mock.patch(GENERATIVE_MODEL_STRING.format("GenerativeModelHook.get_text_embedding_model"))
def test_text_embedding_model_get_embeddings(self, mock_model) -> None:
diff --git a/providers/google/tests/unit/google/cloud/operators/test_automl.py
b/providers/google/tests/unit/google/cloud/operators/test_automl.py
index 7ae70c83c9e..c8d42d3327e 100644
--- a/providers/google/tests/unit/google/cloud/operators/test_automl.py
+++ b/providers/google/tests/unit/google/cloud/operators/test_automl.py
@@ -194,7 +194,9 @@ class TestAutoMLPredictOperator:
task_id=TASK_ID,
operation_params={"TEST_KEY": "TEST_VALUE"},
)
+ with pytest.warns(AirflowProviderDeprecationWarning):
assert isinstance(op.hook, CloudAutoMLHook)
+ with pytest.warns(AirflowProviderDeprecationWarning):
op = AutoMLPredictOperator(
endpoint_id="endpoint_id",
location=GCP_LOCATION,
@@ -203,7 +205,7 @@ class TestAutoMLPredictOperator:
task_id=TASK_ID,
operation_params={"TEST_KEY": "TEST_VALUE"},
)
- assert isinstance(op.hook, PredictionServiceHook)
+ assert isinstance(op.hook, PredictionServiceHook)
class TestAutoMLCreateImportOperator:
diff --git
a/providers/google/tests/unit/google/cloud/operators/test_bigquery.py
b/providers/google/tests/unit/google/cloud/operators/test_bigquery.py
index 63d687227e6..15568d18b84 100644
--- a/providers/google/tests/unit/google/cloud/operators/test_bigquery.py
+++ b/providers/google/tests/unit/google/cloud/operators/test_bigquery.py
@@ -356,7 +356,7 @@ class TestBigQueryCreateEmptyTableOperator:
project_id=TEST_GCP_PROJECT_ID,
table_id=TEST_TABLE_ID,
)
- assert_warning("BigQueryCreateEmptyTableOperator", warnings)
+ assert_warning("BigQueryCreateEmptyTableOperator", warnings)
@mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook")
def test_execute(self, mock_hook):
@@ -367,21 +367,22 @@ class TestBigQueryCreateEmptyTableOperator:
project_id=TEST_GCP_PROJECT_ID,
table_id=TEST_TABLE_ID,
)
- operator.execute(context=MagicMock())
- mock_hook.return_value.create_empty_table.assert_called_once_with(
- dataset_id=TEST_DATASET,
- project_id=TEST_GCP_PROJECT_ID,
- table_id=TEST_TABLE_ID,
- schema_fields=None,
- time_partitioning={},
- cluster_fields=None,
- labels=None,
- view=None,
- materialized_view=None,
- encryption_configuration=None,
- table_resource=None,
- exists_ok=False,
- )
+ operator.execute(context=MagicMock())
+
+ mock_hook.return_value.create_empty_table.assert_called_once_with(
+ dataset_id=TEST_DATASET,
+ project_id=TEST_GCP_PROJECT_ID,
+ table_id=TEST_TABLE_ID,
+ schema_fields=None,
+ time_partitioning={},
+ cluster_fields=None,
+ labels=None,
+ view=None,
+ materialized_view=None,
+ encryption_configuration=None,
+ table_resource=None,
+ exists_ok=False,
+ )
@mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook")
def test_create_view(self, mock_hook):
@@ -393,21 +394,23 @@ class TestBigQueryCreateEmptyTableOperator:
table_id=TEST_TABLE_ID,
view=VIEW_DEFINITION,
)
- operator.execute(context=MagicMock())
- mock_hook.return_value.create_empty_table.assert_called_once_with(
- dataset_id=TEST_DATASET,
- project_id=TEST_GCP_PROJECT_ID,
- table_id=TEST_TABLE_ID,
- schema_fields=None,
- time_partitioning={},
- cluster_fields=None,
- labels=None,
- view=VIEW_DEFINITION,
- materialized_view=None,
- encryption_configuration=None,
- table_resource=None,
- exists_ok=False,
- )
+
+ operator.execute(context=MagicMock())
+
+ mock_hook.return_value.create_empty_table.assert_called_once_with(
+ dataset_id=TEST_DATASET,
+ project_id=TEST_GCP_PROJECT_ID,
+ table_id=TEST_TABLE_ID,
+ schema_fields=None,
+ time_partitioning={},
+ cluster_fields=None,
+ labels=None,
+ view=VIEW_DEFINITION,
+ materialized_view=None,
+ encryption_configuration=None,
+ table_resource=None,
+ exists_ok=False,
+ )
@mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook")
def test_create_materialized_view(self, mock_hook):
@@ -420,21 +423,22 @@ class TestBigQueryCreateEmptyTableOperator:
materialized_view=MATERIALIZED_VIEW_DEFINITION,
)
- operator.execute(context=MagicMock())
- mock_hook.return_value.create_empty_table.assert_called_once_with(
- dataset_id=TEST_DATASET,
- project_id=TEST_GCP_PROJECT_ID,
- table_id=TEST_TABLE_ID,
- schema_fields=None,
- time_partitioning={},
- cluster_fields=None,
- labels=None,
- view=None,
- materialized_view=MATERIALIZED_VIEW_DEFINITION,
- encryption_configuration=None,
- table_resource=None,
- exists_ok=False,
- )
+ operator.execute(context=MagicMock())
+
+ mock_hook.return_value.create_empty_table.assert_called_once_with(
+ dataset_id=TEST_DATASET,
+ project_id=TEST_GCP_PROJECT_ID,
+ table_id=TEST_TABLE_ID,
+ schema_fields=None,
+ time_partitioning={},
+ cluster_fields=None,
+ labels=None,
+ view=None,
+ materialized_view=MATERIALIZED_VIEW_DEFINITION,
+ encryption_configuration=None,
+ table_resource=None,
+ exists_ok=False,
+ )
@mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook")
def test_create_clustered_empty_table(self, mock_hook):
@@ -456,21 +460,21 @@ class TestBigQueryCreateEmptyTableOperator:
cluster_fields=cluster_fields,
)
- operator.execute(context=MagicMock())
- mock_hook.return_value.create_empty_table.assert_called_once_with(
- dataset_id=TEST_DATASET,
- project_id=TEST_GCP_PROJECT_ID,
- table_id=TEST_TABLE_ID,
- schema_fields=schema_fields,
- time_partitioning=time_partitioning,
- cluster_fields=cluster_fields,
- labels=None,
- view=None,
- materialized_view=None,
- encryption_configuration=None,
- table_resource=None,
- exists_ok=False,
- )
+ operator.execute(context=MagicMock())
+ mock_hook.return_value.create_empty_table.assert_called_once_with(
+ dataset_id=TEST_DATASET,
+ project_id=TEST_GCP_PROJECT_ID,
+ table_id=TEST_TABLE_ID,
+ schema_fields=schema_fields,
+ time_partitioning=time_partitioning,
+ cluster_fields=cluster_fields,
+ labels=None,
+ view=None,
+ materialized_view=None,
+ encryption_configuration=None,
+ table_resource=None,
+ exists_ok=False,
+ )
@pytest.mark.parametrize(
"if_exists, is_conflict, expected_error, log_msg",
@@ -495,17 +499,17 @@ class TestBigQueryCreateEmptyTableOperator:
view=VIEW_DEFINITION,
if_exists=if_exists,
)
- if is_conflict:
- mock_hook.return_value.create_empty_table.side_effect =
Conflict("any")
- else:
- mock_hook.return_value.create_empty_table.side_effect = None
- if expected_error is not None:
- with pytest.raises(expected_error):
- operator.execute(context=MagicMock())
- else:
+ if is_conflict:
+ mock_hook.return_value.create_empty_table.side_effect =
Conflict("any")
+ else:
+ mock_hook.return_value.create_empty_table.side_effect = None
+ if expected_error is not None:
+ with pytest.raises(expected_error):
operator.execute(context=MagicMock())
- if log_msg is not None:
- assert log_msg in caplog.text
+ else:
+ operator.execute(context=MagicMock())
+ if log_msg is not None:
+ assert log_msg in caplog.text
@mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook")
def test_get_openlineage_facets_on_complete(self, mock_hook):
@@ -531,22 +535,22 @@ class TestBigQueryCreateEmptyTableOperator:
table_id=TEST_TABLE_ID,
schema_fields=schema_fields,
)
- operator.execute(context=MagicMock())
+ operator.execute(context=MagicMock())
- mock_hook.return_value.create_empty_table.assert_called_once_with(
- dataset_id=TEST_DATASET,
- project_id=TEST_GCP_PROJECT_ID,
- table_id=TEST_TABLE_ID,
- schema_fields=schema_fields,
- time_partitioning={},
- cluster_fields=None,
- labels=None,
- view=None,
- materialized_view=None,
- encryption_configuration=None,
- table_resource=None,
- exists_ok=False,
- )
+ mock_hook.return_value.create_empty_table.assert_called_once_with(
+ dataset_id=TEST_DATASET,
+ project_id=TEST_GCP_PROJECT_ID,
+ table_id=TEST_TABLE_ID,
+ schema_fields=schema_fields,
+ time_partitioning={},
+ cluster_fields=None,
+ labels=None,
+ view=None,
+ materialized_view=None,
+ encryption_configuration=None,
+ table_resource=None,
+ exists_ok=False,
+ )
result = operator.get_openlineage_facets_on_complete(None)
assert not result.run_facets
@@ -579,7 +583,7 @@ class TestBigQueryCreateExternalTableOperator:
},
},
)
- assert_warning("BigQueryCreateExternalTableOperator", warnings)
+ assert_warning("BigQueryCreateExternalTableOperator", warnings)
@mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook")
def test_execute_with_csv_format(self, mock_hook):
@@ -618,14 +622,14 @@ class TestBigQueryCreateExternalTableOperator:
table_resource=table_resource,
)
- mock_hook.return_value.split_tablename.return_value = (
- TEST_GCP_PROJECT_ID,
- TEST_DATASET,
- TEST_TABLE_ID,
- )
+ mock_hook.return_value.split_tablename.return_value = (
+ TEST_GCP_PROJECT_ID,
+ TEST_DATASET,
+ TEST_TABLE_ID,
+ )
- operator.execute(context=MagicMock())
-
mock_hook.return_value.create_empty_table.assert_called_once_with(table_resource=table_resource)
+ operator.execute(context=MagicMock())
+
mock_hook.return_value.create_empty_table.assert_called_once_with(table_resource=table_resource)
@mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook")
def test_execute_with_parquet_format(self, mock_hook):
@@ -657,14 +661,14 @@ class TestBigQueryCreateExternalTableOperator:
table_resource=table_resource,
)
- mock_hook.return_value.split_tablename.return_value = (
- TEST_GCP_PROJECT_ID,
- TEST_DATASET,
- TEST_TABLE_ID,
- )
+ mock_hook.return_value.split_tablename.return_value = (
+ TEST_GCP_PROJECT_ID,
+ TEST_DATASET,
+ TEST_TABLE_ID,
+ )
- operator.execute(context=MagicMock())
-
mock_hook.return_value.create_empty_table.assert_called_once_with(table_resource=table_resource)
+ operator.execute(context=MagicMock())
+
mock_hook.return_value.create_empty_table.assert_called_once_with(table_resource=table_resource)
@mock.patch("airflow.providers.google.cloud.operators.bigquery.BigQueryHook")
def test_get_openlineage_facets_on_complete(self, mock_hook):
@@ -697,14 +701,14 @@ class TestBigQueryCreateExternalTableOperator:
table_resource=table_resource,
)
- mock_hook.return_value.split_tablename.return_value = (
- TEST_GCP_PROJECT_ID,
- TEST_DATASET,
- TEST_TABLE_ID,
- )
+ mock_hook.return_value.split_tablename.return_value = (
+ TEST_GCP_PROJECT_ID,
+ TEST_DATASET,
+ TEST_TABLE_ID,
+ )
- operator.execute(context=MagicMock())
-
mock_hook.return_value.create_empty_table.assert_called_once_with(table_resource=table_resource)
+ operator.execute(context=MagicMock())
+
mock_hook.return_value.create_empty_table.assert_called_once_with(table_resource=table_resource)
result = operator.get_openlineage_facets_on_complete(None)
assert not result.run_facets
diff --git
a/providers/google/tests/unit/google/cloud/operators/test_life_sciences.py
b/providers/google/tests/unit/google/cloud/operators/test_life_sciences.py
index e49c428d1a4..d125bdf10dc 100644
--- a/providers/google/tests/unit/google/cloud/operators/test_life_sciences.py
+++ b/providers/google/tests/unit/google/cloud/operators/test_life_sciences.py
@@ -47,8 +47,8 @@ class TestLifeSciencesRunPipelineOperator:
operator = LifeSciencesRunPipelineOperator(
task_id="task-id", body=TEST_BODY, location=TEST_LOCATION,
project_id=TEST_PROJECT_ID
)
- context = mock.MagicMock()
- result = operator.execute(context=context)
+ context = mock.MagicMock()
+ result = operator.execute(context=context)
assert result == TEST_OPERATION
@@ -62,6 +62,6 @@ class TestLifeSciencesRunPipelineOperator:
body=TEST_BODY,
location=TEST_LOCATION,
)
- context = mock.MagicMock()
- result = operator.execute(context=context)
+ context = mock.MagicMock()
+ result = operator.execute(context=context)
assert result == TEST_OPERATION
diff --git
a/providers/google/tests/unit/google/cloud/operators/vertex_ai/test_generative_model.py
b/providers/google/tests/unit/google/cloud/operators/vertex_ai/test_generative_model.py
index 8712830c6ee..64a7002a09a 100644
---
a/providers/google/tests/unit/google/cloud/operators/vertex_ai/test_generative_model.py
+++
b/providers/google/tests/unit/google/cloud/operators/vertex_ai/test_generative_model.py
@@ -418,3 +418,6 @@ class TestVertexAIGenerateFromCachedContentOperator:
generation_config=None,
safety_settings=None,
)
+
+
+# ruff: noqa: PT031
diff --git
a/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_msgraph.py
b/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_msgraph.py
index 458171ec6f7..7315c58f9fa 100644
---
a/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_msgraph.py
+++
b/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_msgraph.py
@@ -65,17 +65,17 @@ class TestMSGraphAsyncOperator(Base):
):
results, events = execute_operator(operator)
- assert len(results) == 30
- assert results == users.get("value") + next_users.get("value")
- assert len(events) == 2
- assert isinstance(events[0], TriggerEvent)
- assert events[0].payload["status"] == "success"
- assert events[0].payload["type"] == "builtins.dict"
- assert events[0].payload["response"] == json.dumps(users)
- assert isinstance(events[1], TriggerEvent)
- assert events[1].payload["status"] == "success"
- assert events[1].payload["type"] == "builtins.dict"
- assert events[1].payload["response"] == json.dumps(next_users)
+ assert len(results) == 30
+ assert results == users.get("value") + next_users.get("value")
+ assert len(events) == 2
+ assert isinstance(events[0], TriggerEvent)
+ assert events[0].payload["status"] == "success"
+ assert events[0].payload["type"] == "builtins.dict"
+ assert events[0].payload["response"] == json.dumps(users)
+ assert isinstance(events[1], TriggerEvent)
+ assert events[1].payload["status"] == "success"
+ assert events[1].payload["type"] == "builtins.dict"
+ assert events[1].payload["response"] == json.dumps(next_users)
@pytest.mark.db_test
def test_execute_with_new_result_processor_signature(self):
@@ -128,17 +128,17 @@ class TestMSGraphAsyncOperator(Base):
):
results, events = execute_operator(operator)
- assert len(results) == 30
- assert results == users.get("value") + next_users.get("value")
- assert len(events) == 2
- assert isinstance(events[0], TriggerEvent)
- assert events[0].payload["status"] == "success"
- assert events[0].payload["type"] == "builtins.dict"
- assert events[0].payload["response"] == json.dumps(users)
- assert isinstance(events[1], TriggerEvent)
- assert events[1].payload["status"] == "success"
- assert events[1].payload["type"] == "builtins.dict"
- assert events[1].payload["response"] == json.dumps(next_users)
+ assert len(results) == 30
+ assert results == users.get("value") + next_users.get("value")
+ assert len(events) == 2
+ assert isinstance(events[0], TriggerEvent)
+ assert events[0].payload["status"] == "success"
+ assert events[0].payload["type"] == "builtins.dict"
+ assert events[0].payload["response"] == json.dumps(users)
+ assert isinstance(events[1], TriggerEvent)
+ assert events[1].payload["status"] == "success"
+ assert events[1].payload["type"] == "builtins.dict"
+ assert events[1].payload["response"] == json.dumps(next_users)
@pytest.mark.db_test
def test_execute_when_do_xcom_push_is_false(self):
@@ -200,11 +200,11 @@ class TestMSGraphAsyncOperator(Base):
):
results, events = execute_operator(operator)
- assert not results
- assert len(events) == 1
- assert isinstance(events[0], TriggerEvent)
- assert events[0].payload["status"] == "failure"
- assert events[0].payload["message"] == "An error occurred"
+ assert not results
+ assert len(events) == 1
+ assert isinstance(events[0], TriggerEvent)
+ assert events[0].payload["status"] == "failure"
+ assert events[0].payload["message"] == "An error occurred"
@pytest.mark.db_test
def
test_execute_when_an_exception_occurs_on_custom_event_handler_with_new_signature(self):
diff --git
a/providers/microsoft/azure/tests/unit/microsoft/azure/sensors/test_msgraph.py
b/providers/microsoft/azure/tests/unit/microsoft/azure/sensors/test_msgraph.py
index c73c76caffe..88289a529c2 100644
---
a/providers/microsoft/azure/tests/unit/microsoft/azure/sensors/test_msgraph.py
+++
b/providers/microsoft/azure/tests/unit/microsoft/azure/sensors/test_msgraph.py
@@ -55,20 +55,20 @@ class TestMSGraphSensor(Base):
):
results, events = execute_operator(sensor)
- assert sensor.path_parameters == {"scanId":
"0a1b1bf3-37de-48f7-9863-ed4cda97a9ef"}
- assert isinstance(results, str)
- assert results == "0a1b1bf3-37de-48f7-9863-ed4cda97a9ef"
- assert len(events) == 3
- assert isinstance(events[0], TriggerEvent)
- assert events[0].payload["status"] == "success"
- assert events[0].payload["type"] == "builtins.dict"
- assert events[0].payload["response"] == json.dumps(status[0])
- assert isinstance(events[1], TriggerEvent)
- assert isinstance(events[1].payload, datetime)
- assert isinstance(events[2], TriggerEvent)
- assert events[2].payload["status"] == "success"
- assert events[2].payload["type"] == "builtins.dict"
- assert events[2].payload["response"] == json.dumps(status[1])
+ assert sensor.path_parameters == {"scanId":
"0a1b1bf3-37de-48f7-9863-ed4cda97a9ef"}
+ assert isinstance(results, str)
+ assert results == "0a1b1bf3-37de-48f7-9863-ed4cda97a9ef"
+ assert len(events) == 3
+ assert isinstance(events[0], TriggerEvent)
+ assert events[0].payload["status"] == "success"
+ assert events[0].payload["type"] == "builtins.dict"
+ assert events[0].payload["response"] == json.dumps(status[0])
+ assert isinstance(events[1], TriggerEvent)
+ assert isinstance(events[1].payload, datetime)
+ assert isinstance(events[2], TriggerEvent)
+ assert events[2].payload["status"] == "success"
+ assert events[2].payload["type"] == "builtins.dict"
+ assert events[2].payload["response"] == json.dumps(status[1])
def test_execute_with_result_processor_with_new_signature(self):
status = load_json_from_resources(dirname(__file__), "..",
"resources", "status.json")
diff --git a/providers/slack/tests/unit/slack/hooks/test_slack.py
b/providers/slack/tests/unit/slack/hooks/test_slack.py
index 73c44f426de..9f3d74625b4 100644
--- a/providers/slack/tests/unit/slack/hooks/test_slack.py
+++ b/providers/slack/tests/unit/slack/hooks/test_slack.py
@@ -104,8 +104,8 @@ class TestSlackHook:
"""Test that we only use token from Slack API Connection ID."""
with pytest.warns(UserWarning, match="Provide `token` as part of .*
parameters is disallowed"):
hook = SlackHook(slack_conn_id=SLACK_API_DEFAULT_CONN_ID,
token="foo-bar")
- assert "token" not in hook.extra_client_args
- assert hook._get_conn_params()["token"] == MOCK_SLACK_API_TOKEN
+ assert "token" not in hook.extra_client_args
+ assert hook._get_conn_params()["token"] == MOCK_SLACK_API_TOKEN
def test_empty_password(self):
"""Test password field defined in the connection."""
@@ -323,7 +323,7 @@ class TestSlackHook:
hook = SlackHook(slack_conn_id="my_conn")
with pytest.warns(Warning, match="Using value for `timeout`"):
params = hook._get_conn_params()
- assert params["timeout"] == 222
+ assert params["timeout"] == 222
def test_empty_string_ignored_prefixed(self, monkeypatch):
monkeypatch.setenv(
diff --git a/providers/slack/tests/unit/slack/hooks/test_slack_webhook.py
b/providers/slack/tests/unit/slack/hooks/test_slack_webhook.py
index cf2d406533d..8dfa021b911 100644
--- a/providers/slack/tests/unit/slack/hooks/test_slack_webhook.py
+++ b/providers/slack/tests/unit/slack/hooks/test_slack_webhook.py
@@ -199,8 +199,8 @@ class TestSlackWebhookHook:
UserWarning, match="Provide `webhook_token` as part of .*
parameters is disallowed"
):
hook = SlackWebhookHook(slack_webhook_conn_id=TEST_CONN_ID,
webhook_token="foo-bar")
- assert "webhook_token" not in hook.extra_client_args
- assert hook._get_conn_params()["url"] == TEST_WEBHOOK_URL
+ assert "webhook_token" not in hook.extra_client_args
+ assert hook._get_conn_params()["url"] == TEST_WEBHOOK_URL
@pytest.mark.parametrize("conn_id", ["conn_token_in_host_1",
"conn_token_in_host_2"])
def test_wrong_connections(self, conn_id):
@@ -479,7 +479,7 @@ class TestSlackWebhookHook:
hook = SlackWebhookHook(slack_webhook_conn_id="my_conn")
with pytest.warns(Warning, match="Using value for `timeout`"):
params = hook._get_conn_params()
- assert params["timeout"] == 222
+ assert params["timeout"] == 222
def test_empty_string_ignored_prefixed(self):
with patch.dict(
diff --git a/providers/standard/tests/unit/standard/decorators/test_bash.py
b/providers/standard/tests/unit/standard/decorators/test_bash.py
index c5ba14e70da..f4303b345eb 100644
--- a/providers/standard/tests/unit/standard/decorators/test_bash.py
+++ b/providers/standard/tests/unit/standard/decorators/test_bash.py
@@ -412,9 +412,9 @@ class TestBashDecorator:
):
bash_task = bash()
- assert bash_task.operator.bash_command == SET_DURING_EXECUTION
+ assert bash_task.operator.bash_command == SET_DURING_EXECUTION
- ti, _ = self.execute_task(bash_task)
+ ti, _ = self.execute_task(bash_task)
assert bash_task.operator.multiple_outputs is False
self.validate_bash_command_rtif(ti, "echo")
diff --git a/providers/standard/tests/unit/standard/decorators/test_python.py
b/providers/standard/tests/unit/standard/decorators/test_python.py
index ed8d5ef0cdb..702d16ffd34 100644
--- a/providers/standard/tests/unit/standard/decorators/test_python.py
+++ b/providers/standard/tests/unit/standard/decorators/test_python.py
@@ -158,18 +158,18 @@ class TestAirflowTaskDecorator(BasePythonTest):
assert t2(5, 5).operator.multiple_outputs is True
- with pytest.warns(UserWarning, match="Cannot infer
multiple_outputs.*t3") as recwarn:
-
- @task_decorator
- def t3( # type: ignore[empty-body]
- x: "FakeTypeCheckingOnlyClass",
- y: int,
- ) -> "UnresolveableName[int, int]": ...
+ @task_decorator
+ def t3( # type: ignore[empty-body]
+ x: "FakeTypeCheckingOnlyClass",
+ y: int,
+ ) -> "UnresolveableName[int, int]": ...
+ with pytest.warns(UserWarning, match="Cannot infer
multiple_outputs.*t3") as recwarn:
line = sys._getframe().f_lineno - 5 if PY38 else
sys._getframe().f_lineno - 2
- if PY311:
- # extra line explaining the error location in Py311
- line = line - 1
+
+ if PY311:
+ # extra line explaining the error location in Py311
+ line = line - 1
warn = recwarn[0]
assert warn.filename == __file__
diff --git a/providers/standard/tests/unit/standard/operators/test_python.py
b/providers/standard/tests/unit/standard/operators/test_python.py
index 4474795afbd..c6435e3d9c1 100644
--- a/providers/standard/tests/unit/standard/operators/test_python.py
+++ b/providers/standard/tests/unit/standard/operators/test_python.py
@@ -1937,8 +1937,8 @@ class TestCurrentContext:
with set_current_context(example_context):
pass
if AIRFLOW_V_3_0_PLUS:
- with pytest.warns(AirflowProviderDeprecationWarning):
- with pytest.raises(RuntimeError):
+ with pytest.raises(RuntimeError):
+ with pytest.warns(AirflowProviderDeprecationWarning):
get_current_context()
else:
with pytest.raises(RuntimeError):
@@ -1960,13 +1960,13 @@ class TestCurrentContext:
ctx_obj.__enter__()
ctx_list.append(ctx_obj)
if AIRFLOW_V_3_0_PLUS:
- with pytest.warns(AirflowProviderDeprecationWarning):
- for i in reversed(range(max_stack_depth)):
- # Iterate over contexts in reverse order - stack is LIFO
+ for i in reversed(range(max_stack_depth)):
+ # Iterate over contexts in reverse order - stack is LIFO
+ with pytest.warns(AirflowProviderDeprecationWarning):
ctx = get_current_context()
- assert ctx["ContextId"] == i
- # End of with statement
- ctx_list[i].__exit__(None, None, None)
+ assert ctx["ContextId"] == i
+ # End of with statement
+ ctx_list[i].__exit__(None, None, None)
else:
for i in reversed(range(max_stack_depth)):
# Iterate over contexts in reverse order - stack is LIFO
diff --git a/providers/standard/tests/unit/standard/sensors/test_time_delta.py
b/providers/standard/tests/unit/standard/sensors/test_time_delta.py
index 12838f4364d..9f5239bb460 100644
--- a/providers/standard/tests/unit/standard/sensors/test_time_delta.py
+++ b/providers/standard/tests/unit/standard/sensors/test_time_delta.py
@@ -24,7 +24,7 @@ import pendulum
import pytest
import time_machine
-from airflow.exceptions import TaskDeferred
+from airflow.exceptions import AirflowProviderDeprecationWarning, TaskDeferred
from airflow.models import DagBag
from airflow.models.dag import DAG
from airflow.providers.standard.sensors.time_delta import (
@@ -118,7 +118,8 @@ class TestTimeDeltaSensorAsync:
@mock.patch(DEFER_PATH)
def test_timedelta_sensor(self, defer_mock, should_defer):
delta = timedelta(hours=1)
- op = TimeDeltaSensorAsync(task_id="timedelta_sensor_check",
delta=delta, dag=self.dag)
+ with pytest.warns(AirflowProviderDeprecationWarning):
+ op = TimeDeltaSensorAsync(task_id="timedelta_sensor_check",
delta=delta, dag=self.dag)
if should_defer:
data_interval_end = pendulum.now("UTC").add(hours=1)
else:
@@ -178,7 +179,8 @@ class TestTimeDeltaSensorAsync:
)
context.update(dag_run=dr)
delta = timedelta(seconds=1)
- op = TimeDeltaSensorAsync(task_id="wait_sensor_check",
delta=delta, dag=dag)
+ with pytest.warns(AirflowProviderDeprecationWarning):
+ op = TimeDeltaSensorAsync(task_id="wait_sensor_check",
delta=delta, dag=dag)
base_time = interval_end or run_after
expected_time = base_time + delta
with pytest.raises(TaskDeferred) as caught:
diff --git a/task-sdk/pyproject.toml b/task-sdk/pyproject.toml
index 27518a253b4..b7c6f8acbc2 100644
--- a/task-sdk/pyproject.toml
+++ b/task-sdk/pyproject.toml
@@ -135,7 +135,7 @@ codegen = [
"datamodel-code-generator[http]==0.28.2",
"openapi-spec-validator>=0.7.1",
"svcs>=25.1.0",
- "ruff==0.11.2",
+ "ruff==0.12.1",
"rich>=12.4.4",
]
dev = [
diff --git a/task-sdk/src/airflow/sdk/execution_time/supervisor.py
b/task-sdk/src/airflow/sdk/execution_time/supervisor.py
index fffa1ad1555..2145053747f 100644
--- a/task-sdk/src/airflow/sdk/execution_time/supervisor.py
+++ b/task-sdk/src/airflow/sdk/execution_time/supervisor.py
@@ -1025,11 +1025,11 @@ class ActivitySubprocess(WatchedSubprocess):
self._terminal_state = SERVER_TERMINATED
else:
# If we get any other error, we'll just log it and try again
next time
- self._handle_heartbeat_failures()
- except Exception:
- self._handle_heartbeat_failures()
+ self._handle_heartbeat_failures(e)
+ except Exception as e:
+ self._handle_heartbeat_failures(e)
- def _handle_heartbeat_failures(self):
+ def _handle_heartbeat_failures(self, exc: Exception | None):
"""Increment the failed heartbeats counter and kill the process if too
many failures."""
self.failed_heartbeats += 1
log.warning(
@@ -1037,7 +1037,7 @@ class ActivitySubprocess(WatchedSubprocess):
failed_heartbeats=self.failed_heartbeats,
ti_id=self.id,
max_retries=MAX_FAILED_HEARTBEATS,
- exc_info=True,
+ exception=exc,
)
# If we've failed to heartbeat too many times, kill the process
if self.failed_heartbeats >= MAX_FAILED_HEARTBEATS:
diff --git a/task-sdk/tests/task_sdk/bases/test_operator.py
b/task-sdk/tests/task_sdk/bases/test_operator.py
index dafce2400c8..b9a4c14e317 100644
--- a/task-sdk/tests/task_sdk/bases/test_operator.py
+++ b/task-sdk/tests/task_sdk/bases/test_operator.py
@@ -250,13 +250,13 @@ class TestBaseOperator:
)
def test_warnings_are_properly_propagated(self):
- with pytest.warns(DeprecationWarning) as warnings:
+ with pytest.warns(DeprecationWarning, match="deprecated") as warnings:
DeprecatedOperator(task_id="test")
- assert len(warnings) == 1
- warning = warnings[0]
- # Here we check that the trace points to the place
- # where the deprecated class was used
- assert warning.filename == __file__
+ assert len(warnings) == 1
+ warning = warnings[0]
+ # Here we check that the trace points to the place
+ # where the deprecated class was used
+ assert warning.filename == __file__
def test_setattr_performs_no_custom_action_at_execute_time(self,
spy_agency):
op = MockOperator(task_id="test_task")
@@ -680,8 +680,8 @@ class TestBaseOperator:
with pytest.warns(UserWarning, match=warning_message) as warnings:
task = StringTemplateFieldsOperator(task_id="op1")
- assert len(warnings) == 1
- assert isinstance(task.template_fields, list)
+ assert len(warnings) == 1
+ assert isinstance(task.template_fields, list)
def test_jinja_invalid_expression_is_just_propagated(self):
"""Test render_template propagates Jinja invalid expression errors."""
diff --git a/task-sdk/tests/task_sdk/definitions/test_asset.py
b/task-sdk/tests/task_sdk/definitions/test_asset.py
index 2a25c0907c7..46770793d9d 100644
--- a/task-sdk/tests/task_sdk/definitions/test_asset.py
+++ b/task-sdk/tests/task_sdk/definitions/test_asset.py
@@ -117,7 +117,7 @@ def test_uri_with_scheme(uri: str, normalized: str) -> None:
def test_uri_with_auth() -> None:
- with pytest.warns(UserWarning) as record:
+ with pytest.warns(UserWarning, match="username") as record:
asset = Asset("ftp://user@localhost/foo.txt")
assert len(record) == 1
assert str(record[0].message) == (