MCPcopy Index your code
hub / github.com/pyinvoke/invoke / _cast

Method _cast

invoke/env.py:111–123  ·  view source on GitHub ↗
(self, old: Any, new: Any)

Source from the content-addressed store, hash-verified

109 obj[key_path[-1]] = new
110
111 def _cast(self, old: Any, new: Any) -> Any:
112 if isinstance(old, bool):
113 return new not in ("0", "")
114 elif isinstance(old, str):
115 return new
116 elif old is None:
117 return new
118 elif isinstance(old, (list, tuple)):
119 err = "Can't adapt an environment string into a {}!"
120 err = err.format(type(old))
121 raise UncastableEnvVar(err)
122 else:
123 return old.__class__(new)

Callers 1

_path_setMethod · 0.95

Calls 1

UncastableEnvVarClass · 0.85

Tested by

no test coverage detected