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

Method _validate_prepostloop_callable

cmd2/cmd2.py:5823–5829  ·  view source on GitHub ↗

Check parameter and return types for preloop and postloop hooks.

(cls, func: Callable[[], None])

Source from the content-addressed store, hash-verified

5821
5822 @classmethod
5823 def _validate_prepostloop_callable(cls, func: Callable[[], None]) -> None:
5824 """Check parameter and return types for preloop and postloop hooks."""
5825 cls._validate_callable_param_count(func, 0)
5826 # make sure there is no return annotation or the return is specified as None
5827 _, ret_ann = get_types(func)
5828 if ret_ann is not None:
5829 raise TypeError(f"{func.__name__} must have a return type of 'None', got: {ret_ann}")
5830
5831 def register_preloop_hook(self, func: Callable[[], None]) -> None:
5832 """Register a function to be called at the beginning of the command loop."""

Callers 2

register_preloop_hookMethod · 0.95

Calls 2

get_typesFunction · 0.85

Tested by

no test coverage detected