-
-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
I don't see the same level of static type checking on calls to factory build that I would see if I was instantiating the underlying pydantic model directly. Example below is illustrated, mypy and pyright both don't see any issues when calling build, but they do if creating a Foo object directly.
Basic Example
from __future__ import annotations
from typing import Literal
from polyfactory.factories.pydantic_factory import ModelFactory
from pydantic import BaseModel
type Baz = Literal["hello"]
class Foo(BaseModel):
bar: Baz
class FooFactory(ModelFactory[Foo]): ...
foo = FooFactory.build(bar="world") # mypy & pyright should complain since "world" is not validDrawbacks and Impact
Unlikely to fully adopt polyfactory without this feature.
Unresolved questions
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request