diff --git a/Programs/_freeze_module.py b/Programs/_freeze_module.py index 954aea7..90146b7 100644 --- a/Programs/_freeze_module.py +++ b/Programs/_freeze_module.py @@ -16,12 +16,14 @@ All function parameters must have type annotations. import inspect import marshal import sys -from typing import TextIO, get_type_hints +from typing import Any, Callable, TextIO, Type, TypeVar header: str = "/* Auto-generated by Programs/_freeze_module.py */" +F = TypeVar('F', bound=Callable[..., Any]) -def strict_types(func): + +def strict_types(func: F) -> F: """Decorator that enforces type annotations on all parameters. Raises: @@ -46,7 +48,7 @@ def strict_types(func): return func -def _check_type(value, expected_type, param_name: str) -> None: +def _check_type(value: Any, expected_type: Type, param_name: str) -> None: """Enforce strict type checking at runtime. Args: