mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from types import TracebackType
|
||||
from typing import Iterator, MutableMapping, Tuple, Type, Union
|
||||
from typing import Iterator, MutableMapping, Union
|
||||
from typing_extensions import Literal
|
||||
|
||||
_KeyType = Union[str, bytes]
|
||||
@@ -15,12 +15,12 @@ class _Database(MutableMapping[_KeyType, bytes]):
|
||||
def __del__(self) -> None: ...
|
||||
def __enter__(self) -> _Database: ...
|
||||
def __exit__(
|
||||
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
class _error(Exception): ...
|
||||
|
||||
error = Tuple[Type[_error], Type[OSError]]
|
||||
error = tuple[type[_error], type[OSError]]
|
||||
|
||||
def whichdb(filename: str) -> str: ...
|
||||
def open(file: str, flag: Literal["r", "w", "c", "n"] = ..., mode: int = ...) -> _Database: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from types import TracebackType
|
||||
from typing import Iterator, MutableMapping, Type, Union
|
||||
from typing import Iterator, MutableMapping, Union
|
||||
|
||||
_KeyType = Union[str, bytes]
|
||||
_ValueType = Union[str, bytes]
|
||||
@@ -19,7 +19,7 @@ class _Database(MutableMapping[_KeyType, bytes]):
|
||||
def __del__(self) -> None: ...
|
||||
def __enter__(self) -> _Database: ...
|
||||
def __exit__(
|
||||
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
def open(file: str, flag: str = ..., mode: int = ...) -> _Database: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from types import TracebackType
|
||||
from typing import List, Type, TypeVar, Union, overload
|
||||
from typing import TypeVar, Union, overload
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_KeyType = Union[str, bytes]
|
||||
@@ -20,13 +20,13 @@ class _gdbm:
|
||||
def __len__(self) -> int: ...
|
||||
def __enter__(self) -> _gdbm: ...
|
||||
def __exit__(
|
||||
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
@overload
|
||||
def get(self, k: _KeyType) -> bytes | None: ...
|
||||
@overload
|
||||
def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ...
|
||||
def keys(self) -> List[bytes]: ...
|
||||
def keys(self) -> list[bytes]: ...
|
||||
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
|
||||
# Don't exist at runtime
|
||||
__new__: None # type: ignore
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from types import TracebackType
|
||||
from typing import List, Type, TypeVar, Union, overload
|
||||
from typing import TypeVar, Union, overload
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_KeyType = Union[str, bytes]
|
||||
@@ -19,13 +19,13 @@ class _dbm:
|
||||
def __del__(self) -> None: ...
|
||||
def __enter__(self) -> _dbm: ...
|
||||
def __exit__(
|
||||
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
@overload
|
||||
def get(self, k: _KeyType) -> bytes | None: ...
|
||||
@overload
|
||||
def get(self, k: _KeyType, default: bytes | _T) -> bytes | _T: ...
|
||||
def keys(self) -> List[bytes]: ...
|
||||
def keys(self) -> list[bytes]: ...
|
||||
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
|
||||
# Don't exist at runtime
|
||||
__new__: None # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user