{"html_url": "https://github.com/simonw/sqlite-utils/issues/496#issuecomment-1291167887", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/496", "id": 1291167887, "node_id": "IC_kwDOCGYnMM5M9aiP", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-25T21:33:25Z", "updated_at": "2022-10-25T21:33:25Z", "author_association": "OWNER", "body": "I do care about this, but I'm not hugely experienced with types yet so I'm open to suggestions about how to do it!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1393202060, "label": "devrel/python api: Pylance type hinting"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/496#issuecomment-1291170072", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/496", "id": 1291170072, "node_id": "IC_kwDOCGYnMM5M9bEY", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-10-25T21:36:12Z", "updated_at": "2022-10-25T21:36:12Z", "author_association": "OWNER", "body": "I was going to suggest using `db.table(name)` instead of `db[name]` - but it looks like that method will have the same problem:\r\n\r\nhttps://github.com/simonw/sqlite-utils/blob/defa2974c6d3abc19be28d6b319649b8028dc966/sqlite_utils/db.py#L497-L506\r\n\r\nI could change `sqlite-utils` so `db.table(name)` always returns a table and you need to call `db.view(name)` if you want to access a view - that would require bumping to 4.0 though. I'm not convinced that's the best approach here either.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1393202060, "label": "devrel/python api: Pylance type hinting"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/496#issuecomment-1294408928", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/496", "id": 1294408928, "node_id": "IC_kwDOCGYnMM5NJxzg", "user": {"value": 39538958, "label": "justmars"}, "created_at": "2022-10-28T03:36:56Z", "updated_at": "2022-10-28T03:37:50Z", "author_association": "NONE", "body": "With respect to the typing of Table class itself, my interim solution:\r\n\r\n```python\r\nfrom sqlite_utils.db import Table\r\ndef tbl(self, table_name: str) -> Table:\r\n tbl = self.db[table_name]\r\n if isinstance(tbl, Table):\r\n return tbl\r\n raise Exception(f\"Missing {table_name=}\")\r\n```\r\n\r\nWith respect to @chapmanjacobd concern on the `DEFAULT` being an empty class, have also been using `# type: ignore`, e.g.\r\n\r\n```python\r\n@classmethod\r\ndef insert_list(cls, areas: list[str]):\r\n return meta.tbl(meta.Areas).insert_all(\r\n ({\"area\": a} for a in areas), ignore=True # type: ignore\r\n )\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1393202060, "label": "devrel/python api: Pylance type hinting"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/496#issuecomment-1532481862", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/496", "id": 1532481862, "node_id": "IC_kwDOCGYnMM5bV9FG", "user": {"value": 1231935, "label": "xavdid"}, "created_at": "2023-05-03T05:53:26Z", "updated_at": "2023-05-03T05:53:26Z", "author_association": "NONE", "body": "Would love to put our heads together for improvements here. \r\n\r\nI _think_ anything that is `argname=DEFAULT` needs to be typed as `argname: str | Default = DEFAULT` (replacing `str` with the appropriate type(s)). We may be able to get clever and tie the types to that key in the `_defaults` dict (definitely possible in Typescript, but I'm less familiar with advanced python types). \r\n\r\nRight now, all args are typed as `Default`, which means all callers get type errors. \r\n\r\nAs for table/view, given that they don't have the same methods, it would be nice to be able to get one or the other specifically.\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1393202060, "label": "devrel/python api: Pylance type hinting"}, "performed_via_github_app": null}