#33174: Having a model inherit from Generic[T] breaks makemigrations
--------------------------------+--------------------------------------
Reporter: Antoine Humeau | Owner: nobody
Type: New feature | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Comment (by Antoine Humeau):
Indeed the workaround is the better solution.
For future reference, I had to adapt it to:
{{{
if TYPE_CHECKING:
class GenericBase(typing.Generic[StripeClassT]):
pass
else:
class GenericBase:
def __class_getitem__(cls, _):
return cls
class StripeObjectModel(GenericBase[StripeClassT], models.Model):
...
}}}
That is because mypy needs the type parameter in the base classes
definition to bind it to the class.
Thanks a lot for your answers, I am sorry I should have checked for a
workaround more thoroughly before posting.
--
Ticket URL: <https://code.djangoproject.com/ticket/33174#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.51d40ca590193adc100fad087a5a2006%40djangoproject.com.