Skip to content

Commit

Permalink
Do not deprecate just yet
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Oct 17, 2024
1 parent b734cab commit f8e24df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 4 additions & 5 deletions singer_sdk/configuration/_dict_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import logging
import os
import typing as t
import warnings
from pathlib import Path

from dotenv import find_dotenv
Expand Down Expand Up @@ -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):
Expand Down
16 changes: 13 additions & 3 deletions tests/core/configuration/test_dict_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import json
import logging
import typing as t
from pathlib import Path

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit f8e24df

Please sign in to comment.