-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync vendored typeshed stubs (#14350)
- Loading branch information
1 parent
9ec690b
commit 375cead
Showing
30 changed files
with
472 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
d262beb07502cda412db2179fb406d45d1a9486f | ||
5052fa2f18db4493892e0f2775030683c9d06531 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from _typeshed import ReadableBuffer | ||
from typing import final | ||
|
||
@final | ||
class BZ2Compressor: | ||
def __init__(self, compresslevel: int = 9) -> None: ... | ||
def compress(self, data: ReadableBuffer, /) -> bytes: ... | ||
def flush(self) -> bytes: ... | ||
|
||
@final | ||
class BZ2Decompressor: | ||
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ... | ||
@property | ||
def eof(self) -> bool: ... | ||
@property | ||
def needs_input(self) -> bool: ... | ||
@property | ||
def unused_data(self) -> bytes: ... |
61 changes: 61 additions & 0 deletions
61
crates/red_knot_vendored/vendor/typeshed/stdlib/_contextvars.pyi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import sys | ||
from collections.abc import Callable, Iterator, Mapping | ||
from typing import Any, ClassVar, Generic, TypeVar, final, overload | ||
from typing_extensions import ParamSpec | ||
|
||
if sys.version_info >= (3, 9): | ||
from types import GenericAlias | ||
|
||
_T = TypeVar("_T") | ||
_D = TypeVar("_D") | ||
_P = ParamSpec("_P") | ||
|
||
@final | ||
class ContextVar(Generic[_T]): | ||
@overload | ||
def __init__(self, name: str) -> None: ... | ||
@overload | ||
def __init__(self, name: str, *, default: _T) -> None: ... | ||
def __hash__(self) -> int: ... | ||
@property | ||
def name(self) -> str: ... | ||
@overload | ||
def get(self) -> _T: ... | ||
@overload | ||
def get(self, default: _T, /) -> _T: ... | ||
@overload | ||
def get(self, default: _D, /) -> _D | _T: ... | ||
def set(self, value: _T, /) -> Token[_T]: ... | ||
def reset(self, token: Token[_T], /) -> None: ... | ||
if sys.version_info >= (3, 9): | ||
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... | ||
|
||
@final | ||
class Token(Generic[_T]): | ||
@property | ||
def var(self) -> ContextVar[_T]: ... | ||
@property | ||
def old_value(self) -> Any: ... # returns either _T or MISSING, but that's hard to express | ||
MISSING: ClassVar[object] | ||
if sys.version_info >= (3, 9): | ||
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... | ||
|
||
def copy_context() -> Context: ... | ||
|
||
# It doesn't make sense to make this generic, because for most Contexts each ContextVar will have | ||
# a different value. | ||
@final | ||
class Context(Mapping[ContextVar[Any], Any]): | ||
def __init__(self) -> None: ... | ||
@overload | ||
def get(self, key: ContextVar[_T], default: None = None, /) -> _T | None: ... | ||
@overload | ||
def get(self, key: ContextVar[_T], default: _T, /) -> _T: ... | ||
@overload | ||
def get(self, key: ContextVar[_T], default: _D, /) -> _T | _D: ... | ||
def run(self, callable: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> _T: ... | ||
def copy(self) -> Context: ... | ||
def __getitem__(self, key: ContextVar[_T], /) -> _T: ... | ||
def __iter__(self) -> Iterator[ContextVar[Any]]: ... | ||
def __len__(self) -> int: ... | ||
def __eq__(self, value: object, /) -> bool: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import sys | ||
from _typeshed import ReadOnlyBuffer, StrOrBytesPath | ||
from types import TracebackType | ||
from typing import TypeVar, overload | ||
from typing_extensions import Self, TypeAlias | ||
|
||
if sys.platform != "win32": | ||
_T = TypeVar("_T") | ||
_KeyType: TypeAlias = str | ReadOnlyBuffer | ||
_ValueType: TypeAlias = str | ReadOnlyBuffer | ||
|
||
class error(OSError): ... | ||
library: str | ||
|
||
# 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: ... | ||
def __len__(self) -> int: ... | ||
def __del__(self) -> None: ... | ||
def __enter__(self) -> Self: ... | ||
def __exit__( | ||
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: _T) -> bytes | _T: ... | ||
def keys(self) -> list[bytes]: ... | ||
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... | ||
# Don't exist at runtime | ||
__new__: None # type: ignore[assignment] | ||
__init__: None # type: ignore[assignment] | ||
|
||
if sys.version_info >= (3, 11): | ||
def open(filename: StrOrBytesPath, flags: str = "r", mode: int = 0o666, /) -> _dbm: ... | ||
else: | ||
def open(filename: str, flags: str = "r", mode: int = 0o666, /) -> _dbm: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import sys | ||
from _typeshed import ReadOnlyBuffer, StrOrBytesPath | ||
from types import TracebackType | ||
from typing import TypeVar, overload | ||
from typing_extensions import Self, TypeAlias | ||
|
||
if sys.platform != "win32": | ||
_T = TypeVar("_T") | ||
_KeyType: TypeAlias = str | ReadOnlyBuffer | ||
_ValueType: TypeAlias = str | ReadOnlyBuffer | ||
|
||
open_flags: str | ||
|
||
class error(OSError): ... | ||
# Actual typename gdbm, not exposed by the implementation | ||
class _gdbm: | ||
def firstkey(self) -> bytes | None: ... | ||
def nextkey(self, key: _KeyType) -> bytes | None: ... | ||
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: ... | ||
def __contains__(self, key: _KeyType) -> bool: ... | ||
def __len__(self) -> int: ... | ||
def __enter__(self) -> Self: ... | ||
def __exit__( | ||
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: _T) -> bytes | _T: ... | ||
def keys(self) -> list[bytes]: ... | ||
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ... | ||
# Don't exist at runtime | ||
__new__: None # type: ignore[assignment] | ||
__init__: None # type: ignore[assignment] | ||
|
||
if sys.version_info >= (3, 11): | ||
def open(filename: StrOrBytesPath, flags: str = "r", mode: int = 0o666, /) -> _gdbm: ... | ||
else: | ||
def open(filename: str, flags: str = "r", mode: int = 0o666, /) -> _gdbm: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.