Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 166 additions & 0 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
}
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 15 additions & 11 deletions pygrist_mini/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"