fix: Restore type hints for low-level api

This commit is contained in:
Andrei Betlen 2024-02-25 16:54:37 -05:00
parent 2292af5796
commit 19234aa0db

View file

@ -109,12 +109,13 @@ if TYPE_CHECKING:
CtypesFuncPointer: TypeAlias = ctypes._FuncPointer # type: ignore
F = TypeVar("F", bound=Callable[..., Any])
def ctypes_function_for_shared_library(lib: ctypes.CDLL):
def ctypes_function(
name: str, argtypes: List[Any], restype: Any, enabled: bool = True
):
def decorator(f: Callable[..., Any]):
def decorator(f: F) -> F:
if enabled:
func = getattr(lib, name)
func.argtypes = argtypes