Replies: 1 comment 7 replies
-
You can use a from typing import Callable
class Collection:
def make[**P, T](
self, type_: Callable[P, T], *args: P.args, **kwargs: P.kwargs
) -> T: ... Here's the same thing using older (pre-3.12) syntax: from typing import Callable, ParamSpec, TypeVar
P = ParamSpec("P")
T = TypeVar("T")
class Collection:
def make(self, type_: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> T: ... |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, for this code:
How can I annotate
**attrs
such that a type checker, mypy in particular, will correctly ensure that any keywords passed are a valid subset of those that could be passed toT
's constructor?Beta Was this translation helpful? Give feedback.
All reactions