Incompatible type for get_or_create
vs. update
?
#792
-
I'm not a Python typing expert, but I'm wondering how to resolve this. Given: class Todo(Table):
todo_id = Integer(primary_key=True)
item = Text()
assignee = Text(null=True)
last_updated = Timestamp() and then: values: dict[Column, Any] = {
Todo.item: text,
Todo.assignee: user_id,
Todo.last_updated: datetime.now(timezone.utc),
}
if response := await Todo.objects().get_or_create(Todo.todo_id == todo_id, values):
if not response._was_created:
await Todo.update(values).where(Todo.todo_id == todo_id) mypy complains that:
FWIW, without the explicit
Any suggestions on at least getting the mypy error to go away? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yeah, this is a bit of a pain. I'd just ignore it for now using
Line 1115 in 56669fa To: values: t.Union[t.Mapping[Column, t.Any], t.Mapping[str, t.Any], None] = None, |
Beta Was this translation helpful? Give feedback.
Yeah, this is a bit of a pain. I'd just ignore it for now using
# type: ignore
.dict
is invariant so is very unforgiving. I'll change this line:piccolo/piccolo/table.py
Line 1115 in 56669fa
To: