From 2627cf4986fecb407b846346502861728dd91bd6 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 25 Jan 2026 13:36:13 -0600 Subject: [PATCH 1/5] sql: return Any, not None --- pygrist_mini/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygrist_mini/__init__.py b/pygrist_mini/__init__.py index 0f984c9..c197983 100644 --- a/pygrist_mini/__init__.py +++ b/pygrist_mini/__init__.py @@ -124,7 +124,7 @@ def delete_records(self, table_id: str | int, ids: Sequence[int]) -> None: def sql( self, query: str, args: Sequence[object] | None = None, - timeout: float | None = None) -> Sequence[dict[str, object]]: + timeout: float | None = None) -> Sequence[dict[str, Any]]: json_body: dict[str, object] = {"sql": query} if args is not None: From 8993464ab48cfd2ce225ee70335d9013fcc8e63b Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 25 Jan 2026 13:36:49 -0600 Subject: [PATCH 2/5] Require Python 3.10 --- pygrist_mini/__init__.py | 13 +++++++++---- pyproject.toml | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pygrist_mini/__init__.py b/pygrist_mini/__init__.py index c197983..c59a57c 100644 --- a/pygrist_mini/__init__.py +++ b/pygrist_mini/__init__.py @@ -2,10 +2,15 @@ import datetime import json -from typing import Any, Mapping, Sequence, TypedDict +from dataclasses import dataclass +from typing import TYPE_CHECKING, Any, TypedDict +from zoneinfo import ZoneInfo import requests -from zoneinfo import ZoneInfo + + +if TYPE_CHECKING: + from collections.abc import Mapping, Sequence UTC = ZoneInfo("UTC") @@ -14,8 +19,8 @@ class HTTPError(RuntimeError): def __init__(self, status_code: int, message: str): super().__init__(f"Status {status_code}: {message}") - self.status_code = status_code - self.message = message + self.status_code: int = status_code + self.message: str = message class Record(TypedDict): diff --git a/pyproject.toml b/pyproject.toml index 0d4482c..7a2b40b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ authors = [ ] description = "Minimal Grist API (document) client" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.10" license = "MIT" classifiers = [ "Development Status :: 3 - Alpha", From 742a0fe41ef3ee0e26cd6c152ebb1860d6a32281 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 25 Jan 2026 13:36:25 -0600 Subject: [PATCH 3/5] GristClient: become dataclass --- pygrist_mini/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pygrist_mini/__init__.py b/pygrist_mini/__init__.py index c59a57c..44a37b2 100644 --- a/pygrist_mini/__init__.py +++ b/pygrist_mini/__init__.py @@ -34,14 +34,13 @@ def timestamp_to_date(tstamp: float) -> datetime.date: # {{{ grist client +@dataclass(frozen=True) class GristClient: """Grist API client""" - - def __init__(self, root_url, api_key, doc_id, timeout=None): - self.root_url = root_url - self.api_key = api_key - self.doc_id = doc_id - self.timeout = timeout + root_url: str + api_key: str + doc_id: str + timeout: float | None = None # {{{ generic request methods From fbe1374aeb0124a656f150838c269c41fe044f91 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 25 Jan 2026 13:37:05 -0600 Subject: [PATCH 4/5] Add basedpyright CI --- .basedpyright/baseline.json | 166 ++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 15 ++++ pyproject.toml | 8 ++ 3 files changed, 189 insertions(+) create mode 100644 .basedpyright/baseline.json diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json new file mode 100644 index 0000000..c7d37d6 --- /dev/null +++ b/.basedpyright/baseline.json @@ -0,0 +1,166 @@ +{ + "files": { + "./pygrist_mini/__init__.py": [ + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 17, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 17, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 29, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 29, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 16, + "endColumn": 22, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 24, + "endColumn": 53, + "lineCount": 1 + } + }, + { + "code": "reportUnknownMemberType", + "range": { + "startColumn": 15, + "endColumn": 28, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 26, + "endColumn": 30, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 26, + "endColumn": 30, + "lineCount": 1 + } + }, + { + "code": "reportUnknownMemberType", + "range": { + "startColumn": 15, + "endColumn": 28, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 38, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 29, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 29, + "lineCount": 1 + } + }, + { + "code": "reportUnknownMemberType", + "range": { + "startColumn": 15, + "endColumn": 28, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 37, + "endColumn": 41, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 29, + "endColumn": 41, + "lineCount": 1 + } + }, + { + "code": "reportUnknownMemberType", + "range": { + "startColumn": 15, + "endColumn": 31, + "lineCount": 1 + } + }, + { + "code": "reportUnknownMemberType", + "range": { + "startColumn": 19, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownMemberType", + "range": { + "startColumn": 8, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownMemberType", + "range": { + "startColumn": 27, + "endColumn": 42, + "lineCount": 1 + } + } + ] + } +} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4f20fd..63da833 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,4 +22,19 @@ jobs: pipx install ruff ruff check + basedpyright: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: "Main Script" + run: | + python -m venv .testenv + source .testenv/bin/activate + pip install . + pip install basedpyright + basedpyright --baselinemode=auto + # vim: sw=4 diff --git a/pyproject.toml b/pyproject.toml index 7a2b40b..ec6f552 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,3 +66,11 @@ multiline-quotes = "double" combine-as-imports = true lines-after-imports = 2 required-imports = ["from __future__ import annotations"] + +[tool.basedpyright] +reportImplicitStringConcatenation = "none" +reportUnnecessaryIsInstance = "none" +reportUnusedCallResult = "none" +reportExplicitAny = "none" +reportUnreachable = "hint" +reportAny = "none" From db9eeca642c06851bdf36906a9c06a05697fb785 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 25 Jan 2026 13:37:40 -0600 Subject: [PATCH 5/5] Bump version to 2026.1.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ec6f552..3cfa565 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pygrist_mini" -version = "2026.1" +version = "2026.1.1" authors = [ {name = "Andreas Kloeckner", email = "inform@tiker.net"}, ]