Do you want “any type” or do you want “any type with these characteristics”?
bound support Protocol?
T = TypeVar("T") class TypeClassEq(Protocol[T]): def __eq__(self: T, other: T) -> bool: ... TEq = TypeVar("TEq", bound=TypeClassEq)
If so, then
bound could be used to mimic constraints by type-classes.
retry_asyncand the related inner functions of the wrap
async deffor both
tmp.py:29: error: Incompatible return value type (got "Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]", expected "Callable[..., Awaitable[Any]]")with this gist https://gist.github.com/Callek/8bca70ffbe560c22dba72b21ecd49ec8
@gaborbernat is it worth re-opening again?
Got very late the notification for this. I think the feature would be very useful in a post no python 2 world too. It's a matter of fact that type annotations make the code more verbose; so there will be projects who don't want to pay the price of this, or projects you can't modify. In this case, you want to provide the type information as stubs... and for maintaining those stubs would be great if you can use some merge-check tool to validate they're correct against the source.
I'm seeing what I think Is a mypy false positive:
def mypy_type_issue(foo: List[str], bar: List[str]) -> Tuple[List[str], List[str]]: new_foo: List[str] new_bar: List[str] pairlis = list(zip(foo, bar)) pairlis.sort(key=lambda x: x) new_foo, new_bar = zip(*pairlis) # ******* return new_foo, new_bar
The line with the asterisks gives me this error:
Incompatible types in assignment (expression has type "Tuple[Any, ...]", variable has type "List[str]"). Is mypy not understanding the
* or am I not understanding mypy? Thanks!