Skip to content

Commit ecfd294

Browse files
committed
Deprecate load_providers_configuration,
restore_core_default_configuration instead of directly remove
1 parent 0058cc6 commit ecfd294

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

shared/configuration/src/airflow_shared/configuration/parser.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,43 @@ def _resolve_deprecated_lookup(
12711271

12721272
return section, key, deprecated_section, deprecated_key, warning_emitted
12731273

1274+
def load_providers_configuration(self) -> None:
1275+
"""
1276+
Load configuration for providers.
1277+
1278+
.. deprecated:: 3.2.0
1279+
Provider configuration is now loaded lazily via the ``configuration_description``
1280+
cached property. This method is kept for backwards compatibility and will be
1281+
removed in a future version.
1282+
"""
1283+
warnings.warn(
1284+
"load_providers_configuration() is deprecated. "
1285+
"Provider configuration is now loaded lazily via the "
1286+
"`configuration_description` cached property.",
1287+
DeprecationWarning,
1288+
stacklevel=2,
1289+
)
1290+
self._use_providers_configuration = True
1291+
self._invalidate_provider_flag_caches()
1292+
1293+
def restore_core_default_configuration(self) -> None:
1294+
"""
1295+
Restore the parser state before provider-contributed sections were loaded.
1296+
1297+
.. deprecated:: 3.2.0
1298+
Use ``make_sure_configuration_loaded(with_providers=False)`` context manager
1299+
instead. This method is kept for backwards compatibility and will be removed
1300+
in a future version.
1301+
"""
1302+
warnings.warn(
1303+
"restore_core_default_configuration() is deprecated. "
1304+
"Use `make_sure_configuration_loaded(with_providers=False)` instead.",
1305+
DeprecationWarning,
1306+
stacklevel=2,
1307+
)
1308+
self._use_providers_configuration = False
1309+
self._invalidate_provider_flag_caches()
1310+
12741311
@overload # type: ignore[override]
12751312
def get(self, section: str, key: str, fallback: str = ..., **kwargs) -> str: ...
12761313

shared/configuration/tests/configuration/test_parser.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,3 +1159,32 @@ def test_invalidate_provider_flag_caches_allows_recomputation(self):
11591159
sensitive_after = test_conf.sensitive_config_values
11601160
assert desc_after == desc_before
11611161
assert sensitive_after == sensitive_before
1162+
1163+
def test_load_providers_configuration_emits_deprecation_warning(self):
1164+
"""Test that load_providers_configuration emits a DeprecationWarning."""
1165+
test_conf = AirflowConfigParser()
1166+
with pytest.warns(DeprecationWarning, match="load_providers_configuration.*deprecated"):
1167+
test_conf.load_providers_configuration()
1168+
assert test_conf._use_providers_configuration is True
1169+
1170+
def test_restore_core_default_configuration_emits_deprecation_warning(self):
1171+
"""Test that restore_core_default_configuration emits a DeprecationWarning."""
1172+
test_conf = AirflowConfigParser()
1173+
with pytest.warns(DeprecationWarning, match="restore_core_default_configuration.*deprecated"):
1174+
test_conf.restore_core_default_configuration()
1175+
assert test_conf._use_providers_configuration is False
1176+
1177+
def test_deprecated_load_restore_round_trip(self):
1178+
"""Test that the deprecated methods toggle _use_providers_configuration correctly."""
1179+
test_conf = AirflowConfigParser()
1180+
assert test_conf._use_providers_configuration is True
1181+
1182+
with pytest.warns(DeprecationWarning, match="restore_core_default_configuration"):
1183+
test_conf.restore_core_default_configuration()
1184+
assert test_conf._use_providers_configuration is False
1185+
assert "configuration_description" not in test_conf.__dict__
1186+
1187+
with pytest.warns(DeprecationWarning, match="load_providers_configuration"):
1188+
test_conf.load_providers_configuration()
1189+
assert test_conf._use_providers_configuration is True
1190+
assert "configuration_description" not in test_conf.__dict__

0 commit comments

Comments
 (0)