diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index aabdfc22e..248d44ddd 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -63,7 +63,6 @@ ctypes.pointer ctypes.sizeof ctypes.wintypes.PCHAR.from_param ctypes.wintypes.PWCHAR.from_param -dbm.sqlite3 doctest.TestResults.__doc__ doctest.TestResults.__new__ email.utils.getaddresses diff --git a/stdlib/VERSIONS b/stdlib/VERSIONS index ae7377f55..58d7e8b0a 100644 --- a/stdlib/VERSIONS +++ b/stdlib/VERSIONS @@ -114,6 +114,7 @@ curses: 3.0- dataclasses: 3.7- datetime: 3.0- dbm: 3.0- +dbm.sqlite3: 3.13- decimal: 3.0- difflib: 3.0- dis: 3.0- diff --git a/stdlib/dbm/gnu.pyi b/stdlib/dbm/gnu.pyi index e80441cbb..1d1d541f5 100644 --- a/stdlib/dbm/gnu.pyi +++ b/stdlib/dbm/gnu.pyi @@ -19,6 +19,9 @@ if sys.platform != "win32": def reorganize(self) -> None: ... def sync(self) -> None: ... def close(self) -> None: ... + if sys.version_info >= (3, 13): + def clear(self) -> None: ... + def __getitem__(self, item: _KeyType) -> bytes: ... def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... def __delitem__(self, key: _KeyType) -> None: ... diff --git a/stdlib/dbm/ndbm.pyi b/stdlib/dbm/ndbm.pyi index 02bf23ec1..4113a7e3f 100644 --- a/stdlib/dbm/ndbm.pyi +++ b/stdlib/dbm/ndbm.pyi @@ -15,6 +15,9 @@ if sys.platform != "win32": # Actual typename dbm, not exposed by the implementation class _dbm: def close(self) -> None: ... + if sys.version_info >= (3, 13): + def clear(self) -> None: ... + def __getitem__(self, item: _KeyType) -> bytes: ... def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... def __delitem__(self, key: _KeyType) -> None: ... diff --git a/stdlib/dbm/sqlite3.pyi b/stdlib/dbm/sqlite3.pyi new file mode 100644 index 000000000..446a0cf15 --- /dev/null +++ b/stdlib/dbm/sqlite3.pyi @@ -0,0 +1,29 @@ +from _typeshed import ReadableBuffer, StrOrBytesPath, Unused +from collections.abc import Generator, MutableMapping +from typing import Final, Literal +from typing_extensions import LiteralString, Self, TypeAlias + +BUILD_TABLE: Final[LiteralString] +GET_SIZE: Final[LiteralString] +LOOKUP_KEY: Final[LiteralString] +STORE_KV: Final[LiteralString] +DELETE_KEY: Final[LiteralString] +ITER_KEYS: Final[LiteralString] + +_SqliteData: TypeAlias = str | ReadableBuffer | int | float + +class error(OSError): ... + +class _Database(MutableMapping[bytes, bytes]): + def __init__(self, path: StrOrBytesPath, /, *, flag: Literal["r", "w", "c", "n"], mode: int) -> None: ... + def __len__(self) -> int: ... + def __getitem__(self, key: _SqliteData) -> bytes: ... + def __setitem__(self, key: _SqliteData, value: _SqliteData) -> None: ... + def __delitem__(self, key: _SqliteData) -> None: ... + def __iter__(self) -> Generator[bytes]: ... + def close(self) -> None: ... + def keys(self) -> list[bytes]: ... # type: ignore[override] + def __enter__(self) -> Self: ... + def __exit__(self, *args: Unused) -> None: ... + +def open(filename: StrOrBytesPath, /, flag: Literal["r", "w,", "c", "n"] = "r", mode: int = 0o666) -> _Database: ...