Skip to content

Improve typing for db["table"] usage#721

Open
RamiNoodle733 wants to merge 1 commit intosimonw:mainfrom
RamiNoodle733:fix/issue-638
Open

Improve typing for db["table"] usage#721
RamiNoodle733 wants to merge 1 commit intosimonw:mainfrom
RamiNoodle733:fix/issue-638

Conversation

@RamiNoodle733
Copy link

@RamiNoodle733 RamiNoodle733 commented Mar 8, 2026

Summary

  • annotate Database.__getitem__ as returning Table for static type checkers
  • keep existing runtime behavior for views by casting the view return path
  • add typing-focused regression tests for the return annotation and view runtime behavior

Why

Fixes #638, where mypy/pyright report errors for common db["name"].create(...) and upsert(...) usage.

Validation

  • uv run flake8 sqlite_utils/db.py tests/test_typing.py
  • uv run mypy sqlite_utils tests
  • uv run pytest tests/test_typing.py -q
  • uv run pytest tests/test_create.py -k view -q

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.

Mypy & Pyright show errors for basic sqlite-utils usage

1 participant