You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class PublicPersonInfo(BaseModel):
name: Optional[str] = None
address: Optional[Address] = None
if name == 'main':
address = Address(street="Main Street",number=1,zip_code=100001,city='Test City')
info = PersonInfo(name='John Doe', age=35, address=address)
# default deepcopy behavior
public_info = mapper.to(PublicPersonInfo).map(info)
print("Target public_info.address is same as source address: ", address is public_info.address)
# Target public_info.address is same as source address: False
# disable deepcopy
public_info = mapper.to(PublicPersonInfo).map(info, use_deepcopy=False)
print("Target public_info.address is same as source address: ", address is public_info.address)
# Target public_info.address is same as source address: True
When run these code an exception was throwed, please help me to figure out an solution, thanks
The text was updated successfully, but these errors were encountered:
changuncle
changed the title
type(obj)() how to create an instance
BaseModel.__init__() takes 1 positional argument but 2 were given
Jul 15, 2024
class Address(BaseModel):
street: Optional[str]
number: Optional[int]
zip_code: Optional[int]
city: Optional[str]
class PersonInfo(BaseModel):
name: Optional[str] = None
age: Optional[int] = None
address: Optional[Address] = None
class PublicPersonInfo(BaseModel):
name: Optional[str] = None
address: Optional[Address] = None
if name == 'main':
address = Address(street="Main Street",number=1,zip_code=100001,city='Test City')
When run these code an exception was throwed, please help me to figure out an solution, thanks
The text was updated successfully, but these errors were encountered: