get_provider_map for type Any #515
-
Trying to use polyfactory with a model with a @classmethod
def get_provider_map(cls) -> dict[type, Any]:
providers_map = super().get_provider_map()
return {
**providers_map,
Any: lambda: "this does not work",
object: lambda: "this works as workaround",
ATypeAlias: lambda: "type alias", # I have seen https://github.com/litestar-org/polyfactory/issues/348 : will not work
} What is the correct way to catch Any? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Unfortunately, |
Beta Was this translation helpful? Give feedback.
-
Done #521 |
Beta Was this translation helpful? Give feedback.
Unfortunately,
Any
is handled specially andpolyfactory
always generates a random string for that. This probably isn't the right way to do this, but instead we should be using the provider map to create the value for a field annotated withAny.
Feel free to create an issue for this because I think you have a valid usecase :) If not, I can create the issue as well.