“Pydantic arbitrary_types_allowed” Kode Jawaban

Pydantic arbitrary_types_allowed

from pydantic import BaseModel as PydanticBaseModel


class BaseModel(PydanticBaseModel):
    class Config:
        arbitrary_types_allowed = True


class MyClass:
    """A random class"""


class Model(BaseModel):
    x: MyClass
Crowded Caracal

Pydantic arbitrary_types_allowed

from pydantic import BaseModel as PydanticBaseModel


class BaseModel(PydanticBaseModel):
    class Config:
        arbitrary_types_allowed = True


class MyClass:
    """A random class"""


class Model(BaseModel):
    x: MyClass
Crowded Caracal

Jawaban yang mirip dengan “Pydantic arbitrary_types_allowed”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya