MCPcopy Create free account
hub / github.com/theskumar/python-dotenv / resolve_variables

Function resolve_variables

src/dotenv/main.py:227–249  ·  view source on GitHub ↗
(
    values: Iterable[Tuple[str, Optional[str]]],
    override: bool,
)

Source from the content-addressed store, hash-verified

225
226
227def resolve_variables(
228 values: Iterable[Tuple[str, Optional[str]]],
229 override: bool,
230) -> Mapping[str, Optional[str]]:
231 new_values: Dict[str, Optional[str]] = {}
232
233 for (name, value) in values:
234 if value is None:
235 result = None
236 else:
237 atoms = parse_variables(value)
238 env: Dict[str, Optional[str]] = {}
239 if override:
240 env.update(os.environ) # type: ignore
241 env.update(new_values)
242 else:
243 env.update(new_values)
244 env.update(os.environ) # type: ignore
245 result = "".join(atom.resolve(env) for atom in atoms)
246
247 new_values[name] = result
248
249 return new_values
250
251
252def _walk_to_root(path: str) -> Iterator[str]:

Callers 1

dictMethod · 0.85

Calls 2

parse_variablesFunction · 0.85
resolveMethod · 0.45

Tested by

no test coverage detected