From f8e24df1c406b5b50cba75e11060b4c241c9c1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Wed, 16 Oct 2024 23:14:33 -0600 Subject: [PATCH] Do not deprecate just yet --- singer_sdk/configuration/_dict_config.py | 9 ++++----- tests/core/configuration/test_dict_config.py | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/singer_sdk/configuration/_dict_config.py b/singer_sdk/configuration/_dict_config.py index 81eb5565e..4297c39ed 100644 --- a/singer_sdk/configuration/_dict_config.py +++ b/singer_sdk/configuration/_dict_config.py @@ -5,7 +5,6 @@ import logging import os import typing as t -import warnings from pathlib import Path from dotenv import find_dotenv @@ -68,10 +67,10 @@ def parse_environment_config( try: result[config_key] = _parse_array(env_var_value) except Exception: # noqa: BLE001 - warnings.warn( - "Parsing array from deprecated string format 'x,y,z'", - DeprecationWarning, - stacklevel=2, + # TODO(edgarrmondragon): Make this a deprecation warning. + logger.warning( + "Parsing array of the form 'x,y,z' is deprecated and will be " + "removed in future versions.", ) result[config_key] = _legacy_parse_array_of_strings(env_var_value) elif _typing.is_array_type(schema): diff --git a/tests/core/configuration/test_dict_config.py b/tests/core/configuration/test_dict_config.py index 42f2a8fb4..851f9970a 100644 --- a/tests/core/configuration/test_dict_config.py +++ b/tests/core/configuration/test_dict_config.py @@ -1,6 +1,7 @@ from __future__ import annotations import json +import logging import typing as t from pathlib import Path @@ -50,7 +51,11 @@ def config_file2(tmpdir) -> str: return filepath -def test_get_env_var_config(monkeypatch: pytest.MonkeyPatch, subtests: SubTests): +def test_get_env_var_config( + monkeypatch: pytest.MonkeyPatch, + subtests: SubTests, + caplog: pytest.LogCaptureFixture, +): """Test settings parsing from environment variables.""" with monkeypatch.context() as m: m.setenv("PLUGIN_TEST_PROP1", "hello") @@ -85,12 +90,17 @@ def test_get_env_var_config(monkeypatch: pytest.MonkeyPatch, subtests: SubTests) assert not set.intersection(missing_props, env_config) m.setenv("PLUGIN_TEST_PROP3", "val1,val2") - with subtests.test(msg="Legacy array parsing"), pytest.warns( - DeprecationWarning + with subtests.test(msg="Legacy array parsing"), caplog.at_level( + logging.WARNING, ): parsed = parse_environment_config(CONFIG_JSONSCHEMA, "PLUGIN_TEST_") assert parsed["prop3"] == ["val1", "val2"] + assert any( + "Parsing array of the form 'x,y,z'" in log.message + for log in caplog.records + ) + no_env_config = parse_environment_config(CONFIG_JSONSCHEMA, "PLUGIN_TEST_") missing_props = { "prop1",