yi-config-starter 0.1.3__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yi-config-starter
3
- Version: 0.1.3
3
+ Version: 0.2.0
4
4
  Summary: Config starter for my local projects
5
5
  Author: Yunus Indori
6
6
  License: MIT License
@@ -4,5 +4,5 @@ from yi_config_starter.config_starter import ApplicationConfiguration
4
4
 
5
5
  logging.getLogger(__name__).addHandler(logging.NullHandler())
6
6
 
7
- __version__ = "0.1.3"
7
+ __version__ = "0.2.0"
8
8
  __all__ = ["ApplicationConfiguration"]
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
 
6
6
  import logging
7
7
  import os
8
+ import re
8
9
  import sys
9
10
  from pathlib import Path
10
11
  from threading import RLock
@@ -168,6 +169,8 @@ class ApplicationConfiguration:
168
169
  {{XDG_CONFIG}} -> $XDG_CONFIG_HOME or "~/.config"
169
170
  {{ENV:VAR_NAME}} -> value of environment variable VAR_NAME (empty if missing)
170
171
  You can pass extra_placeholders to override or add tokens.
172
+
173
+ After replacements, raises ValueError if any unresolved {{...}} placeholders remain.
171
174
  """
172
175
  # base mapping
173
176
  appdata = os.environ.get("APPDATA") or str(Path.home() / ".config")
@@ -204,6 +207,16 @@ class ApplicationConfiguration:
204
207
  text = text[:i] + env_val + text[j + 2:]
205
208
  start = i + len(env_val)
206
209
 
210
+ # Fail fast if any unresolved placeholders remain.
211
+ # We consider anything shaped like {{...}} to be a placeholder at this stage.
212
+ unresolved = {m.group(1).strip() for m in re.finditer(r"\{\{([^{}]+)}}", text)}
213
+ if unresolved:
214
+ names = ", ".join(sorted(unresolved))
215
+ raise ValueError(
216
+ f"Unresolved placeholders in config after preprocessing: {names}. "
217
+ f"Define them via built-ins, extra_placeholders, or environment variables using {{ENV:NAME}}."
218
+ )
219
+
207
220
  return text
208
221
 
209
222
  def _read_yaml(self, path: Path, extra_placeholders: Optional[Dict[str, str]] = None) -> dict:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yi-config-starter
3
- Version: 0.1.3
3
+ Version: 0.2.0
4
4
  Summary: Config starter for my local projects
5
5
  Author: Yunus Indori
6
6
  License: MIT License