mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
dbm: fix bytes handling (#9030)
This commit is contained in:
@@ -6,7 +6,7 @@ from typing_extensions import Literal, TypeAlias
|
||||
__all__ = ["open", "whichdb", "error"]
|
||||
|
||||
_KeyType: TypeAlias = str | bytes
|
||||
_ValueType: TypeAlias = str | bytes
|
||||
_ValueType: TypeAlias = str | bytes | bytearray
|
||||
_TFlags: TypeAlias = Literal[
|
||||
"r",
|
||||
"w",
|
||||
|
||||
@@ -10,6 +10,9 @@ _ValueType: TypeAlias = str | bytes
|
||||
|
||||
error = OSError
|
||||
|
||||
# This class doesn't exist at runtime. open() can return an instance of
|
||||
# any of the three implementations of dbm (dumb, gnu, ndbm), and this
|
||||
# class is intended to represent the common interface supported by all three.
|
||||
class _Database(MutableMapping[_KeyType, bytes]):
|
||||
def __init__(self, filebasename: str, mode: str, flag: str = ...) -> None: ...
|
||||
def sync(self) -> None: ...
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from _typeshed import ReadOnlyBuffer, Self
|
||||
from types import TracebackType
|
||||
from typing import TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform != "win32":
|
||||
_T = TypeVar("_T")
|
||||
_KeyType: TypeAlias = str | bytes
|
||||
_ValueType: TypeAlias = str | bytes
|
||||
_KeyType: TypeAlias = str | ReadOnlyBuffer
|
||||
_ValueType: TypeAlias = str | ReadOnlyBuffer
|
||||
|
||||
open_flags: str
|
||||
|
||||
@@ -31,7 +31,7 @@ if sys.platform != "win32":
|
||||
@overload
|
||||
def get(self, k: _KeyType) -> bytes | None: ...
|
||||
@overload
|
||||
def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ...
|
||||
def get(self, k: _KeyType, default: _T) -> bytes | _T: ...
|
||||
def keys(self) -> list[bytes]: ...
|
||||
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
|
||||
# Don't exist at runtime
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from _typeshed import ReadOnlyBuffer, Self
|
||||
from types import TracebackType
|
||||
from typing import TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.platform != "win32":
|
||||
_T = TypeVar("_T")
|
||||
_KeyType: TypeAlias = str | bytes
|
||||
_ValueType: TypeAlias = str | bytes
|
||||
_KeyType: TypeAlias = str | ReadOnlyBuffer
|
||||
_ValueType: TypeAlias = str | ReadOnlyBuffer
|
||||
|
||||
class error(OSError): ...
|
||||
library: str
|
||||
@@ -27,7 +27,7 @@ if sys.platform != "win32":
|
||||
@overload
|
||||
def get(self, k: _KeyType) -> bytes | None: ...
|
||||
@overload
|
||||
def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ...
|
||||
def get(self, k: _KeyType, default: _T) -> bytes | _T: ...
|
||||
def keys(self) -> list[bytes]: ...
|
||||
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
|
||||
# Don't exist at runtime
|
||||
|
||||
Reference in New Issue
Block a user