MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / _validate_callable_param_count

Method _validate_callable_param_count

cmd2/cmd2.py:5813–5820  ·  view source on GitHub ↗

Ensure a function has the given number of parameters.

(cls, func: Callable[..., Any], count: int)

Source from the content-addressed store, hash-verified

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:

Calls

no outgoing calls

Tested by

no test coverage detected