How to add type hint to python factory_boy Factory classes?

Viewed 50

So we are working with some existing code where there is an implementation of factories classes from the factory_boy project which create instances of other classes for example

class TableFactory(Factory):
    class Meta:
        model = Table

    id = LazyAttribute(lambda x: uuid4())
    color = SubFactory(ColorFactory)
    reference = 'WT9034'
    weight = 120
    height = 50
    length = 3
    width = 1 

where the Factory base meta-class has a logic in its __new__ method to dynamically instantiate a class using the model provided in the Meta class of the TableFactory. The Table model is a simple SQLAlchemy class/model.

Since the produced classes are made dynamically I guess we cannot have static type hinting for the produced class types? Or can we somehow add this?

0 Answers
Related