Returns a modified `inspect.Signature` based on that of ``body``. :returns: an `inspect.Signature` matching that of ``body``, but with the initial context argument removed. :raises TypeError: if the task lacks an initial positional `.Cont
(self, body: Callable)
| 145 | return self.times_called > 0 |
| 146 | |
| 147 | def argspec(self, body: Callable) -> "Signature": |
| 148 | """ |
| 149 | Returns a modified `inspect.Signature` based on that of ``body``. |
| 150 | |
| 151 | :returns: |
| 152 | an `inspect.Signature` matching that of ``body``, but with the |
| 153 | initial context argument removed. |
| 154 | :raises TypeError: |
| 155 | if the task lacks an initial positional `.Context` argument. |
| 156 | |
| 157 | .. versionadded:: 1.0 |
| 158 | .. versionchanged:: 2.0 |
| 159 | Changed from returning a two-tuple of ``(arg_names, spec_dict)`` to |
| 160 | returning an `inspect.Signature`. |
| 161 | """ |
| 162 | # Handle callable-but-not-function objects |
| 163 | if isinstance(body, types.FunctionType): |
| 164 | func = body |
| 165 | else: |
| 166 | func = body.__call__ # type: ignore |
| 167 | # Rebuild signature with first arg dropped, or die usefully(ish trying |
| 168 | sig = inspect.signature(func) |
| 169 | params = list(sig.parameters.values()) |
| 170 | # TODO: this ought to also check if an extant 1st param _was_ a Context |
| 171 | # arg, and yell similarly if not. |
| 172 | if not len(params): |
| 173 | # TODO: see TODO under __call__, this should be same type |
| 174 | raise TypeError("Tasks must have an initial Context argument!") |
| 175 | return sig.replace(parameters=params[1:]) |
| 176 | |
| 177 | def fill_implicit_positionals( |
| 178 | self, positional: Optional[Iterable[str]] |
no outgoing calls
no test coverage detected