From aabea4373f44db0f66236388a2a909f8f1fb7779 Mon Sep 17 00:00:00 2001 From: HeeJae Chang Date: Tue, 28 Jul 2026 01:45:57 -0700 Subject: [PATCH 1/2] Add partial type stubs for safe modules Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- pgspecial/help/commands.pyi | 1 + pgspecial/namedqueries.pyi | 25 +++++++++++++++++++++++++ pgspecial/py.typed | 0 3 files changed, 26 insertions(+) create mode 100644 pgspecial/help/commands.pyi create mode 100644 pgspecial/namedqueries.pyi create mode 100644 pgspecial/py.typed diff --git a/pgspecial/help/commands.pyi b/pgspecial/help/commands.pyi new file mode 100644 index 0000000..272144e --- /dev/null +++ b/pgspecial/help/commands.pyi @@ -0,0 +1 @@ +helpcommands: dict[str, dict[str, str]] diff --git a/pgspecial/namedqueries.pyi b/pgspecial/namedqueries.pyi new file mode 100644 index 0000000..9455197 --- /dev/null +++ b/pgspecial/namedqueries.pyi @@ -0,0 +1,25 @@ +from collections.abc import MutableMapping +from typing import ClassVar, Protocol, TypeVar + +_DefaultT = TypeVar("_DefaultT") + +class _Config(Protocol): + def __contains__(self, key: object) -> bool: ... + def __getitem__(self, key: str) -> MutableMapping[str, str]: ... + def __setitem__(self, key: str, value: MutableMapping[str, str]) -> None: ... + def get(self, key: str, default: _DefaultT) -> MutableMapping[str, str] | _DefaultT: ... + def write(self) -> object: ... + +class NamedQueries: + section_name: ClassVar[str] + usage: ClassVar[str] + instance: ClassVar[NamedQueries | None] + config: _Config + + def __init__(self, config: _Config) -> None: ... + @classmethod + def from_config(cls, config: _Config) -> NamedQueries: ... + def list(self) -> MutableMapping[str, str] | list[object]: ... + def get(self, name: str) -> str | None: ... + def save(self, name: str, query: str) -> None: ... + def delete(self, name: str) -> str: ... diff --git a/pgspecial/py.typed b/pgspecial/py.typed new file mode 100644 index 0000000..e69de29 From 2a01b90827bb304f5a689a0ed3e4c07b05124bc7 Mon Sep 17 00:00:00 2001 From: HeeJae Chang Date: Tue, 28 Jul 2026 14:51:00 -0700 Subject: [PATCH 2/2] Narrow empty named-query fallback type Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- pgspecial/namedqueries.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgspecial/namedqueries.pyi b/pgspecial/namedqueries.pyi index 9455197..291927f 100644 --- a/pgspecial/namedqueries.pyi +++ b/pgspecial/namedqueries.pyi @@ -1,5 +1,5 @@ from collections.abc import MutableMapping -from typing import ClassVar, Protocol, TypeVar +from typing import ClassVar, NoReturn, Protocol, TypeVar _DefaultT = TypeVar("_DefaultT") @@ -19,7 +19,7 @@ class NamedQueries: def __init__(self, config: _Config) -> None: ... @classmethod def from_config(cls, config: _Config) -> NamedQueries: ... - def list(self) -> MutableMapping[str, str] | list[object]: ... + def list(self) -> MutableMapping[str, str] | list[NoReturn]: ... def get(self, name: str) -> str | None: ... def save(self, name: str, query: str) -> None: ... def delete(self, name: str) -> str: ...