Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,14 @@ def _replace_section_config_with_display_sources(
include_secret: bool,
):
sect = config_sources.setdefault(section, OrderedDict())
for (k, val) in config.items(section=section, raw=raw):
with warnings.catch_warnings():
# calling `items` on config has the effect of calling `get` on each item
# if we call `get` on a moved item, we will falsely get a warning
# letting us know to update our code
# so we suppress such warnings here
warnings.simplefilter("ignore", category=FutureWarning)
items = config.items(section=section, raw=raw)
for (k, val) in items:
deprecated_section, deprecated_key, _ = deprecated_options.get((section, k), (None, None, None))
if deprecated_section and deprecated_key:
if source_name == "default":
Expand Down
10 changes: 10 additions & 0 deletions tests/core/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,3 +1369,13 @@ def test_conf_as_dict_when_deprecated_value_in_secrets_disabled_config(
conf.read_dict(dictionary=cfg_dict)
os.environ.clear()
assert conf.get("database", "sql_alchemy_conn") == f"sqlite:///{HOME_DIR}/airflow/airflow.db"

def test_should_not_falsely_emit_future_warning(self):
from airflow.configuration import AirflowConfigParser

test_conf = AirflowConfigParser()
test_conf.read_dict({"scheduler": {"deactivate_stale_dags_interval": 60}})

with warnings.catch_warnings(record=True) as captured:
test_conf.as_dict()
assert captured == []