Opened 3 years ago
Closed 3 years ago
#33558 closed Bug (duplicate)
Abstract model inheriting from typing.Generic[T] causes TypeError
Reported by: | Rob Percival | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 4.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The exception message is "TypeError: Cannot inherit from plain Generic". Example:
T = typing.TypeVar("T") class AbstractModel(models.Model, Generic[T]): foo: T # Bad example of how you might use a TypeVar class Meta: abstract = True class IntModel(AbstractModel[int]): …
A better explanation of the issue and a patch can be found here: https://github.com/typeddjango/django-stubs/issues/299
Note:
See TracTickets
for help on using tickets.
Duplicate #33174.