Treat configuration inputs as a deterministic contract: normalize/parsing should be robust and centralized, and config-file reading must use an explicit encoding matching the write path.
INCLUDE_SOURCES), parse with normalization and whitespace tolerance at one “single computation site”, then reuse the parsed result everywhere. This prevents subtle bugs where spaces or empty tokens change behavior..env/config file IO, read with an explicit encoding (typically utf-8) rather than relying on the runtime’s locale. If you later need to support legacy encodings, implement an explicit fallback + warning, not an implicit locale-dependent codec.Example (list parsing + config gating):
include_sources = (config.get("INCLUDE_SOURCES") or "").lower().split(",")
include_sources = [s.strip() for s in include_sources if s.strip()]
# Example gate: opt-in only
if "dripstack" in include_sources:
enable_dripstack()
Example (explicit .env read contract):
with open(path, "r", encoding="utf-8") as f:
content = f.read()