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

Method pop

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

Source from the content-addressed store, hash-verified

258 del self[key]
259
260 def pop(self, *args: Any) -> Any:
261 # Must test this up front before (possibly) mutating self._config
262 key_existed = args and args[0] in self._config
263 # We always have a _config (whether it's a real dict or a cache of
264 # merged levels) so we can fall back to it for all the corner case
265 # handling re: args (arity, handling a default, raising KeyError, etc)
266 ret = self._config.pop(*args)
267 # If it looks like no popping occurred (key wasn't there), presumably
268 # user gave default, so we can short-circuit return here - no need to
269 # track a deletion that did not happen.
270 if not key_existed:
271 return ret
272 # Here, we can assume at least the 1st posarg (key) existed.
273 self._track_removal_of(args[0])
274 # In all cases, return the popped value.
275 return ret
276
277 def popitem(self) -> Any:
278 ret = self._config.popitem()

Callers 15

_sudoMethod · 0.45
prefixMethod · 0.45
cdMethod · 0.45
__init__Method · 0.45
_modifyMethod · 0.45
_removeMethod · 0.45
exciseFunction · 0.45
arg_optsMethod · 0.45
get_argumentsMethod · 0.45
taskFunction · 0.45
parse_tasksMethod · 0.45

Calls 1

_track_removal_ofMethod · 0.95

Tested by

no test coverage detected