Ensure a function has the given number of parameters.
(cls, func: Callable[..., Any], count: int)
| 5811 | |
| 5812 | @classmethod |
| 5813 | def _validate_callable_param_count(cls, func: Callable[..., Any], count: int) -> None: |
| 5814 | """Ensure a function has the given number of parameters.""" |
| 5815 | signature = inspect.signature(func) |
| 5816 | # validate that the callable has the right number of parameters |
| 5817 | nparam = len(signature.parameters) |
| 5818 | if nparam != count: |
| 5819 | plural = "" if nparam == 1 else "s" |
| 5820 | raise TypeError(f"{func.__name__} has {nparam} positional argument{plural}, expected {count}") |
| 5821 | |
| 5822 | @classmethod |
| 5823 | def _validate_prepostloop_callable(cls, func: Callable[[], None]) -> None: |
no outgoing calls
no test coverage detected