From 5f70d3721a2afb36eb2c9afba50c476610cb6628 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Tue, 9 Jun 2020 11:20:09 +0100 Subject: [PATCH] Update root dbm module. (#4199) --- stdlib/3/dbm/__init__.pyi | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/stdlib/3/dbm/__init__.pyi b/stdlib/3/dbm/__init__.pyi index 782b6ab24..338fe7744 100644 --- a/stdlib/3/dbm/__init__.pyi +++ b/stdlib/3/dbm/__init__.pyi @@ -1,11 +1,25 @@ +import sys +from types import TracebackType +from typing import Iterator, Optional, Type, Union, MutableMapping -from typing import Union, MutableMapping +from typing_extensions import Literal _KeyType = Union[str, bytes] _ValueType = Union[str, bytes] +class _Database(MutableMapping[_KeyType, bytes]): + def close(self) -> None: ... + def __getitem__(self, key: _KeyType) -> bytes: ... + def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ... + def __delitem__(self, key: _KeyType) -> None: ... + def __iter__(self) -> Iterator[bytes]: ... + def __len__(self) -> int: ... + def __del__(self) -> None: ... + def __enter__(self) -> _Database: ... + def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ... + class error(Exception): ... def whichdb(filename: str) -> str: ... -def open(file: str, flag: str = ..., mode: int = ...) -> MutableMapping[_KeyType, _ValueType]: ... +def open(file: str, flag: Literal['r', 'w', 'c', 'n'] = ..., mode: int = ...) -> _Database: ...