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/pygrist_mini/__init__.py b/pygrist_mini/__init__.py index 0f984c9..44a37b2 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): @@ -29,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 @@ -124,7 +128,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: diff --git a/pyproject.toml b/pyproject.toml index 0d4482c..3cfa565 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,13 +4,13 @@ build-backend = "hatchling.build" [project] name = "pygrist_mini" -version = "2026.1" +version = "2026.1.1" authors = [ {name = "Andreas Kloeckner", email = "inform@tiker.net"}, ] description = "Minimal Grist API (document) client" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.10" license = "MIT" classifiers = [ "Development Status :: 3 - Alpha", @@ -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"