Repository navigation
Conversation
String IDs such as '1' already worked with get() via str lookup, but update/remove compared them to int table keys and silently no-oped. Coerce through document_id_class so both paths agree. Fixes msiemens#639
CI failed on Python 3.14 mypy: get(doc_id='1') and update/remove with doc_ids=['1'] did not match annotations that only allowed int. - Annotate get/update/remove to accept int | str IDs - Coerce get(doc_id=...) through document_id_class like other read paths - Narrow Document | None in the regression test before indexing
|
Fixed the Python 3.14 mypy failures: annotations for |
|
Thanks for the PR! The main question is how to handle invalid IDs. Say one uses Given that #616 was written explicitly to handle missing document IDs like this, I think we should keep that behavior while coercing IDs where possible. What do you think? |
|
Good point, thanks for catching that. I'd rather not raise on bad IDs, and I don't want What I'd do is only coerce when it's safe: a real int stays as-is, and a string like That still fixes Happy to update the PR that way if it sounds right to you. |
|
Yes, that sonds about right. A minor wrinkle to look out for is that not all document IDs are |
Summary
get(doc_id='1')finds a document, butupdate/removewithdoc_ids=['1']returned[]and changed nothing because table keys are ints.Per #639 option (1): coerce IDs with
document_id_classinupdate/remove, matchingget’s ability to accept stringified IDs.Fixes #639
Test plan
test_doc_ids_string_coerciondoc_ids=['1']