# Code de la lib, pas modifiable
class CustomType:
foo: str
def __init__(self, foo: str):
self.foo = foo
def lib_func(foo: str) -> CustomType:
return CustomType(foo)
# Code perso
from typing import TypeVar, Generic, Callable, ParamSpec
T = TypeVar("T")
P = ParamSpec("P")
class my_func(Generic[P, T]):
def __init__(self, func: Callable[P, T]):
self.func = func
def __call__(self, foo: T) -> None:
print(f"I'm doing something with {foo} of type {reveal_type}")
data = lib_func("test")
result = my_func(lib_func)(data)
reveal_type(my_func(lib_func)) # ● Type of "my_func(lib_func)" is "my_func[(foo: str), CustomType]"
reveal_type(my_func(lib_func)(data)) # ● Type of "my_func(lib_func)(data)" is "None"