Skip to content

Commit 5f2b06c

Browse files
committed
Reactivate workaround until second issue is fixed
1 parent bdcba57 commit 5f2b06c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

baybe/settings.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def inner(*args, **kwds):
7979

8080
def _make_default_factory(fld: Attribute, /) -> Any:
8181
"""Make the default factory for the given attribute."""
82+
# TODO: https://github.com/python-attrs/attrs/issues/1540
83+
name = fld.alias or fld.name
8284

8385
def get_default_value(self: Settings) -> Any:
8486
"""Dynamically retrieve the default value for the field.
@@ -98,7 +100,7 @@ def get_default_value(self: Settings) -> Any:
98100

99101
if self._restore_environment:
100102
# If enabled, the environment values take precedence for the default
101-
env_name = f"BAYBE_{fld.alias.upper()}"
103+
env_name = f"BAYBE_{name.upper()}"
102104
value = os.getenv(env_name, default)
103105
if fld.type == "bool":
104106
value = to_bool(value)
@@ -227,19 +229,22 @@ def __attrs_pre_init__(self) -> None:
227229
("BAYBE_CACHE_DIR", flds.cache_directory),
228230
]
229231
for env_var, fld in pairs:
232+
# TODO: https://github.com/python-attrs/attrs/issues/1540
233+
name = fld.alias or fld.name
234+
230235
if (value := os.environ.pop(env_var, None)) is not None:
231236
warnings.warn(
232237
f"The environment variable '{env_var}' has "
233238
f"been deprecated and support will be dropped in a future version. "
234-
f"Please use 'BAYBE_{fld.alias.upper()}' instead. "
239+
f"Please use 'BAYBE_{name.upper()}' instead. "
235240
f"For now, we've automatically handled the translation for you.",
236241
DeprecationWarning,
237242
)
238243
if env_var.endswith("POLARS"):
239244
value = "false" if to_bool(value) else "true"
240245
elif env_var.endswith("SIMULATION_RUNS"):
241246
value = "true" if to_bool(value) else "false"
242-
os.environ[f"BAYBE_{fld.alias.upper()}"] = value
247+
os.environ[f"BAYBE_{name.upper()}"] = value
243248
# <<<<< Deprecation
244249

245250
known_env_vars = {

0 commit comments

Comments
 (0)