Lee-W commented on code in PR #46544:
URL: https://github.com/apache/airflow/pull/46544#discussion_r1948808042


##########
tests/cli/commands/remote_commands/test_config_command.py:
##########
@@ -324,7 +324,8 @@ def test_lint_with_invalid_section_option(self):
     def test_lint_detects_multiple_issues(self):
         with mock.patch(
             "airflow.configuration.conf.has_option",
-            side_effect=lambda s, o: o in ["check_slas", 
"strict_dataset_uri_validation"],
+            side_effect=lambda s, o, lookup_from_deprecated_options: o

Review Comment:
   ```suggestion
               side_effect=lambda section, option, 
lookup_from_deprecated_options: option
   ```



##########
airflow/configuration.py:
##########
@@ -891,58 +891,60 @@ def get(  # type: ignore[override,misc]
         section: str,
         key: str,
         suppress_warnings: bool = False,
+        lookup_from_deprecated_options: bool = True,
         _extra_stacklevel: int = 0,
         **kwargs,
     ) -> str | None:
         section = section.lower()
         key = key.lower()
         warning_emitted = False
-        deprecated_section: str | None
-        deprecated_key: str | None
+        deprecated_section: str | None = None
+        deprecated_key: str | None = None
 
-        option_description = self.configuration_description.get(section, 
{}).get(key, {})
-        if option_description.get("deprecated"):
-            deprecation_reason = option_description.get("deprecation_reason", 
"")
-            warnings.warn(
-                f"The '{key}' option in section {section} is deprecated. 
{deprecation_reason}",
-                DeprecationWarning,
-                stacklevel=2 + _extra_stacklevel,
-            )
-        # For when we rename whole sections
-        if section in self.inversed_deprecated_sections:
-            deprecated_section, deprecated_key = (section, key)
-            section = self.inversed_deprecated_sections[section]
-            if not self._suppress_future_warnings:
+        if lookup_from_deprecated_options:
+            option_description = self.configuration_description.get(section, 
{}).get(key, {})
+            if option_description.get("deprecated"):
+                deprecation_reason = 
option_description.get("deprecation_reason", "")
                 warnings.warn(
-                    f"The config section [{deprecated_section}] has been 
renamed to "
-                    f"[{section}]. Please update your `conf.get*` call to use 
the new name",
-                    FutureWarning,
-                    stacklevel=2 + _extra_stacklevel,
-                )
-            # Don't warn about individual rename if the whole section is 
renamed
-            warning_emitted = True
-        elif (section, key) in self.inversed_deprecated_options:
-            # Handle using deprecated section/key instead of the new 
section/key
-            new_section, new_key = self.inversed_deprecated_options[(section, 
key)]
-            if not self._suppress_future_warnings and not warning_emitted:
-                warnings.warn(
-                    f"section/key [{section}/{key}] has been deprecated, you 
should use"
-                    f"[{new_section}/{new_key}] instead. Please update your 
`conf.get*` call to use the "
-                    "new name",
-                    FutureWarning,
+                    f"The '{key}' option in section {section} is deprecated. 
{deprecation_reason}",
+                    DeprecationWarning,
                     stacklevel=2 + _extra_stacklevel,
                 )
+            # For when we rename whole sections

Review Comment:
   ```suggestion
               # For the cases in which we rename whole sections
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to