mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-24 13:45:05 +00:00
Add type annotations to helper functions per code review
- Added type annotations to strict_types decorator (func: F -> F) - Added type annotations to _check_type parameters (value: Any, expected_type: Type) - Removed unused get_type_hints import - Added TypeVar and proper typing imports for decorator - All functions now have complete type annotations including helpers Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user