-
-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
I have a model with an attribute of 'model'. This bombs out model_from_dict as it has a param named 'model' and this causes a conflict with the attribute on the passed in dict.
Our workaround is to rename our attribute to 'model_' to get around the keyword argument conflict.
There are some fixes I can think off the top of my head, but they also have their issues
- rename the model input parameter to something less likely to conflict
- allow for a dictionary to be input as a kw argument in addition to the current method
URL to code causing the issue
No response
MCVE
class UUIDCar(UUIDAuditBase):
"""The car domain model."""
make: Mapped[str] = mapped_column(String(length=50))
model: Mapped[str] = mapped_column(String(length=50))
def test_dict_has_model_attribute() -> None:
from tests.fixtures.uuid.models import UUIDCar
data = {
"make": "Advanced",
"model": "Alchemy"
}
car = model_from_dict(UUIDCar, **data)
assert car.make == "Advanced"
assert car.model == "Alchemy"Steps to reproduce
1. Create class with an attribute 'model'
2. Attempt to instantiate it with model_from_dictScreenshots
"In the format of: "
Logs
Package Version
1.8.2
Platform
- Linux
- Mac
- Windows
- Other (Please specify in the description above)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working