Replies: 1 comment 14 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.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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