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? |
Answered by
dantownsend
Mar 16, 2023
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, |
1 reply
Answer selected by
eddyg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, this is a bit of a pain. I'd just ignore it for now using
# type: ignore.dictis invariant so is very unforgiving. I'll change this line:piccolo/piccolo/table.py
Line 1115 in 56669fa
To: