Skip to content

Commit fd90776

Browse files
committed
Support small-cap envs
1 parent 6a61af5 commit fd90776

File tree

2 files changed

+10
-26
lines changed

2 files changed

+10
-26
lines changed

src/settings/_user_config.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,38 +55,23 @@ def get_user_config(settings):
5555
return config
5656

5757

58-
def _parse_env_var(key: str) -> dict | list | str | int | None:
59-
"""Parse one setting input key."""
60-
raw_value = os.getenv(key)
61-
if raw_value is None:
62-
return None
63-
64-
try:
65-
parsed = yaml.safe_load(raw_value)
66-
return _lowercase(parsed)
67-
except yaml.YAMLError as e:
68-
logger.error(f"Failed to parse environment variable {key} as YAML:\n{e}")
69-
return {}
70-
71-
72-
def _load_section(keys: list[str]) -> dict:
73-
"""Parse one section of expected config."""
74-
section_config = {}
75-
for key in keys:
76-
parsed = _parse_env_var(key)
77-
if parsed is not None:
78-
section_config[key.lower()] = parsed
79-
return section_config
58+
def _load_from_env() -> dict:
59+
"""
60+
Load and parse config from environment variables defined in CONFIG_MAPPING.
8061
62+
Tries uppercase and lowercase keys, parses values as YAML,
63+
and lowercases dictionary keys in the result.
8164
82-
def _load_from_env() -> dict:
65+
Returns:
66+
dict: Config sections with parsed env var values.
67+
"""
8368
config = {}
8469

8570
for section, keys in CONFIG_MAPPING.items():
8671
section_config = {}
8772

8873
for key in keys:
89-
raw_value = os.getenv(key)
74+
raw_value = os.getenv(key) or os.getenv(key.lower())
9075
if raw_value is None:
9176
continue
9277

tests/jobs/test_strikes_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from unittest.mock import MagicMock, patch
2+
from unittest.mock import MagicMock
33

44
import pytest
55
from src.jobs.strikes_handler import StrikesHandler
@@ -122,7 +122,6 @@ def test_log_change_logs_expected_strike_changes(caplog):
122122
# Check actual IDs exist
123123
for key in ["hash_new", "hash_inc", "hash_old", "hash_gone", "hash_paused"]:
124124
assert key in log_messages
125-
126125

127126
@pytest.mark.parametrize(
128127
"max_strikes, initial_strikes, expected_removed_after_two_runs",

0 commit comments

Comments
 (0)