litestar-org/polyfactory

Bug: can't construct models with fields named like `ModelFactory`s classmethods

Closed this issue · 1 comments

Hello, I stumbled upon this recently:

class C(BaseModel):
    batch: int

class CFactory(ModelFactory):
    __model__ = C

CFactory.build() # TypeError: ModelFactory.batch() missing 1 required positional argument: 'size'

– looks like it fails due to CFactory.build detecting and incorrectly recognizing CFactory.batch as a factory field instead of its own classmethod. Similar issue occurs with e.g. build or get_model_fields.

Interesting. Ok, we'll look into this. Thanks!