-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Allow unpacking of type variable bound to typed dict #1399
Comments
This would be kwargs equivalent of being able to unpack TypeVarTuple. This would I think solve this request to be able to use Paramspec kwargs only. I have a couple small use cases where this would be nice although they mostly follow other issue of more flexibility with preserving just args/kwargs/similar manipulation. |
I believe I hit this issue when I was trying to write a type stub for
class Graph:
def add_node(self, node_for_adding, **attr): ... I was trying to do this: N = TypeVar("N") # type for node ID
A = TypeVar("A", bound=TypedDict) # type for node attribute
class Graph(Generic[N, A]):
def add_node(self, node_for_adding: N, **attr: Unpack[A]) -> None: ... |
Yup, perfect example. |
Is there something I could help with to speed this up? Probably only possible way to halp is to draft a PEP? Anyway, it would be really useful for a framework I'm building - https://github.com/paveldedik/ludic/blob/main/ludic/base.py#L293-L308 It seems I can already bound a subclass of a from typing import TypedDict, TypeVar
class Attrs(TypedDict):
key: str
T = TypeVar("T", bound=Attrs) # does not complain This seems to work in mypy but I'm afraid there is not PEP for it. |
The trouble is |
I'd like to have a family of classes where overrides have additional parameters to various methods:
See @erictraut's instructive comment on the issue here.
The text was updated successfully, but these errors were encountered: