Check parameter and return types for command finalization hooks.
(
cls, func: Callable[[plugin.CommandFinalizationData], plugin.CommandFinalizationData]
)
| 5891 | |
| 5892 | @classmethod |
| 5893 | def _validate_cmdfinalization_callable( |
| 5894 | cls, func: Callable[[plugin.CommandFinalizationData], plugin.CommandFinalizationData] |
| 5895 | ) -> None: |
| 5896 | """Check parameter and return types for command finalization hooks.""" |
| 5897 | cls._validate_callable_param_count(func, 1) |
| 5898 | type_hints, ret_ann = get_types(func) |
| 5899 | if not type_hints: |
| 5900 | raise TypeError(f"{func.__name__} parameter is missing a type hint, expected: {plugin.CommandFinalizationData}") |
| 5901 | _, par_ann = next(iter(type_hints.items())) |
| 5902 | if par_ann != plugin.CommandFinalizationData: |
| 5903 | raise TypeError( |
| 5904 | f"{func.__name__} must have one parameter declared with type {plugin.CommandFinalizationData}, got: {par_ann}" |
| 5905 | ) |
| 5906 | if ret_ann != plugin.CommandFinalizationData: |
| 5907 | raise TypeError(f"{func.__name__} must declare return a return type of {plugin.CommandFinalizationData}") |
| 5908 | |
| 5909 | def register_cmdfinalization_hook( |
| 5910 | self, func: Callable[[plugin.CommandFinalizationData], plugin.CommandFinalizationData] |
no test coverage detected