You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/09/01 18:12:58 UTC
[airflow] branch main updated: Refactor unneeded 'continue' jumps in configuration (#33844)
This is an automated email from the ASF dual-hosted git repository.
potiuk 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 3ae6b4e86f Refactor unneeded 'continue' jumps in configuration (#33844)
3ae6b4e86f is described below
commit 3ae6b4e86fe807c00bd736c59df58733df2b9bf9
Author: Miroslav Šedivý <67...@users.noreply.github.com>
AuthorDate: Fri Sep 1 18:12:51 2023 +0000
Refactor unneeded 'continue' jumps in configuration (#33844)
---
airflow/configuration.py | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/airflow/configuration.py b/airflow/configuration.py
index 7f04c6926b..e30ead3ff3 100644
--- a/airflow/configuration.py
+++ b/airflow/configuration.py
@@ -16,6 +16,7 @@
# under the License.
from __future__ import annotations
+import contextlib
import datetime
import functools
import io
@@ -1472,14 +1473,13 @@ class AirflowConfigParser(ConfigParser):
# if they are not provided through env, cmd and secret
hidden = "< hidden >"
for section, key in self.sensitive_config_values:
- if not config_sources.get(section):
- continue
- if config_sources[section].get(key, None):
- if display_source:
- source = config_sources[section][key][1]
- config_sources[section][key] = (hidden, source)
- else:
- config_sources[section][key] = hidden
+ if config_sources.get(section):
+ if config_sources[section].get(key, None):
+ if display_source:
+ source = config_sources[section][key][1]
+ config_sources[section][key] = (hidden, source)
+ else:
+ config_sources[section][key] = hidden
return config_sources
@@ -1649,16 +1649,13 @@ class AirflowConfigParser(ConfigParser):
configs: Iterable[tuple[str, ConfigParser]],
) -> bool:
for config_type, config in configs:
- if config_type == "default":
- continue
- try:
- deprecated_section_array = config.items(section=deprecated_section, raw=True)
- for key_candidate, _ in deprecated_section_array:
- if key_candidate == deprecated_key:
+ if config_type != "default":
+ with contextlib.suppress(NoSectionError):
+ deprecated_section_array = config.items(section=deprecated_section, raw=True)
+ if any(key == deprecated_key for key, _ in deprecated_section_array):
return True
- except NoSectionError:
- pass
- return False
+ else:
+ return False
@staticmethod
def _deprecated_variable_is_set(deprecated_section: str, deprecated_key: str) -> bool: