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

Class Call

invoke/tasks.py:363–489  ·  view source on GitHub ↗

Represents a call/execution of a `.Task` with given (kw)args. Similar to `~functools.partial` with some added functionality (such as the delegation to the inner task, and optional tracking of the name it's being called by.) .. versionadded:: 1.0

Source from the content-addressed store, hash-verified

361
362
363class Call:
364 """
365 Represents a call/execution of a `.Task` with given (kw)args.
366
367 Similar to `~functools.partial` with some added functionality (such as the
368 delegation to the inner task, and optional tracking of the name it's being
369 called by.)
370
371 .. versionadded:: 1.0
372 """
373
374 def __init__(
375 self,
376 task: "Task",
377 called_as: Optional[str] = None,
378 args: Optional[Tuple[str, ...]] = None,
379 kwargs: Optional[Dict[str, Any]] = None,
380 ) -> None:
381 """
382 Create a new `.Call` object.
383
384 :param task: The `.Task` object to be executed.
385
386 :param str called_as:
387 The name the task is being called as, e.g. if it was called by an
388 alias or other rebinding. Defaults to ``None``, aka, the task was
389 referred to by its default name.
390
391 :param tuple args:
392 Positional arguments to call with, if any. Default: ``None``.
393
394 :param dict kwargs:
395 Keyword arguments to call with, if any. Default: ``None``.
396 """
397 self.task = task
398 self.called_as = called_as
399 self.args = args or tuple()
400 self.kwargs = kwargs or dict()
401
402 # TODO: just how useful is this? feels like maybe overkill magic
403 def __getattr__(self, name: str) -> Any:
404 return getattr(self.task, name)
405
406 def __deepcopy__(self, memo: object) -> "Call":
407 return self.clone()
408
409 def __repr__(self) -> str:
410 aka = ""
411 if self.called_as is not None and self.called_as != self.task.name:
412 aka = " (called as: {!r})".format(self.called_as)
413 return "<{} {!r}{}, args: {!r}, kwargs: {!r}>".format(
414 self.__class__.__name__,
415 self.task.name,
416 aka,
417 self.args,
418 self.kwargs,
419 )
420

Callers 15

is_requiredMethod · 0.90
is_first_posargMethod · 0.90
defaults_to_NoneMethod · 0.90
may_be_givenMethod · 0.90
may_be_givenMethod · 0.90
may_be_givenMethod · 0.90
includes_task_nameMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…