mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
Add dbm stubs (#3508)
This commit is contained in:
committed by
Jelle Zijlstra
parent
5021b30711
commit
0c563130fd
11
stdlib/3/dbm/__init__.pyi
Normal file
11
stdlib/3/dbm/__init__.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
from typing import Union, MutableMapping
|
||||
|
||||
_KeyType = Union[str, bytes]
|
||||
_ValueType = Union[str, bytes]
|
||||
|
||||
class error(Exception): ...
|
||||
|
||||
def whichdb(filename: str) -> str: ...
|
||||
|
||||
def open(file: str, flag: str = ..., mode: int = ...) -> MutableMapping[_KeyType, _ValueType]: ...
|
||||
31
stdlib/3/dbm/dumb.pyi
Normal file
31
stdlib/3/dbm/dumb.pyi
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
import sys
|
||||
from typing import Union, MutableMapping, Iterator, Optional, Type
|
||||
from types import TracebackType
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Final
|
||||
else:
|
||||
from typing_extensions import Final
|
||||
|
||||
_KeyType = Union[str, bytes]
|
||||
_ValueType = Union[str, bytes]
|
||||
|
||||
error = OSError
|
||||
|
||||
class _Database(MutableMapping[_KeyType, bytes]):
|
||||
|
||||
def __init__(self, filebasename: str, mode: str, flag: str = ...) -> None: ...
|
||||
def sync(self) -> None: ...
|
||||
def iterkeys(self) -> Iterator[bytes]: ... # undocumented
|
||||
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: ...
|
||||
|
||||
def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ...
|
||||
36
stdlib/3/dbm/gnu.pyi
Normal file
36
stdlib/3/dbm/gnu.pyi
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
from typing import Union, Optional, Type, Iterator, overload, List, TypeVar, Generic
|
||||
from types import TracebackType
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_KeyType = Union[str, bytes]
|
||||
_ValueType = Union[str, bytes]
|
||||
|
||||
class error(OSError): ...
|
||||
|
||||
# Actual typename gdbm, not exposed by the implementation
|
||||
class _gdbm:
|
||||
def firstkey(self) -> Optional[bytes]: ...
|
||||
def nextkey(self, key: _KeyType) -> Optional[bytes]: ...
|
||||
def reorganize(self) -> None: ...
|
||||
def sync(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def __getitem__(self, item: _KeyType) -> bytes: ...
|
||||
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
|
||||
def __delitem__(self, key: _KeyType) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __enter__(self) -> _gdbm: ...
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
|
||||
|
||||
@overload
|
||||
def get(self, k: _KeyType) -> Optional[bytes]: ...
|
||||
@overload
|
||||
def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ...
|
||||
def keys(self) -> List[bytes]: ...
|
||||
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
|
||||
|
||||
# Don't exist at runtime
|
||||
__new__: None # type: ignore
|
||||
__init__: None # type: ignore
|
||||
|
||||
def open(file: str, flag: str = ..., mode: int = ...) -> _gdbm: ...
|
||||
36
stdlib/3/dbm/ndbm.pyi
Normal file
36
stdlib/3/dbm/ndbm.pyi
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
from typing import Generic, Union, Iterator, Optional, Type, TypeVar, overload, List
|
||||
from types import TracebackType
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_KeyType = Union[str, bytes]
|
||||
_ValueType = Union[str, bytes]
|
||||
|
||||
class error(OSError): ...
|
||||
|
||||
library: str = ...
|
||||
|
||||
# Actual typename dbm, not exposed by the implementation
|
||||
class _dbm:
|
||||
|
||||
def close(self) -> None: ...
|
||||
def __getitem__(self, item: _KeyType) -> bytes: ...
|
||||
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
|
||||
def __delitem__(self, key: _KeyType) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __del__(self) -> None: ...
|
||||
def __enter__(self) -> _dbm: ...
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
|
||||
|
||||
@overload
|
||||
def get(self, k: _KeyType) -> Optional[bytes]: ...
|
||||
@overload
|
||||
def get(self, k: _KeyType, default: Union[bytes, _T]) -> Union[bytes, _T]: ...
|
||||
def keys(self) -> List[bytes]: ...
|
||||
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
|
||||
|
||||
# Don't exist at runtime
|
||||
__new__: None # type: ignore
|
||||
__init__: None # type: ignore
|
||||
|
||||
def open(filename: str, flag: str = ..., mode: int = ...) -> _dbm: ...
|
||||
Reference in New Issue
Block a user