-
-
Notifications
You must be signed in to change notification settings - Fork 208
Closed
Description
In Python 3.11 TypedDict can inherit from Generic which hasn't been possible so far. To use it in prior versions, TypedDict can be imported from typing_extensions. I believe it would make sense to postpone import rewriting for it until 3.11.
Example from the Python docs
from typing import Generic, TypeVar
from typing_extensions import TypedDict
T = TypeVar("T")
class Group(TypedDict, Generic[T]):
key: T
group: list[T]After pyupgrade --py38-plus
from typing import Generic, TypeVar
from typing import TypedDict
...--
Besides TypedDict, NamedTuple will also be able to inherit from Generic in 3.11 or can be imported from typing_extensions. This isn't an issue yet though, since pyupgrade doesn't rewrite it.
from typing import Generic, TypeVar
from typing_extensions import NamedTuple
T = TypeVar("T")
class Group(NamedTuple, Generic[T]):
key: T
group: list[T]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels