This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 15ae7ce9724 Remove deprecated functions from 
`airflow/configuration.py` (#43530)
15ae7ce9724 is described below

commit 15ae7ce9724871ad07f81a4a322156280d7ca03c
Author: Kaxil Naik <[email protected]>
AuthorDate: Thu Oct 31 00:55:10 2024 +0000

    Remove deprecated functions from `airflow/configuration.py` (#43530)
    
    These functions have been deprecated from a long time now.
---
 airflow/configuration.py            | 141 ------------------------------------
 newsfragments/43530.significant.rst |  21 ++++++
 tests/core/test_configuration.py    |  17 -----
 3 files changed, 21 insertions(+), 158 deletions(-)

diff --git a/airflow/configuration.py b/airflow/configuration.py
index 9c15b5f7776..82718325865 100644
--- a/airflow/configuration.py
+++ b/airflow/configuration.py
@@ -2043,114 +2043,6 @@ def make_group_other_inaccessible(file_path: str):
         )
 
 
-def get(*args, **kwargs) -> ConfigType | None:
-    """Historical get."""
-    warnings.warn(
-        "Accessing configuration method 'get' directly from the configuration 
module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.get'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return conf.get(*args, **kwargs)
-
-
-def getboolean(*args, **kwargs) -> bool:
-    """Historical getboolean."""
-    warnings.warn(
-        "Accessing configuration method 'getboolean' directly from the 
configuration module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.getboolean'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return conf.getboolean(*args, **kwargs)
-
-
-def getfloat(*args, **kwargs) -> float:
-    """Historical getfloat."""
-    warnings.warn(
-        "Accessing configuration method 'getfloat' directly from the 
configuration module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.getfloat'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return conf.getfloat(*args, **kwargs)
-
-
-def getint(*args, **kwargs) -> int:
-    """Historical getint."""
-    warnings.warn(
-        "Accessing configuration method 'getint' directly from the 
configuration module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.getint'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return conf.getint(*args, **kwargs)
-
-
-def getsection(*args, **kwargs) -> ConfigOptionsDictType | None:
-    """Historical getsection."""
-    warnings.warn(
-        "Accessing configuration method 'getsection' directly from the 
configuration module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.getsection'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return conf.getsection(*args, **kwargs)
-
-
-def has_option(*args, **kwargs) -> bool:
-    """Historical has_option."""
-    warnings.warn(
-        "Accessing configuration method 'has_option' directly from the 
configuration module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.has_option'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return conf.has_option(*args, **kwargs)
-
-
-def remove_option(*args, **kwargs) -> bool:
-    """Historical remove_option."""
-    warnings.warn(
-        "Accessing configuration method 'remove_option' directly from the 
configuration module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.remove_option'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return conf.remove_option(*args, **kwargs)
-
-
-def as_dict(*args, **kwargs) -> ConfigSourcesType:
-    """Historical as_dict."""
-    warnings.warn(
-        "Accessing configuration method 'as_dict' directly from the 
configuration module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.as_dict'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return conf.as_dict(*args, **kwargs)
-
-
-def set(*args, **kwargs) -> None:
-    """Historical set."""
-    warnings.warn(
-        "Accessing configuration method 'set' directly from the configuration 
module is "
-        "deprecated. Please access the configuration from the 
'configuration.conf' object via "
-        "'conf.set'",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    conf.set(*args, **kwargs)
-
-
 def ensure_secrets_loaded() -> list[BaseSecretsBackend]:
     """
     Ensure that all secrets backends are loaded.
@@ -2207,39 +2099,6 @@ def initialize_secrets_backends() -> 
list[BaseSecretsBackend]:
     return backend_list
 
 
[email protected]_cache(maxsize=None)
-def _DEFAULT_CONFIG() -> str:
-    path = _default_config_file_path("default_airflow.cfg")
-    with open(path) as fh:
-        return fh.read()
-
-
[email protected]_cache(maxsize=None)
-def _TEST_CONFIG() -> str:
-    path = _default_config_file_path("default_test.cfg")
-    with open(path) as fh:
-        return fh.read()
-
-
-_deprecated = {
-    "DEFAULT_CONFIG": _DEFAULT_CONFIG,
-    "TEST_CONFIG": _TEST_CONFIG,
-    "TEST_CONFIG_FILE_PATH": functools.partial(_default_config_file_path, 
"default_test.cfg"),
-    "DEFAULT_CONFIG_FILE_PATH": functools.partial(_default_config_file_path, 
"default_airflow.cfg"),
-}
-
-
-def __getattr__(name):
-    if name in _deprecated:
-        warnings.warn(
-            f"{__name__}.{name} is deprecated and will be removed in future",
-            DeprecationWarning,
-            stacklevel=2,
-        )
-        return _deprecated[name]()
-    raise AttributeError(f"module {__name__} has no attribute {name}")
-
-
 def initialize_auth_manager() -> BaseAuthManager:
     """
     Initialize auth manager.
diff --git a/newsfragments/43530.significant.rst 
b/newsfragments/43530.significant.rst
new file mode 100644
index 00000000000..6f6e89be0e5
--- /dev/null
+++ b/newsfragments/43530.significant.rst
@@ -0,0 +1,21 @@
+Direct Access to Deprecated ``airflow.configuration`` Module Functions Removed
+
+Functions previously accessible directly via the ``airflow.configuration`` 
module,
+such as ``get``, ``getboolean``, ``getfloat``, ``getint``, ``has_option``, 
``remove_option``, ``as_dict``, and ``set``,
+have been removed. These functions should now be accessed through 
``airflow.configuration.conf``.
+
+Before:
+
+.. code-block:: python
+
+    from airflow.configuration import get
+
+    value = get("section", "key")
+
+After:
+
+.. code-block:: python
+
+    from airflow.configuration import conf
+
+    value = conf.get("section", "key")
diff --git a/tests/core/test_configuration.py b/tests/core/test_configuration.py
index 583472eb0a6..016cd5f9893 100644
--- a/tests/core/test_configuration.py
+++ b/tests/core/test_configuration.py
@@ -29,7 +29,6 @@ from unittest.mock import patch
 
 import pytest
 
-from airflow import configuration
 from airflow.configuration import (
     AirflowConfigException,
     AirflowConfigParser,
@@ -1147,22 +1146,6 @@ sql_alchemy_conn=sqlite://test
             # Test when you read using the old section you get told to change 
your `conf.get` call
             assert test_conf.get("old_section", "val") == expected
 
-    def test_deprecated_funcs(self):
-        for func in [
-            "get",
-            "getboolean",
-            "getfloat",
-            "getint",
-            "has_option",
-            "remove_option",
-            "as_dict",
-            "set",
-        ]:
-            with mock.patch(f"airflow.configuration.conf.{func}") as 
mock_method:
-                with pytest.warns(DeprecationWarning):
-                    getattr(configuration, func)()
-                mock_method.assert_called_once()
-
     @pytest.mark.parametrize("display_source", [True, False])
     @mock.patch.dict("os.environ", {}, clear=True)
     def test_conf_as_dict_when_deprecated_value_in_config(self, 
display_source: bool):

Reply via email to