Skip to content Skip to sidebar Skip to footer

How To Specify Typings For Dynamic Fields Similar To Django Model/field?

For example: # field base class class F: pass # represent integer class AF(F): pass # represent string class BF(F): pass class M: a = AF() b = BF()

Solution 1:

Django's Model class has fields that explicitly check the type of the field as well as database migrations to add those types to the DB. If you want to use static types in python, consider using MyPy to annotate your functions and variables.


Post a Comment for "How To Specify Typings For Dynamic Fields Similar To Django Model/field?"