Pylance outputs an error for these:
user: TypeAlias = models.ForeignKey[User]
content_type: TypeAlias = models.ForeignKey[ContentType]
It becomes fine with:
user: models.ForeignKey[User] = ...
content_type: models.ForeignKey[ContentType] = ...
Bonus: it would be nice to have these additions (like in contrib.auth.models.Permission:
user_id: int
content_type_id: int
Note: the other fields (in this and some other contrib.*.models) should probably better be written with this pattern: field: models.FieldType = ..., as in contrib.contenttypes.models and contrib.redirects.models.
Pylance outputs an error for these:
It becomes fine with:
Bonus: it would be nice to have these additions (like in
contrib.auth.models.Permission:Note: the other fields (in this and some other
contrib.*.models) should probably better be written with this pattern:field: models.FieldType = ..., as incontrib.contenttypes.modelsandcontrib.redirects.models.