MCPcopy Create free account
hub / github.com/pyinvoke/invoke / setdefault

Method setdefault

invoke/config.py:282–295  ·  view source on GitHub ↗
(self, *args: Any)

Source from the content-addressed store, hash-verified

280 return ret
281
282 def setdefault(self, *args: Any) -> Any:
283 # Must test up front whether the key existed beforehand
284 key_existed = args and args[0] in self._config
285 # Run locally
286 ret = self._config.setdefault(*args)
287 # Key already existed -> nothing was mutated, short-circuit
288 if key_existed:
289 return ret
290 # Here, we can assume the key did not exist and thus user must have
291 # supplied a 'default' (if they did not, the real setdefault() above
292 # would have excepted.)
293 key, default = args
294 self._track_modification_of(key, default)
295 return ret
296
297 def update(self, *args: Any, **kwargs: Any) -> None:
298 if kwargs:

Callers 1

_reprMethod · 0.45

Calls 1

Tested by

no test coverage detected