Open etjones opened 2 months ago
Here's a pattern that casts calls to DB[
from sqlite_utils import Database
from sqlite_utils.db import Table
from typing import cast
DB = Database("example.db")
table = cast(Table, DB["my_table"]) # this avoids errors, but it's a mouthful every time you use a table
table.upsert({"name": "example", "value": 42}, pk="id") # upsert() call is happy, although literal "id" is sometimes an issue
Duplicate of the unresolved closed bug #607.
Here's perfectly valid
sqlite_utils
code that raises objections from Mypy & Pyright/PyLance in VS Code:Is there a workaround or another approach that wouldn't throw these spurious errors?