Skip to content

fix: correct Table.update transform type hints - #621

Open
uadhran wants to merge 1 commit into
msiemens:masterfrom
uadhran:fix/598-354
Open

fix: correct Table.update transform type hints#621
uadhran wants to merge 1 commit into
msiemens:masterfrom
uadhran:fix/598-354

Conversation

@uadhran

@uadhran uadhran commented Jul 1, 2026

Copy link
Copy Markdown

Table.update and Table.update_multiple annotated transform callables as
Callable[[Mapping], None], but transforms mutate documents in place (e.g.
tinydb.operations.delete uses del doc[field]). Mapping has no
__delitem__, so the hints were inaccurate.

Changes

  • Change callable parameter to Callable[[MutableMapping], None] in
    Table.update and Table.update_multiple
  • Add test_update_custom_transform_callable for custom transforms and
    tinydb.operations helpers

Verification

  • uv run py.test -v --cov=tinydb — 218 passed
  • uv run py.test -v --pycodestyle — not run (pre-existing failures on master)

Related: #598

Change update/update_multiple callable parameters from Mapping to
MutableMapping so transform functions that mutate documents in place
(like tinydb.operations helpers) match the actual runtime contract.

Add test_update_custom_transform_callable to verify custom transforms
and tinydb.operations helpers work via Table.update.

Related: msiemens#598
@uadhran uadhran changed the title fix: Table.update type hints and document moving documents between tables fix: correct Table.update transform type hints Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant