Check parameter and return types for preloop and postloop hooks.
(cls, func: Callable[[], None])
| 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.""" |
no test coverage detected