(original) (raw)

I’ve read through PEPs 483, 484, and 526, but I don’t see any discussion of how type hints should work when the type of a class member differs from the type of an instance member, like when metaclasses are used to create instances.

e.g.:

>>> from django.db import models

>>> class MyModel(models.Model):

... name = models.CharField()

... class Meta:

... app\_label = "myapp"

...

>>> type(MyModel.name)

>>> m = MyModel()

>>> type(m.name)

In this case, I would like to be able to specify an instance type of str for MyModel.name.

Can someone point me to any existing relevant discussion? Or if not, where should a new discussion start?

T