MicroPython stuff

This commit is contained in:
Ádám Kovács
2023-11-07 14:00:27 +01:00
parent 56146a6307
commit 36638e2dd1
170 changed files with 23479 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
from typing_extensions import TypeAlias
_VersionInfo: TypeAlias = tuple[int, int, int, str, int]
class _Feature:
def __init__(self, optionalRelease: _VersionInfo, mandatoryRelease: _VersionInfo | None, compiler_flag: int) -> None: ...
def getOptionalRelease(self) -> _VersionInfo: ...
def getMandatoryRelease(self) -> _VersionInfo | None: ...
compiler_flag: int
absolute_import: _Feature
division: _Feature
generators: _Feature
nested_scopes: _Feature
print_function: _Feature
unicode_literals: _Feature
with_statement: _Feature
barry_as_FLUFL: _Feature
generator_stop: _Feature
annotations: _Feature
all_feature_names: list[str] # undocumented
__all__ = [
"all_feature_names",
"absolute_import",
"division",
"generators",
"nested_scopes",
"print_function",
"unicode_literals",
"with_statement",
"barry_as_FLUFL",
"generator_stop",
"annotations",
]

573
.vscode/Pico-W-Stub/stdlib/_ast.pyi vendored Normal file
View File

@@ -0,0 +1,573 @@
import sys
from typing import Any, ClassVar
from typing_extensions import Literal, TypeAlias
PyCF_ONLY_AST: Literal[1024]
if sys.version_info >= (3, 8):
PyCF_TYPE_COMMENTS: Literal[4096]
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
_Identifier: TypeAlias = str
class AST:
if sys.version_info >= (3, 10):
__match_args__ = ()
_attributes: ClassVar[tuple[str, ...]]
_fields: ClassVar[tuple[str, ...]]
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
# TODO: Not all nodes have all of the following attributes
lineno: int
col_offset: int
if sys.version_info >= (3, 8):
end_lineno: int | None
end_col_offset: int | None
type_comment: str | None
class mod(AST): ...
if sys.version_info >= (3, 8):
class type_ignore(AST): ...
class TypeIgnore(type_ignore):
if sys.version_info >= (3, 10):
__match_args__ = ("lineno", "tag")
tag: str
class FunctionType(mod):
if sys.version_info >= (3, 10):
__match_args__ = ("argtypes", "returns")
argtypes: list[expr]
returns: expr
class Module(mod):
if sys.version_info >= (3, 10):
__match_args__ = ("body", "type_ignores")
body: list[stmt]
if sys.version_info >= (3, 8):
type_ignores: list[TypeIgnore]
class Interactive(mod):
if sys.version_info >= (3, 10):
__match_args__ = ("body",)
body: list[stmt]
class Expression(mod):
if sys.version_info >= (3, 10):
__match_args__ = ("body",)
body: expr
class stmt(AST): ...
class FunctionDef(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
name: _Identifier
args: arguments
body: list[stmt]
decorator_list: list[expr]
returns: expr | None
class AsyncFunctionDef(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("name", "args", "body", "decorator_list", "returns", "type_comment")
name: _Identifier
args: arguments
body: list[stmt]
decorator_list: list[expr]
returns: expr | None
class ClassDef(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("name", "bases", "keywords", "body", "decorator_list")
name: _Identifier
bases: list[expr]
keywords: list[keyword]
body: list[stmt]
decorator_list: list[expr]
class Return(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("value",)
value: expr | None
class Delete(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("targets",)
targets: list[expr]
class Assign(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("targets", "value", "type_comment")
targets: list[expr]
value: expr
class AugAssign(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "op", "value")
target: expr
op: operator
value: expr
class AnnAssign(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "annotation", "value", "simple")
target: expr
annotation: expr
value: expr | None
simple: int
class For(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "iter", "body", "orelse", "type_comment")
target: expr
iter: expr
body: list[stmt]
orelse: list[stmt]
class AsyncFor(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "iter", "body", "orelse", "type_comment")
target: expr
iter: expr
body: list[stmt]
orelse: list[stmt]
class While(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("test", "body", "orelse")
test: expr
body: list[stmt]
orelse: list[stmt]
class If(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("test", "body", "orelse")
test: expr
body: list[stmt]
orelse: list[stmt]
class With(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("items", "body", "type_comment")
items: list[withitem]
body: list[stmt]
class AsyncWith(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("items", "body", "type_comment")
items: list[withitem]
body: list[stmt]
class Raise(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("exc", "cause")
exc: expr | None
cause: expr | None
class Try(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("body", "handlers", "orelse", "finalbody")
body: list[stmt]
handlers: list[ExceptHandler]
orelse: list[stmt]
finalbody: list[stmt]
if sys.version_info >= (3, 11):
class TryStar(stmt):
__match_args__ = ("body", "handlers", "orelse", "finalbody")
body: list[stmt]
handlers: list[ExceptHandler]
orelse: list[stmt]
finalbody: list[stmt]
class Assert(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("test", "msg")
test: expr
msg: expr | None
class Import(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("names",)
names: list[alias]
class ImportFrom(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("module", "names", "level")
module: str | None
names: list[alias]
level: int
class Global(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("names",)
names: list[_Identifier]
class Nonlocal(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("names",)
names: list[_Identifier]
class Expr(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("value",)
value: expr
class Pass(stmt): ...
class Break(stmt): ...
class Continue(stmt): ...
class expr(AST): ...
class BoolOp(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("op", "values")
op: boolop
values: list[expr]
class BinOp(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("left", "op", "right")
left: expr
op: operator
right: expr
class UnaryOp(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("op", "operand")
op: unaryop
operand: expr
class Lambda(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("args", "body")
args: arguments
body: expr
class IfExp(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("test", "body", "orelse")
test: expr
body: expr
orelse: expr
class Dict(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("keys", "values")
keys: list[expr | None]
values: list[expr]
class Set(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("elts",)
elts: list[expr]
class ListComp(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("elt", "generators")
elt: expr
generators: list[comprehension]
class SetComp(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("elt", "generators")
elt: expr
generators: list[comprehension]
class DictComp(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("key", "value", "generators")
key: expr
value: expr
generators: list[comprehension]
class GeneratorExp(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("elt", "generators")
elt: expr
generators: list[comprehension]
class Await(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value",)
value: expr
class Yield(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value",)
value: expr | None
class YieldFrom(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value",)
value: expr
class Compare(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("left", "ops", "comparators")
left: expr
ops: list[cmpop]
comparators: list[expr]
class Call(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("func", "args", "keywords")
func: expr
args: list[expr]
keywords: list[keyword]
class FormattedValue(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value", "conversion", "format_spec")
value: expr
conversion: int
format_spec: expr | None
class JoinedStr(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("values",)
values: list[expr]
if sys.version_info < (3, 8):
class Num(expr): # Deprecated in 3.8; use Constant
n: complex
class Str(expr): # Deprecated in 3.8; use Constant
s: str
class Bytes(expr): # Deprecated in 3.8; use Constant
s: bytes
class NameConstant(expr): # Deprecated in 3.8; use Constant
value: Any
class Ellipsis(expr): ... # Deprecated in 3.8; use Constant
class Constant(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value", "kind")
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
kind: str | None
# Aliases for value, for backwards compatibility
s: Any
n: complex
if sys.version_info >= (3, 8):
class NamedExpr(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "value")
target: expr
value: expr
class Attribute(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value", "attr", "ctx")
value: expr
attr: _Identifier
ctx: expr_context
if sys.version_info >= (3, 9):
_Slice: TypeAlias = expr
else:
class slice(AST): ...
_Slice: TypeAlias = slice
class Slice(_Slice):
if sys.version_info >= (3, 10):
__match_args__ = ("lower", "upper", "step")
lower: expr | None
upper: expr | None
step: expr | None
if sys.version_info < (3, 9):
class ExtSlice(slice):
dims: list[slice]
class Index(slice):
value: expr
class Subscript(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value", "slice", "ctx")
value: expr
slice: _Slice
ctx: expr_context
class Starred(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value", "ctx")
value: expr
ctx: expr_context
class Name(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("id", "ctx")
id: _Identifier
ctx: expr_context
class List(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("elts", "ctx")
elts: list[expr]
ctx: expr_context
class Tuple(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("elts", "ctx")
elts: list[expr]
ctx: expr_context
if sys.version_info >= (3, 9):
dims: list[expr]
class expr_context(AST): ...
if sys.version_info < (3, 9):
class AugLoad(expr_context): ...
class AugStore(expr_context): ...
class Param(expr_context): ...
class Suite(mod):
body: list[stmt]
class Del(expr_context): ...
class Load(expr_context): ...
class Store(expr_context): ...
class boolop(AST): ...
class And(boolop): ...
class Or(boolop): ...
class operator(AST): ...
class Add(operator): ...
class BitAnd(operator): ...
class BitOr(operator): ...
class BitXor(operator): ...
class Div(operator): ...
class FloorDiv(operator): ...
class LShift(operator): ...
class Mod(operator): ...
class Mult(operator): ...
class MatMult(operator): ...
class Pow(operator): ...
class RShift(operator): ...
class Sub(operator): ...
class unaryop(AST): ...
class Invert(unaryop): ...
class Not(unaryop): ...
class UAdd(unaryop): ...
class USub(unaryop): ...
class cmpop(AST): ...
class Eq(cmpop): ...
class Gt(cmpop): ...
class GtE(cmpop): ...
class In(cmpop): ...
class Is(cmpop): ...
class IsNot(cmpop): ...
class Lt(cmpop): ...
class LtE(cmpop): ...
class NotEq(cmpop): ...
class NotIn(cmpop): ...
class comprehension(AST):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "iter", "ifs", "is_async")
target: expr
iter: expr
ifs: list[expr]
is_async: int
class excepthandler(AST): ...
class ExceptHandler(excepthandler):
if sys.version_info >= (3, 10):
__match_args__ = ("type", "name", "body")
type: expr | None
name: _Identifier | None
body: list[stmt]
class arguments(AST):
if sys.version_info >= (3, 10):
__match_args__ = ("posonlyargs", "args", "vararg", "kwonlyargs", "kw_defaults", "kwarg", "defaults")
if sys.version_info >= (3, 8):
posonlyargs: list[arg]
args: list[arg]
vararg: arg | None
kwonlyargs: list[arg]
kw_defaults: list[expr | None]
kwarg: arg | None
defaults: list[expr]
class arg(AST):
if sys.version_info >= (3, 10):
__match_args__ = ("arg", "annotation", "type_comment")
arg: _Identifier
annotation: expr | None
class keyword(AST):
if sys.version_info >= (3, 10):
__match_args__ = ("arg", "value")
arg: _Identifier | None
value: expr
class alias(AST):
if sys.version_info >= (3, 10):
__match_args__ = ("name", "asname")
name: _Identifier
asname: _Identifier | None
class withitem(AST):
if sys.version_info >= (3, 10):
__match_args__ = ("context_expr", "optional_vars")
context_expr: expr
optional_vars: expr | None
if sys.version_info >= (3, 10):
class Match(stmt):
__match_args__ = ("subject", "cases")
subject: expr
cases: list[match_case]
class pattern(AST): ...
# Without the alias, Pyright complains variables named pattern are recursively defined
_Pattern: TypeAlias = pattern
class match_case(AST):
__match_args__ = ("pattern", "guard", "body")
pattern: _Pattern
guard: expr | None
body: list[stmt]
class MatchValue(pattern):
__match_args__ = ("value",)
value: expr
class MatchSingleton(pattern):
__match_args__ = ("value",)
value: Literal[True, False, None]
class MatchSequence(pattern):
__match_args__ = ("patterns",)
patterns: list[pattern]
class MatchStar(pattern):
__match_args__ = ("name",)
name: _Identifier | None
class MatchMapping(pattern):
__match_args__ = ("keys", "patterns", "rest")
keys: list[expr]
patterns: list[pattern]
rest: _Identifier | None
class MatchClass(pattern):
__match_args__ = ("cls", "patterns", "kwd_attrs", "kwd_patterns")
cls: expr
patterns: list[pattern]
kwd_attrs: list[_Identifier]
kwd_patterns: list[pattern]
class MatchAs(pattern):
__match_args__ = ("pattern", "name")
pattern: _Pattern | None
name: _Identifier | None
class MatchOr(pattern):
__match_args__ = ("patterns",)
patterns: list[pattern]

136
.vscode/Pico-W-Stub/stdlib/_codecs.pyi vendored Normal file
View File

@@ -0,0 +1,136 @@
import codecs
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from typing import overload
from typing_extensions import Literal, TypeAlias
# This type is not exposed; it is defined in unicodeobject.c
class _EncodingMap:
def size(self) -> int: ...
_CharMap: TypeAlias = dict[int, int] | _EncodingMap
_Handler: TypeAlias = Callable[[UnicodeError], tuple[str | bytes, int]]
_SearchFunction: TypeAlias = Callable[[str], codecs.CodecInfo | None]
def register(__search_function: _SearchFunction) -> None: ...
if sys.version_info >= (3, 10):
def unregister(__search_function: _SearchFunction) -> None: ...
def register_error(__errors: str, __handler: _Handler) -> None: ...
def lookup_error(__name: str) -> _Handler: ...
# The type ignore on `encode` and `decode` is to avoid issues with overlapping overloads, for more details, see #300
# https://docs.python.org/3/library/codecs.html#binary-transforms
_BytesToBytesEncoding: TypeAlias = Literal[
"base64",
"base_64",
"base64_codec",
"bz2",
"bz2_codec",
"hex",
"hex_codec",
"quopri",
"quotedprintable",
"quoted_printable",
"quopri_codec",
"uu",
"uu_codec",
"zip",
"zlib",
"zlib_codec",
]
# https://docs.python.org/3/library/codecs.html#text-transforms
_StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"]
@overload
def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = ...) -> bytes: ...
@overload
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = ...) -> str: ... # type: ignore[misc]
@overload
def encode(obj: str, encoding: str = ..., errors: str = ...) -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = ...) -> bytes: ... # type: ignore[misc]
@overload
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = ...) -> str: ...
# these are documented as text encodings but in practice they also accept str as input
@overload
def decode(
obj: str, encoding: Literal["unicode_escape", "unicode-escape", "raw_unicode_escape", "raw-unicode-escape"], errors: str = ...
) -> str: ...
# hex is officially documented as a bytes to bytes encoding, but it appears to also work with str
@overload
def decode(obj: str, encoding: Literal["hex", "hex_codec"], errors: str = ...) -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: str = ..., errors: str = ...) -> str: ...
def lookup(__encoding: str) -> codecs.CodecInfo: ...
def charmap_build(__map: str) -> _CharMap: ...
def ascii_decode(__data: ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def ascii_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def charmap_decode(__data: ReadableBuffer, __errors: str | None = ..., __mapping: _CharMap | None = ...) -> tuple[str, int]: ...
def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _CharMap | None = ...) -> tuple[bytes, int]: ...
def escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def escape_encode(__data: bytes, __errors: str | None = ...) -> tuple[bytes, int]: ...
def latin_1_decode(__data: ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def latin_1_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
if sys.version_info >= (3, 9):
def raw_unicode_escape_decode(
__data: str | ReadableBuffer, __errors: str | None = ..., __final: bool = ...
) -> tuple[str, int]: ...
else:
def raw_unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def raw_unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def readbuffer_encode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[bytes, int]: ...
if sys.version_info >= (3, 9):
def unicode_escape_decode(
__data: str | ReadableBuffer, __errors: str | None = ..., __final: bool = ...
) -> tuple[str, int]: ...
else:
def unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def unicode_escape_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
if sys.version_info < (3, 8):
def unicode_internal_decode(__obj: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ...
def unicode_internal_encode(__obj: str | ReadableBuffer, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_16_be_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_16_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ...
def utf_16_ex_decode(
__data: ReadableBuffer, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
) -> tuple[str, int, int]: ...
def utf_16_le_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_16_le_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_32_be_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_be_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_32_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_encode(__str: str, __errors: str | None = ..., __byteorder: int = ...) -> tuple[bytes, int]: ...
def utf_32_ex_decode(
__data: ReadableBuffer, __errors: str | None = ..., __byteorder: int = ..., __final: int = ...
) -> tuple[str, int, int]: ...
def utf_32_le_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_32_le_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_7_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_7_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def utf_8_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def utf_8_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
if sys.platform == "win32":
def mbcs_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def mbcs_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def code_page_decode(
__codepage: int, __data: ReadableBuffer, __errors: str | None = ..., __final: int = ...
) -> tuple[str, int]: ...
def code_page_encode(__code_page: int, __str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...
def oem_decode(__data: ReadableBuffer, __errors: str | None = ..., __final: int = ...) -> tuple[str, int]: ...
def oem_encode(__str: str, __errors: str | None = ...) -> tuple[bytes, int]: ...

View File

@@ -0,0 +1,81 @@
import sys
from types import MappingProxyType
from typing import ( # noqa: Y027,Y038
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable,
Collection as Collection,
Container as Container,
Coroutine as Coroutine,
Generator as Generator,
Generic,
Hashable as Hashable,
ItemsView as ItemsView,
Iterable as Iterable,
Iterator as Iterator,
KeysView as KeysView,
Mapping as Mapping,
MappingView as MappingView,
MutableMapping as MutableMapping,
MutableSequence as MutableSequence,
MutableSet as MutableSet,
Reversible as Reversible,
Sequence as Sequence,
Sized as Sized,
TypeVar,
ValuesView as ValuesView,
)
from typing_extensions import final
__all__ = [
"Awaitable",
"Coroutine",
"AsyncIterable",
"AsyncIterator",
"AsyncGenerator",
"Hashable",
"Iterable",
"Iterator",
"Generator",
"Reversible",
"Sized",
"Container",
"Callable",
"Collection",
"Set",
"MutableSet",
"Mapping",
"MutableMapping",
"MappingView",
"KeysView",
"ItemsView",
"ValuesView",
"Sequence",
"MutableSequence",
"ByteString",
]
_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
@final
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
if sys.version_info >= (3, 10):
@property
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
@final
class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
if sys.version_info >= (3, 10):
@property
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
@final
class dict_items(ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): # undocumented
if sys.version_info >= (3, 10):
@property
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...

281
.vscode/Pico-W-Stub/stdlib/_decimal.pyi vendored Normal file
View File

@@ -0,0 +1,281 @@
import numbers
import sys
from collections.abc import Container, Sequence
from types import TracebackType
from typing import Any, ClassVar, NamedTuple, overload
from typing_extensions import Final, Literal, Self, TypeAlias
_Decimal: TypeAlias = Decimal | int
_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]
_ComparableNum: TypeAlias = Decimal | float | numbers.Rational
__version__: Final[str]
__libmpdec_version__: Final[str]
class DecimalTuple(NamedTuple):
sign: int
digits: tuple[int, ...]
exponent: int | Literal["n", "N", "F"]
ROUND_DOWN: str
ROUND_HALF_UP: str
ROUND_HALF_EVEN: str
ROUND_CEILING: str
ROUND_FLOOR: str
ROUND_UP: str
ROUND_HALF_DOWN: str
ROUND_05UP: str
HAVE_CONTEXTVAR: bool
HAVE_THREADS: bool
MAX_EMAX: int
MAX_PREC: int
MIN_EMIN: int
MIN_ETINY: int
class DecimalException(ArithmeticError): ...
class Clamped(DecimalException): ...
class InvalidOperation(DecimalException): ...
class ConversionSyntax(InvalidOperation): ...
class DivisionByZero(DecimalException, ZeroDivisionError): ...
class DivisionImpossible(InvalidOperation): ...
class DivisionUndefined(InvalidOperation, ZeroDivisionError): ...
class Inexact(DecimalException): ...
class InvalidContext(InvalidOperation): ...
class Rounded(DecimalException): ...
class Subnormal(DecimalException): ...
class Overflow(Inexact, Rounded): ...
class Underflow(Inexact, Rounded, Subnormal): ...
class FloatOperation(DecimalException, TypeError): ...
def setcontext(__context: Context) -> None: ...
def getcontext() -> Context: ...
if sys.version_info >= (3, 11):
def localcontext(
ctx: Context | None = None,
*,
prec: int | None = ...,
rounding: str | None = ...,
Emin: int | None = ...,
Emax: int | None = ...,
capitals: int | None = ...,
clamp: int | None = ...,
traps: dict[_TrapType, bool] | None = ...,
flags: dict[_TrapType, bool] | None = ...,
) -> _ContextManager: ...
else:
def localcontext(ctx: Context | None = None) -> _ContextManager: ...
class Decimal:
def __new__(cls, value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
@classmethod
def from_float(cls, __f: float) -> Self: ...
def __bool__(self) -> bool: ...
def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __hash__(self) -> int: ...
def as_tuple(self) -> DecimalTuple: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
def to_eng_string(self, context: Context | None = None) -> str: ...
def __abs__(self) -> Decimal: ...
def __add__(self, __value: _Decimal) -> Decimal: ...
def __divmod__(self, __value: _Decimal) -> tuple[Decimal, Decimal]: ...
def __eq__(self, __value: object) -> bool: ...
def __floordiv__(self, __value: _Decimal) -> Decimal: ...
def __ge__(self, __value: _ComparableNum) -> bool: ...
def __gt__(self, __value: _ComparableNum) -> bool: ...
def __le__(self, __value: _ComparableNum) -> bool: ...
def __lt__(self, __value: _ComparableNum) -> bool: ...
def __mod__(self, __value: _Decimal) -> Decimal: ...
def __mul__(self, __value: _Decimal) -> Decimal: ...
def __neg__(self) -> Decimal: ...
def __pos__(self) -> Decimal: ...
def __pow__(self, __value: _Decimal, __mod: _Decimal | None = None) -> Decimal: ...
def __radd__(self, __value: _Decimal) -> Decimal: ...
def __rdivmod__(self, __value: _Decimal) -> tuple[Decimal, Decimal]: ...
def __rfloordiv__(self, __value: _Decimal) -> Decimal: ...
def __rmod__(self, __value: _Decimal) -> Decimal: ...
def __rmul__(self, __value: _Decimal) -> Decimal: ...
def __rsub__(self, __value: _Decimal) -> Decimal: ...
def __rtruediv__(self, __value: _Decimal) -> Decimal: ...
def __sub__(self, __value: _Decimal) -> Decimal: ...
def __truediv__(self, __value: _Decimal) -> Decimal: ...
def remainder_near(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __trunc__(self) -> int: ...
@property
def real(self) -> Decimal: ...
@property
def imag(self) -> Decimal: ...
def conjugate(self) -> Decimal: ...
def __complex__(self) -> complex: ...
@overload
def __round__(self) -> int: ...
@overload
def __round__(self, __ndigits: int) -> Decimal: ...
def __floor__(self) -> int: ...
def __ceil__(self) -> int: ...
def fma(self, other: _Decimal, third: _Decimal, context: Context | None = None) -> Decimal: ...
def __rpow__(self, __value: _Decimal, __mod: Context | None = None) -> Decimal: ...
def normalize(self, context: Context | None = None) -> Decimal: ...
def quantize(self, exp: _Decimal, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def same_quantum(self, other: _Decimal, context: Context | None = None) -> bool: ...
def to_integral_exact(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def to_integral_value(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def to_integral(self, rounding: str | None = None, context: Context | None = None) -> Decimal: ...
def sqrt(self, context: Context | None = None) -> Decimal: ...
def max(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def min(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def adjusted(self) -> int: ...
def canonical(self) -> Decimal: ...
def compare_signal(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def compare_total(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def compare_total_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def copy_abs(self) -> Decimal: ...
def copy_negate(self) -> Decimal: ...
def copy_sign(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def exp(self, context: Context | None = None) -> Decimal: ...
def is_canonical(self) -> bool: ...
def is_finite(self) -> bool: ...
def is_infinite(self) -> bool: ...
def is_nan(self) -> bool: ...
def is_normal(self, context: Context | None = None) -> bool: ...
def is_qnan(self) -> bool: ...
def is_signed(self) -> bool: ...
def is_snan(self) -> bool: ...
def is_subnormal(self, context: Context | None = None) -> bool: ...
def is_zero(self) -> bool: ...
def ln(self, context: Context | None = None) -> Decimal: ...
def log10(self, context: Context | None = None) -> Decimal: ...
def logb(self, context: Context | None = None) -> Decimal: ...
def logical_and(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def logical_invert(self, context: Context | None = None) -> Decimal: ...
def logical_or(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def logical_xor(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def max_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def min_mag(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def next_minus(self, context: Context | None = None) -> Decimal: ...
def next_plus(self, context: Context | None = None) -> Decimal: ...
def next_toward(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def number_class(self, context: Context | None = None) -> str: ...
def radix(self) -> Decimal: ...
def rotate(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def scaleb(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def shift(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __reduce__(self) -> tuple[type[Self], tuple[str]]: ...
def __copy__(self) -> Self: ...
def __deepcopy__(self, __memo: Any) -> Self: ...
def __format__(self, __specifier: str, __context: Context | None = ...) -> str: ...
class _ContextManager:
new_context: Context
saved_context: Context
def __init__(self, new_context: Context) -> None: ...
def __enter__(self) -> Context: ...
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
_TrapType: TypeAlias = type[DecimalException]
class Context:
# TODO: Context doesn't allow you to delete *any* attributes from instances of the class at runtime,
# even settable attributes like `prec` and `rounding`,
# but that's inexpressable in the stub.
# Type checkers either ignore it or misinterpret it
# if you add a `def __delattr__(self, __name: str) -> NoReturn` method to the stub
prec: int
rounding: str
Emin: int
Emax: int
capitals: int
clamp: int
traps: dict[_TrapType, bool]
flags: dict[_TrapType, bool]
def __init__(
self,
prec: int | None = ...,
rounding: str | None = ...,
Emin: int | None = ...,
Emax: int | None = ...,
capitals: int | None = ...,
clamp: int | None = ...,
flags: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
traps: None | dict[_TrapType, bool] | Container[_TrapType] = ...,
_ignored_flags: list[_TrapType] | None = ...,
) -> None: ...
def __reduce__(self) -> tuple[type[Self], tuple[Any, ...]]: ...
def clear_flags(self) -> None: ...
def clear_traps(self) -> None: ...
def copy(self) -> Context: ...
def __copy__(self) -> Context: ...
# see https://github.com/python/cpython/issues/94107
__hash__: ClassVar[None] # type: ignore[assignment]
def Etiny(self) -> int: ...
def Etop(self) -> int: ...
def create_decimal(self, __num: _DecimalNew = "0") -> Decimal: ...
def create_decimal_from_float(self, __f: float) -> Decimal: ...
def abs(self, __x: _Decimal) -> Decimal: ...
def add(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def canonical(self, __x: Decimal) -> Decimal: ...
def compare(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def compare_signal(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def compare_total(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def compare_total_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def copy_abs(self, __x: _Decimal) -> Decimal: ...
def copy_decimal(self, __x: _Decimal) -> Decimal: ...
def copy_negate(self, __x: _Decimal) -> Decimal: ...
def copy_sign(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def divide(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def divide_int(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def divmod(self, __x: _Decimal, __y: _Decimal) -> tuple[Decimal, Decimal]: ...
def exp(self, __x: _Decimal) -> Decimal: ...
def fma(self, __x: _Decimal, __y: _Decimal, __z: _Decimal) -> Decimal: ...
def is_canonical(self, __x: _Decimal) -> bool: ...
def is_finite(self, __x: _Decimal) -> bool: ...
def is_infinite(self, __x: _Decimal) -> bool: ...
def is_nan(self, __x: _Decimal) -> bool: ...
def is_normal(self, __x: _Decimal) -> bool: ...
def is_qnan(self, __x: _Decimal) -> bool: ...
def is_signed(self, __x: _Decimal) -> bool: ...
def is_snan(self, __x: _Decimal) -> bool: ...
def is_subnormal(self, __x: _Decimal) -> bool: ...
def is_zero(self, __x: _Decimal) -> bool: ...
def ln(self, __x: _Decimal) -> Decimal: ...
def log10(self, __x: _Decimal) -> Decimal: ...
def logb(self, __x: _Decimal) -> Decimal: ...
def logical_and(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def logical_invert(self, __x: _Decimal) -> Decimal: ...
def logical_or(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def logical_xor(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def max(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def max_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def min(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def min_mag(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def minus(self, __x: _Decimal) -> Decimal: ...
def multiply(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def next_minus(self, __x: _Decimal) -> Decimal: ...
def next_plus(self, __x: _Decimal) -> Decimal: ...
def next_toward(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def normalize(self, __x: _Decimal) -> Decimal: ...
def number_class(self, __x: _Decimal) -> str: ...
def plus(self, __x: _Decimal) -> Decimal: ...
def power(self, a: _Decimal, b: _Decimal, modulo: _Decimal | None = None) -> Decimal: ...
def quantize(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def radix(self) -> Decimal: ...
def remainder(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def remainder_near(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def rotate(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def same_quantum(self, __x: _Decimal, __y: _Decimal) -> bool: ...
def scaleb(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def shift(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def sqrt(self, __x: _Decimal) -> Decimal: ...
def subtract(self, __x: _Decimal, __y: _Decimal) -> Decimal: ...
def to_eng_string(self, __x: _Decimal) -> str: ...
def to_sci_string(self, __x: _Decimal) -> str: ...
def to_integral_exact(self, __x: _Decimal) -> Decimal: ...
def to_integral_value(self, __x: _Decimal) -> Decimal: ...
def to_integral(self, __x: _Decimal) -> Decimal: ...
DefaultContext: Context
BasicContext: Context
ExtendedContext: Context

View File

@@ -0,0 +1,318 @@
# Utility types for typeshed
#
# See the README.md file in this directory for more information.
import sys
from collections.abc import Awaitable, Callable, Iterable, Sequence
from collections.abc import Set as AbstractSet
from collections.abc import Sized
from dataclasses import Field
from os import PathLike
from types import FrameType, TracebackType
from typing import Any, AnyStr, ClassVar, Generic, Protocol, TypeVar, overload
from typing_extensions import (Buffer, Final, Literal, LiteralString,
TypeAlias, final)
_KT = TypeVar("_KT")
_KT_co = TypeVar("_KT_co", covariant=True)
_KT_contra = TypeVar("_KT_contra", contravariant=True)
_VT = TypeVar("_VT")
_VT_co = TypeVar("_VT_co", covariant=True)
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
# Use for "self" annotations:
# def __enter__(self: Self) -> Self: ...
Self = TypeVar("Self") # noqa: Y001
# covariant version of typing.AnyStr, useful for protocols
AnyStr_co = TypeVar("AnyStr_co", str, bytes, covariant=True) # noqa: Y001
# For partially known annotations. Usually, fields where type annotations
# haven't been added are left unannotated, but in some situations this
# isn't possible or a type is already partially known. In cases like these,
# use Incomplete instead of Any as a marker. For example, use
# "Incomplete | None" instead of "Any | None".
Incomplete: TypeAlias = Any
# To describe a function parameter that is unused and will work with anything.
Unused: TypeAlias = object
# Used to mark arguments that default to a sentinel value. This prevents
# stubtest from complaining about the default value not matching.
#
# def foo(x: int | None = sentinel) -> None: ...
#
# In cases where the sentinel object is exported and can be used by user code,
# a construct like this is better:
#
# _SentinelType = NewType("_SentinelType", object)
# sentinel: _SentinelType
# def foo(x: int | None | _SentinelType = ...) -> None: ...
sentinel = Any # noqa: Y026
# stable
class IdentityFunction(Protocol):
def __call__(self, __x: _T) -> _T: ...
# stable
class SupportsNext(Protocol[_T_co]):
def __next__(self) -> _T_co: ...
# stable
class SupportsAnext(Protocol[_T_co]):
def __anext__(self) -> Awaitable[_T_co]: ...
# Comparison protocols
class SupportsDunderLT(Protocol[_T_contra]):
def __lt__(self, __other: _T_contra) -> bool: ...
class SupportsDunderGT(Protocol[_T_contra]):
def __gt__(self, __other: _T_contra) -> bool: ...
class SupportsDunderLE(Protocol[_T_contra]):
def __le__(self, __other: _T_contra) -> bool: ...
class SupportsDunderGE(Protocol[_T_contra]):
def __ge__(self, __other: _T_contra) -> bool: ...
class SupportsAllComparisons(
SupportsDunderLT[Any], SupportsDunderGT[Any], SupportsDunderLE[Any], SupportsDunderGE[Any], Protocol
): ...
SupportsRichComparison: TypeAlias = SupportsDunderLT[Any] | SupportsDunderGT[Any]
SupportsRichComparisonT = TypeVar("SupportsRichComparisonT", bound=SupportsRichComparison) # noqa: Y001
# Dunder protocols
class SupportsAdd(Protocol[_T_contra, _T_co]):
def __add__(self, __x: _T_contra) -> _T_co: ...
class SupportsRAdd(Protocol[_T_contra, _T_co]):
def __radd__(self, __x: _T_contra) -> _T_co: ...
class SupportsSub(Protocol[_T_contra, _T_co]):
def __sub__(self, __x: _T_contra) -> _T_co: ...
class SupportsRSub(Protocol[_T_contra, _T_co]):
def __rsub__(self, __x: _T_contra) -> _T_co: ...
class SupportsDivMod(Protocol[_T_contra, _T_co]):
def __divmod__(self, __other: _T_contra) -> _T_co: ...
class SupportsRDivMod(Protocol[_T_contra, _T_co]):
def __rdivmod__(self, __other: _T_contra) -> _T_co: ...
# This protocol is generic over the iterator type, while Iterable is
# generic over the type that is iterated over.
class SupportsIter(Protocol[_T_co]):
def __iter__(self) -> _T_co: ...
# This protocol is generic over the iterator type, while AsyncIterable is
# generic over the type that is iterated over.
class SupportsAiter(Protocol[_T_co]):
def __aiter__(self) -> _T_co: ...
class SupportsLenAndGetItem(Protocol[_T_co]):
def __len__(self) -> int: ...
def __getitem__(self, __k: int) -> _T_co: ...
class SupportsTrunc(Protocol):
def __trunc__(self) -> int: ...
# Mapping-like protocols
# stable
class SupportsItems(Protocol[_KT_co, _VT_co]):
def items(self) -> AbstractSet[tuple[_KT_co, _VT_co]]: ...
# stable
class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
def keys(self) -> Iterable[_KT]: ...
def __getitem__(self, __key: _KT) -> _VT_co: ...
# stable
class SupportsGetItem(Protocol[_KT_contra, _VT_co]):
def __contains__(self, __x: Any) -> bool: ...
def __getitem__(self, __key: _KT_contra) -> _VT_co: ...
# stable
class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]):
def __setitem__(self, __key: _KT_contra, __value: _VT) -> None: ...
def __delitem__(self, __key: _KT_contra) -> None: ...
StrPath: TypeAlias = str | PathLike[str] # stable
BytesPath: TypeAlias = bytes | PathLike[bytes] # stable
GenericPath: TypeAlias = AnyStr | PathLike[AnyStr]
StrOrBytesPath: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes] # stable
OpenTextModeUpdating: TypeAlias = Literal[
"r+",
"+r",
"rt+",
"r+t",
"+rt",
"tr+",
"t+r",
"+tr",
"w+",
"+w",
"wt+",
"w+t",
"+wt",
"tw+",
"t+w",
"+tw",
"a+",
"+a",
"at+",
"a+t",
"+at",
"ta+",
"t+a",
"+ta",
"x+",
"+x",
"xt+",
"x+t",
"+xt",
"tx+",
"t+x",
"+tx",
]
OpenTextModeWriting: TypeAlias = Literal["w", "wt", "tw", "a", "at", "ta", "x", "xt", "tx"]
OpenTextModeReading: TypeAlias = Literal["r", "rt", "tr", "U", "rU", "Ur", "rtU", "rUt", "Urt", "trU", "tUr", "Utr"]
OpenTextMode: TypeAlias = OpenTextModeUpdating | OpenTextModeWriting | OpenTextModeReading
OpenBinaryModeUpdating: TypeAlias = Literal[
"rb+",
"r+b",
"+rb",
"br+",
"b+r",
"+br",
"wb+",
"w+b",
"+wb",
"bw+",
"b+w",
"+bw",
"ab+",
"a+b",
"+ab",
"ba+",
"b+a",
"+ba",
"xb+",
"x+b",
"+xb",
"bx+",
"b+x",
"+bx",
]
OpenBinaryModeWriting: TypeAlias = Literal["wb", "bw", "ab", "ba", "xb", "bx"]
OpenBinaryModeReading: TypeAlias = Literal["rb", "br", "rbU", "rUb", "Urb", "brU", "bUr", "Ubr"]
OpenBinaryMode: TypeAlias = OpenBinaryModeUpdating | OpenBinaryModeReading | OpenBinaryModeWriting
# stable
class HasFileno(Protocol):
def fileno(self) -> int: ...
FileDescriptor: TypeAlias = int # stable
FileDescriptorLike: TypeAlias = int | HasFileno # stable
FileDescriptorOrPath: TypeAlias = int | StrOrBytesPath
# stable
class SupportsRead(Protocol[_T_co]):
def read(self, __length: int = ...) -> _T_co: ...
# stable
class SupportsReadline(Protocol[_T_co]):
def readline(self, __length: int = ...) -> _T_co: ...
# stable
class SupportsNoArgReadline(Protocol[_T_co]):
def readline(self) -> _T_co: ...
# stable
class SupportsWrite(Protocol[_T_contra]):
def write(self, __s: _T_contra) -> object: ...
# Unfortunately PEP 688 does not allow us to distinguish read-only
# from writable buffers. We use these aliases for readability for now.
# Perhaps a future extension of the buffer protocol will allow us to
# distinguish these cases in the type system.
ReadOnlyBuffer: TypeAlias = Buffer # stable
# Anything that implements the read-write buffer interface.
WriteableBuffer: TypeAlias = Buffer
# Same as WriteableBuffer, but also includes read-only buffer types (like bytes).
ReadableBuffer: TypeAlias = Buffer # stable
class SliceableBuffer(Buffer, Protocol):
def __getitem__(self, __slice: slice) -> Sequence[int]: ...
class IndexableBuffer(Buffer, Protocol):
def __getitem__(self, __i: int) -> int: ...
class SupportsGetItemBuffer(SliceableBuffer, IndexableBuffer, Protocol):
def __contains__(self, __x: Any) -> bool: ...
@overload
def __getitem__(self, __slice: slice) -> Sequence[int]: ...
@overload
def __getitem__(self, __i: int) -> int: ...
class SizedBuffer(Sized, Buffer, Protocol): ...
# for compatibility with third-party stubs that may use this
_BufferWithLen: TypeAlias = SizedBuffer # not stable # noqa: Y047
ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType]
OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None]
# stable
if sys.version_info >= (3, 10):
from types import NoneType as NoneType
else:
# Used by type checkers for checks involving None (does not exist at runtime)
@final
class NoneType:
def __bool__(self) -> Literal[False]: ...
# This is an internal CPython type that is like, but subtly different from, a NamedTuple
# Subclasses of this type are found in multiple modules.
# In typeshed, `structseq` is only ever used as a mixin in combination with a fixed-length `Tuple`
# See discussion at #6546 & #6560
# `structseq` classes are unsubclassable, so are all decorated with `@final`.
class structseq(Generic[_T_co]):
n_fields: Final[int]
n_unnamed_fields: Final[int]
n_sequence_fields: Final[int]
# The first parameter will generally only take an iterable of a specific length.
# E.g. `os.uname_result` takes any iterable of length exactly 5.
#
# The second parameter will accept a dict of any kind without raising an exception,
# but only has any meaning if you supply it a dict where the keys are strings.
# https://github.com/python/typeshed/pull/6560#discussion_r767149830
def __new__(cls: type[Self], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> Self: ...
# Superset of typing.AnyStr that also includes LiteralString
AnyOrLiteralStr = TypeVar("AnyOrLiteralStr", str, bytes, LiteralString) # noqa: Y001
# Represents when str or LiteralStr is acceptable. Useful for string processing
# APIs where literalness of return value depends on literalness of inputs
StrOrLiteralStr = TypeVar("StrOrLiteralStr", LiteralString, str) # noqa: Y001
# Objects suitable to be passed to sys.setprofile, threading.setprofile, and similar
ProfileFunction: TypeAlias = Callable[[FrameType, str, Any], object]
# Objects suitable to be passed to sys.settrace, threading.settrace, and similar
TraceFunction: TypeAlias = Callable[[FrameType, str, Any], TraceFunction | None]
# experimental
# Might not work as expected for pyright, see
# https://github.com/python/typeshed/pull/9362
# https://github.com/microsoft/pyright/issues/4339
class DataclassInstance(Protocol):
__dataclass_fields__: ClassVar[dict[str, Field[Any]]]

View File

@@ -0,0 +1,37 @@
# PEP 249 Database API 2.0 Types
# https://www.python.org/dev/peps/pep-0249/
from collections.abc import Mapping, Sequence
from typing import Any, Protocol
from typing_extensions import TypeAlias
DBAPITypeCode: TypeAlias = Any | None
# Strictly speaking, this should be a Sequence, but the type system does
# not support fixed-length sequences.
DBAPIColumnDescription: TypeAlias = tuple[str, DBAPITypeCode, int | None, int | None, int | None, int | None, bool | None]
class DBAPIConnection(Protocol):
def close(self) -> object: ...
def commit(self) -> object: ...
# optional:
# def rollback(self) -> Any: ...
def cursor(self) -> DBAPICursor: ...
class DBAPICursor(Protocol):
@property
def description(self) -> Sequence[DBAPIColumnDescription] | None: ...
@property
def rowcount(self) -> int: ...
# optional:
# def callproc(self, __procname: str, __parameters: Sequence[Any] = ...) -> Sequence[Any]: ...
def close(self) -> object: ...
def execute(self, __operation: str, __parameters: Sequence[Any] | Mapping[str, Any] = ...) -> object: ...
def executemany(self, __operation: str, __seq_of_parameters: Sequence[Sequence[Any]]) -> object: ...
def fetchone(self) -> Sequence[Any] | None: ...
def fetchmany(self, __size: int = ...) -> Sequence[Sequence[Any]]: ...
def fetchall(self) -> Sequence[Sequence[Any]]: ...
# optional:
# def nextset(self) -> None | Literal[True]: ...
arraysize: int
def setinputsizes(self, __sizes: Sequence[DBAPITypeCode | int | None]) -> object: ...
def setoutputsize(self, __size: int, __column: int = ...) -> object: ...

View File

@@ -0,0 +1,44 @@
# Types to support PEP 3333 (WSGI)
#
# Obsolete since Python 3.11: Use wsgiref.types instead.
#
# See the README.md file in this directory for more information.
import sys
from _typeshed import OptExcInfo
from collections.abc import Callable, Iterable, Iterator
from typing import Any, Protocol
from typing_extensions import TypeAlias
class _Readable(Protocol):
def read(self, size: int = ...) -> bytes: ...
# Optional: def close(self) -> object: ...
if sys.version_info >= (3, 11):
from wsgiref.types import *
else:
# stable
class StartResponse(Protocol):
def __call__(
self, __status: str, __headers: list[tuple[str, str]], __exc_info: OptExcInfo | None = ...
) -> Callable[[bytes], object]: ...
WSGIEnvironment: TypeAlias = dict[str, Any] # stable
WSGIApplication: TypeAlias = Callable[[WSGIEnvironment, StartResponse], Iterable[bytes]] # stable
# WSGI input streams per PEP 3333, stable
class InputStream(Protocol):
def read(self, __size: int = ...) -> bytes: ...
def readline(self, __size: int = ...) -> bytes: ...
def readlines(self, __hint: int = ...) -> list[bytes]: ...
def __iter__(self) -> Iterator[bytes]: ...
# WSGI error streams per PEP 3333, stable
class ErrorStream(Protocol):
def flush(self) -> object: ...
def write(self, __s: str) -> object: ...
def writelines(self, __seq: list[str]) -> object: ...
# Optional file wrapper in wsgi.file_wrapper
class FileWrapper(Protocol):
def __call__(self, __file: _Readable, __block_size: int = ...) -> Iterable[bytes]: ...

View File

@@ -0,0 +1,9 @@
# See the README.md file in this directory for more information.
from typing import Any, Protocol
# As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects
class DOMImplementation(Protocol):
def hasFeature(self, feature: str, version: str | None) -> bool: ...
def createDocument(self, namespaceUri: str, qualifiedName: str, doctype: Any | None) -> Any: ...
def createDocumentType(self, qualifiedName: str, publicId: str, systemId: str) -> Any: ...

57
.vscode/Pico-W-Stub/stdlib/abc.pyi vendored Normal file
View File

@@ -0,0 +1,57 @@
import sys
from collections.abc import Callable
from typing import Any, TypeVar
import _typeshed
from _typeshed import SupportsWrite
from typing_extensions import Concatenate, Literal, ParamSpec
_T = TypeVar("_T")
_R_co = TypeVar("_R_co", covariant=True)
_FuncT = TypeVar("_FuncT", bound=Callable[..., Any])
_P = ParamSpec("_P")
# These definitions have special processing in mypy
class ABCMeta(type):
__abstractmethods__: frozenset[str]
if sys.version_info >= (3, 11):
def __new__(
__mcls: type[_typeshed.Self],
__name: str,
__bases: tuple[type, ...],
__namespace: dict[str, Any],
**kwargs: Any
) -> _typeshed.Self: ...
else:
def __new__(
mcls: type[_typeshed.Self],
name: str,
bases: tuple[type, ...],
namespace: dict[str, Any],
**kwargs: Any
) -> _typeshed.Self: ...
def __instancecheck__(cls: ABCMeta, instance: Any) -> bool: ...
def __subclasscheck__(cls: ABCMeta, subclass: type) -> bool: ...
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = None) -> None: ...
def register(cls: ABCMeta, subclass: type[_T]) -> type[_T]: ...
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
class abstractclassmethod(classmethod[_T, _P, _R_co]): # type: ignore
__isabstractmethod__: Literal[True]
def __init__(self, callable: Callable[Concatenate[type[_T], _P], _R_co]) -> None: ... # type: ignore
class abstractstaticmethod(staticmethod[_P, _R_co]): # type: ignore
__isabstractmethod__: Literal[True]
def __init__(self, callable: Callable[_P, _R_co]) -> None: ... # type: ignore
class abstractproperty(property):
__isabstractmethod__: Literal[True]
class ABC(metaclass=ABCMeta): ...
def get_cache_token() -> object: ...
if sys.version_info >= (3, 10):
def update_abstractmethods(cls: type[_T]) -> type[_T]: ...

View File

@@ -0,0 +1,45 @@
import sys
from collections.abc import Awaitable, Coroutine, Generator
from typing import Any, TypeVar
from typing_extensions import TypeAlias
# As at runtime, this depends on all submodules defining __all__ accurately.
from .base_events import *
from .coroutines import *
from .events import *
from .futures import *
from .locks import *
from .protocols import *
from .queues import *
from .runners import *
from .streams import *
# from .subprocess import *
from .tasks import *
from .transports import *
if sys.version_info >= (3, 8):
from .exceptions import *
if sys.version_info >= (3, 9):
from .threads import *
if sys.version_info >= (3, 11):
from .taskgroups import *
from .timeouts import *
if sys.platform == "win32":
from .windows_events import *
else:
from .unix_events import *
_T = TypeVar("_T")
# Aliases imported by multiple submodules in typeshed
if sys.version_info >= (3, 12):
_AwaitableLike: TypeAlias = Awaitable[_T] # noqa: Y047
_CoroutineLike: TypeAlias = Coroutine[Any, Any, _T] # noqa: Y047
else:
_AwaitableLike: TypeAlias = Generator[Any, None, _T] | Awaitable[_T]
_CoroutineLike: TypeAlias = Generator[Any, None, _T] | Coroutine[Any, Any, _T]

View File

@@ -0,0 +1,521 @@
import ssl
import sys
from asyncio import _AwaitableLike, _CoroutineLike
from asyncio.events import AbstractEventLoop, AbstractServer, Handle, TimerHandle, _TaskFactory
from asyncio.futures import Future
from asyncio.protocols import BaseProtocol
from asyncio.tasks import Task
from asyncio.transports import (
BaseTransport,
DatagramTransport,
ReadTransport,
SubprocessTransport,
Transport,
WriteTransport,
)
from collections.abc import Callable, Iterable, Sequence
from contextvars import Context
from typing import IO, Any, TypeVar, overload
from _typeshed import FileDescriptorLike, ReadableBuffer, WriteableBuffer
from stdlib.socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
from typing_extensions import Literal, TypeAlias
if sys.version_info >= (3, 9):
__all__ = ("BaseEventLoop", "Server")
else:
__all__ = ("BaseEventLoop",)
_T = TypeVar("_T")
_ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
_Context: TypeAlias = dict[str, Any]
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object]
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
_SSLContext: TypeAlias = bool | None | ssl.SSLContext # type: ignore[misc]
class Server(AbstractServer):
if sys.version_info >= (3, 11):
def __init__(
self,
loop: AbstractEventLoop,
sockets: Iterable[socket],
protocol_factory: _ProtocolFactory,
ssl_context: _SSLContext,
backlog: int,
ssl_handshake_timeout: float | None,
ssl_shutdown_timeout: float | None = None,
) -> None: ...
else:
def __init__(
self,
loop: AbstractEventLoop,
sockets: Iterable[socket],
protocol_factory: _ProtocolFactory,
ssl_context: _SSLContext,
backlog: int,
ssl_handshake_timeout: float | None,
) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
def is_serving(self) -> bool: ...
async def start_serving(self) -> None: ...
async def serve_forever(self) -> None: ...
if sys.version_info >= (3, 8):
@property
def sockets(self) -> tuple[socket, ...]: ...
else:
@property
def sockets(self) -> list[socket]: ...
def close(self) -> None: ...
async def wait_closed(self) -> None: ...
class BaseEventLoop(AbstractEventLoop):
def run_forever(self) -> None: ...
def run_until_complete(self, future: _AwaitableLike[_T]) -> _T: ...
def stop(self) -> None: ...
def is_running(self) -> bool: ...
def is_closed(self) -> bool: ...
def close(self) -> None: ...
async def shutdown_asyncgens(self) -> None: ...
# Methods scheduling callbacks. All these return Handles.
def call_soon(
self, callback: Callable[..., object], *args: Any, context: Context | None = None
) -> Handle: ...
def call_later(
self,
delay: float,
callback: Callable[..., object],
*args: Any,
context: Context | None = None,
) -> TimerHandle: ...
def call_at(
self,
when: float,
callback: Callable[..., object],
*args: Any,
context: Context | None = None,
) -> TimerHandle: ...
def time(self) -> float: ...
# Future methods
def create_future(self) -> Future[Any]: ...
# Tasks methods
if sys.version_info >= (3, 11):
def create_task(
self, coro: _CoroutineLike[_T], *, name: object = None, context: Context | None = None
) -> Task[_T]: ...
elif sys.version_info >= (3, 8):
def create_task(self, coro: _CoroutineLike[_T], *, name: object = None) -> Task[_T]: ...
else:
def create_task(self, coro: _CoroutineLike[_T]) -> Task[_T]: ...
def set_task_factory(self, factory: _TaskFactory | None) -> None: ...
def get_task_factory(self) -> _TaskFactory | None: ...
# Methods for interacting with threads
def call_soon_threadsafe(
self, callback: Callable[..., object], *args: Any, context: Context | None = None
) -> Handle: ...
def run_in_executor(
self, executor: Any, func: Callable[..., _T], *args: Any
) -> Future[_T]: ...
def set_default_executor(self, executor: Any) -> None: ...
# Network I/O methods returning Futures.
async def getaddrinfo(
self,
host: bytes | str | None,
port: bytes | str | int | None,
*,
family: int = 0,
type: int = 0,
proto: int = 0,
flags: int = 0,
) -> list[
tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]
]: ...
async def getnameinfo(
self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = 0
) -> tuple[str, str]: ...
if sys.version_info >= (3, 12):
@overload
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: None = None,
local_addr: tuple[str, int] | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
all_errors: bool = False,
) -> tuple[Transport, _ProtocolT]: ...
@overload
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: None = None,
port: None = None,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: socket,
local_addr: None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
all_errors: bool = False,
) -> tuple[Transport, _ProtocolT]: ...
elif sys.version_info >= (3, 11):
@overload
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: None = None,
local_addr: tuple[str, int] | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
) -> tuple[Transport, _ProtocolT]: ...
@overload
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: None = None,
port: None = None,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: socket,
local_addr: None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
) -> tuple[Transport, _ProtocolT]: ...
elif sys.version_info >= (3, 8):
@overload
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: None = None,
local_addr: tuple[str, int] | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
) -> tuple[Transport, _ProtocolT]: ...
@overload
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: None = None,
port: None = None,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: socket,
local_addr: None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
) -> tuple[Transport, _ProtocolT]: ...
else:
@overload
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: None = None,
local_addr: tuple[str, int] | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
@overload
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: None = None,
port: None = None,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: socket,
local_addr: None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
if sys.version_info >= (3, 11):
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = ...,
flags: int = ...,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
port: None = None,
*,
family: int = ...,
flags: int = ...,
sock: socket = ...,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
async def start_tls(
self,
transport: BaseTransport,
protocol: BaseProtocol,
sslcontext: ssl.SSLContext,
*,
server_side: bool = False,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> Transport | None: ...
async def connect_accepted_socket(
self,
protocol_factory: Callable[[], _ProtocolT],
sock: socket,
*,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
else:
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = ...,
flags: int = ...,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
port: None = None,
*,
family: int = ...,
flags: int = ...,
sock: socket = ...,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
async def start_tls(
self,
transport: BaseTransport,
protocol: BaseProtocol,
sslcontext: ssl.SSLContext, # type: ignore[misc]
*,
server_side: bool = False,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
) -> Transport | None: ...
async def connect_accepted_socket(
self,
protocol_factory: Callable[[], _ProtocolT],
sock: socket,
*,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
async def sock_sendfile(
self,
sock: socket,
file: IO[bytes],
offset: int = 0,
count: int | None = None,
*,
fallback: bool | None = True,
) -> int: ...
async def sendfile(
self,
transport: WriteTransport,
file: IO[bytes],
offset: int = 0,
count: int | None = None,
*,
fallback: bool = True,
) -> int: ...
if sys.version_info >= (3, 11):
async def create_datagram_endpoint( # type: ignore[override]
self,
protocol_factory: Callable[[], _ProtocolT],
local_addr: tuple[str, int] | str | None = None,
remote_addr: tuple[str, int] | str | None = None,
*,
family: int = 0,
proto: int = 0,
flags: int = 0,
reuse_port: bool | None = None,
allow_broadcast: bool | None = None,
sock: socket | None = None,
) -> tuple[DatagramTransport, _ProtocolT]: ...
else:
async def create_datagram_endpoint(
self,
protocol_factory: Callable[[], _ProtocolT],
local_addr: tuple[str, int] | str | None = None,
remote_addr: tuple[str, int] | str | None = None,
*,
family: int = 0,
proto: int = 0,
flags: int = 0,
reuse_address: bool | None = ...,
reuse_port: bool | None = None,
allow_broadcast: bool | None = None,
sock: socket | None = None,
) -> tuple[DatagramTransport, _ProtocolT]: ...
# Pipes and subprocesses.
async def connect_read_pipe(
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
) -> tuple[ReadTransport, _ProtocolT]: ...
async def connect_write_pipe(
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
) -> tuple[WriteTransport, _ProtocolT]: ...
async def subprocess_shell(
self,
protocol_factory: Callable[[], _ProtocolT],
cmd: bytes | str,
*,
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False, None] = None,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
async def subprocess_exec(
self,
protocol_factory: Callable[[], _ProtocolT],
program: Any,
*args: Any,
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = False,
shell: Literal[False] = False,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
def add_reader(
self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any
) -> None: ...
def remove_reader(self, fd: FileDescriptorLike) -> bool: ...
def add_writer(
self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any
) -> None: ...
def remove_writer(self, fd: FileDescriptorLike) -> bool: ...
# The sock_* methods (and probably some others) are not actually implemented on
# BaseEventLoop, only on subclasses. We list them here for now for convenience.
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ...
async def sock_sendall(self, sock: socket, data: ReadableBuffer) -> None: ...
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
if sys.version_info >= (3, 11):
async def sock_recvfrom(self, sock: socket, bufsize: int) -> tuple[bytes, _RetAddress]: ...
async def sock_recvfrom_into(
self, sock: socket, buf: WriteableBuffer, nbytes: int = 0
) -> tuple[int, _RetAddress]: ...
async def sock_sendto(
self, sock: socket, data: ReadableBuffer, address: _Address
) -> int: ...
# Signal handling.
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...
def remove_signal_handler(self, sig: int) -> bool: ...
# Error handlers.
def set_exception_handler(self, handler: _ExceptionHandler | None) -> None: ...
def get_exception_handler(self) -> _ExceptionHandler | None: ...
def default_exception_handler(self, context: _Context) -> None: ...
def call_exception_handler(self, context: _Context) -> None: ...
# Debug flag management.
def get_debug(self) -> bool: ...
def set_debug(self, enabled: bool) -> None: ...
if sys.version_info >= (3, 12):
async def shutdown_default_executor(self, timeout: float | None = None) -> None: ...
elif sys.version_info >= (3, 9):
async def shutdown_default_executor(self) -> None: ...

View File

@@ -0,0 +1,20 @@
from collections.abc import Callable, Sequence
from contextvars import Context
from typing import Any
from typing_extensions import Literal
from . import futures
__all__ = ()
# asyncio defines 'isfuture()' in base_futures.py and re-imports it in futures.py
# but it leads to circular import error in pytype tool.
# That's why the import order is reversed.
from .futures import isfuture as isfuture
_PENDING: Literal["PENDING"] # undocumented
_CANCELLED: Literal["CANCELLED"] # undocumented
_FINISHED: Literal["FINISHED"] # undocumented
def _format_callbacks(cb: Sequence[tuple[Callable[[futures.Future[Any]], None], Context]]) -> str: ... # undocumented
def _future_repr_info(future: futures.Future[Any]) -> list[str]: ... # undocumented

View File

@@ -0,0 +1,9 @@
from _typeshed import StrOrBytesPath
from types import FrameType
from typing import Any
from . import tasks
def _task_repr_info(task: tasks.Task[Any]) -> list[str]: ... # undocumented
def _task_get_stack(task: tasks.Task[Any], limit: int | None) -> list[FrameType]: ... # undocumented
def _task_print_stack(task: tasks.Task[Any], limit: int | None, file: StrOrBytesPath) -> None: ... # undocumented

View File

@@ -0,0 +1,20 @@
import enum
import sys
from typing_extensions import Literal
LOG_THRESHOLD_FOR_CONNLOST_WRITES: Literal[5]
ACCEPT_RETRY_DELAY: Literal[1]
DEBUG_STACK_DEPTH: Literal[10]
SSL_HANDSHAKE_TIMEOUT: float
SENDFILE_FALLBACK_READBUFFER_SIZE: Literal[262144]
if sys.version_info >= (3, 11):
SSL_SHUTDOWN_TIMEOUT: float
FLOW_CONTROL_HIGH_WATER_SSL_READ: Literal[256]
FLOW_CONTROL_HIGH_WATER_SSL_WRITE: Literal[512]
if sys.version_info >= (3, 12):
THREAD_JOIN_TIMEOUT: Literal[300]
class _SendfileMode(enum.Enum):
UNSUPPORTED: int
TRY_NATIVE: int
FALLBACK: int

View File

@@ -0,0 +1,28 @@
import sys
from collections.abc import Awaitable, Callable, Coroutine
from typing import Any, TypeVar, overload
from typing_extensions import ParamSpec, TypeGuard
if sys.version_info >= (3, 11):
__all__ = ("iscoroutinefunction", "iscoroutine")
else:
__all__ = ("coroutine", "iscoroutinefunction", "iscoroutine")
_T = TypeVar("_T")
_FunctionT = TypeVar("_FunctionT", bound=Callable[..., Any])
_P = ParamSpec("_P")
if sys.version_info < (3, 11):
def coroutine(func: _FunctionT) -> _FunctionT: ...
@overload
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
@overload
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
@overload
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
@overload
def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ...
# Can actually be a generator-style coroutine on Python 3.7
def iscoroutine(obj: object) -> TypeGuard[Coroutine[Any, Any, Any]]: ...

View File

@@ -0,0 +1,687 @@
import ssl
import sys
from abc import ABCMeta, abstractmethod
from collections.abc import Callable, Coroutine, Generator, Sequence
from contextvars import Context
from typing import IO, Any, Protocol, TypeVar, overload
from _typeshed import FileDescriptorLike, ReadableBuffer, StrPath, Unused, WriteableBuffer
from stdlib.socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
from typing_extensions import Literal, Self, TypeAlias
from . import _AwaitableLike, _CoroutineLike
from .base_events import Server
from .futures import Future
from .protocols import BaseProtocol
from .tasks import Task
from .transports import (
BaseTransport,
DatagramTransport,
ReadTransport,
SubprocessTransport,
Transport,
WriteTransport,
)
from .unix_events import AbstractChildWatcher
if sys.version_info >= (3, 8):
__all__ = (
"AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
"get_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"set_event_loop",
"new_event_loop",
"get_child_watcher",
"set_child_watcher",
"_set_running_loop",
"get_running_loop",
"_get_running_loop",
)
else:
__all__ = (
"AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
"SendfileNotAvailableError",
"get_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"set_event_loop",
"new_event_loop",
"get_child_watcher",
"set_child_watcher",
"_set_running_loop",
"get_running_loop",
"_get_running_loop",
)
_T = TypeVar("_T")
_ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
_Context: TypeAlias = dict[str, Any]
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object]
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
_SSLContext: TypeAlias = bool | None | ssl.SSLContext # type: ignore
class _TaskFactory(Protocol):
def __call__(
self,
__loop: AbstractEventLoop,
__factory: Coroutine[Any, Any, _T] | Generator[Any, None, _T],
) -> Future[_T]: ...
class Handle:
_cancelled: bool
_args: Sequence[Any]
def __init__(
self,
callback: Callable[..., object],
args: Sequence[Any],
loop: AbstractEventLoop,
context: Context | None = None,
) -> None: ...
def cancel(self) -> None: ...
def _run(self) -> None: ...
def cancelled(self) -> bool: ...
if sys.version_info >= (3, 12):
def get_context(self) -> Context: ...
class TimerHandle(Handle):
def __init__(
self,
when: float,
callback: Callable[..., object],
args: Sequence[Any],
loop: AbstractEventLoop,
context: Context | None = None,
) -> None: ...
def __hash__(self) -> int: ...
def when(self) -> float: ...
def __lt__(self, other: TimerHandle) -> bool: ...
def __le__(self, other: TimerHandle) -> bool: ...
def __gt__(self, other: TimerHandle) -> bool: ...
def __ge__(self, other: TimerHandle) -> bool: ...
def __eq__(self, other: object) -> bool: ...
class AbstractServer:
@abstractmethod
def close(self) -> None: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, *exc: Unused) -> None: ...
@abstractmethod
def get_loop(self) -> AbstractEventLoop: ...
@abstractmethod
def is_serving(self) -> bool: ...
@abstractmethod
async def start_serving(self) -> None: ...
@abstractmethod
async def serve_forever(self) -> None: ...
@abstractmethod
async def wait_closed(self) -> None: ...
class AbstractEventLoop:
slow_callback_duration: float
@abstractmethod
def run_forever(self) -> None: ...
@abstractmethod
def run_until_complete(self, future: _AwaitableLike[_T]) -> _T: ...
@abstractmethod
def stop(self) -> None: ...
@abstractmethod
def is_running(self) -> bool: ...
@abstractmethod
def is_closed(self) -> bool: ...
@abstractmethod
def close(self) -> None: ...
@abstractmethod
async def shutdown_asyncgens(self) -> None: ...
# Methods scheduling callbacks. All these return Handles.
if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2
@abstractmethod
def call_soon(
self, callback: Callable[..., object], *args: Any, context: Context | None = None
) -> Handle: ...
@abstractmethod
def call_later(
self,
delay: float,
callback: Callable[..., object],
*args: Any,
context: Context | None = None,
) -> TimerHandle: ...
@abstractmethod
def call_at(
self,
when: float,
callback: Callable[..., object],
*args: Any,
context: Context | None = None,
) -> TimerHandle: ...
else:
@abstractmethod
def call_soon(self, callback: Callable[..., object], *args: Any) -> Handle: ...
@abstractmethod
def call_later(
self, delay: float, callback: Callable[..., object], *args: Any
) -> TimerHandle: ...
@abstractmethod
def call_at(
self, when: float, callback: Callable[..., object], *args: Any
) -> TimerHandle: ...
@abstractmethod
def time(self) -> float: ...
# Future methods
@abstractmethod
def create_future(self) -> Future[Any]: ...
# Tasks methods
if sys.version_info >= (3, 11):
@abstractmethod
def create_task(
self,
coro: _CoroutineLike[_T],
*,
name: str | None = None,
context: Context | None = None,
) -> Task[_T]: ...
elif sys.version_info >= (3, 8):
@abstractmethod
def create_task(
self, coro: _CoroutineLike[_T], *, name: str | None = None
) -> Task[_T]: ...
else:
@abstractmethod
def create_task(self, coro: _CoroutineLike[_T]) -> Task[_T]: ...
@abstractmethod
def set_task_factory(self, factory: _TaskFactory | None) -> None: ...
@abstractmethod
def get_task_factory(self) -> _TaskFactory | None: ...
# Methods for interacting with threads
if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2
@abstractmethod
def call_soon_threadsafe(
self, callback: Callable[..., object], *args: Any, context: Context | None = None
) -> Handle: ...
else:
@abstractmethod
def call_soon_threadsafe(self, callback: Callable[..., object], *args: Any) -> Handle: ...
@abstractmethod
def run_in_executor(
self, executor: Any, func: Callable[..., _T], *args: Any
) -> Future[_T]: ...
@abstractmethod
def set_default_executor(self, executor: Any) -> None: ...
# Network I/O methods returning Futures.
@abstractmethod
async def getaddrinfo(
self,
host: bytes | str | None,
port: bytes | str | int | None,
*,
family: int = 0,
type: int = 0,
proto: int = 0,
flags: int = 0,
) -> list[
tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]
]: ...
@abstractmethod
async def getnameinfo(
self, sockaddr: tuple[str, int] | tuple[str, int, int, int], flags: int = 0
) -> tuple[str, str]: ...
if sys.version_info >= (3, 11):
@overload
@abstractmethod
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: None = None,
local_addr: tuple[str, int] | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
) -> tuple[Transport, _ProtocolT]: ...
@overload
@abstractmethod
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: None = None,
port: None = None,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: socket,
local_addr: None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
) -> tuple[Transport, _ProtocolT]: ...
elif sys.version_info >= (3, 8):
@overload
@abstractmethod
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: None = None,
local_addr: tuple[str, int] | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
) -> tuple[Transport, _ProtocolT]: ...
@overload
@abstractmethod
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: None = None,
port: None = None,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: socket,
local_addr: None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
happy_eyeballs_delay: float | None = None,
interleave: int | None = None,
) -> tuple[Transport, _ProtocolT]: ...
else:
@overload
@abstractmethod
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: None = None,
local_addr: tuple[str, int] | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
@overload
@abstractmethod
async def create_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
host: None = None,
port: None = None,
*,
ssl: _SSLContext = None,
family: int = 0,
proto: int = 0,
flags: int = 0,
sock: socket,
local_addr: None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
if sys.version_info >= (3, 11):
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = ...,
flags: int = ...,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
port: None = None,
*,
family: int = ...,
flags: int = ...,
sock: socket = ...,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@abstractmethod
async def start_tls(
self,
transport: WriteTransport,
protocol: BaseProtocol,
sslcontext: ssl.SSLContext,
*,
server_side: bool = False,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> Transport | None: ...
async def create_unix_server(
self,
protocol_factory: _ProtocolFactory,
path: StrPath | None = None,
*,
sock: socket | None = None,
backlog: int = 100,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
else:
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = ...,
flags: int = ...,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
port: None = None,
*,
family: int = ...,
flags: int = ...,
sock: socket = ...,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@abstractmethod
async def start_tls(
self,
transport: BaseTransport,
protocol: BaseProtocol,
sslcontext: ssl.SSLContext, # type: ignore
*,
server_side: bool = False,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
) -> Transport | None: ...
async def create_unix_server(
self,
protocol_factory: _ProtocolFactory,
path: StrPath | None = None,
*,
sock: socket | None = None,
backlog: int = 100,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
if sys.version_info >= (3, 11):
async def connect_accepted_socket(
self,
protocol_factory: Callable[[], _ProtocolT],
sock: socket,
*,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
elif sys.version_info >= (3, 10):
async def connect_accepted_socket(
self,
protocol_factory: Callable[[], _ProtocolT],
sock: socket,
*,
ssl: _SSLContext = None,
ssl_handshake_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
if sys.version_info >= (3, 11):
async def create_unix_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
path: str | None = None,
*,
ssl: _SSLContext = None,
sock: socket | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
else:
async def create_unix_connection(
self,
protocol_factory: Callable[[], _ProtocolT],
path: str | None = None,
*,
ssl: _SSLContext = None,
sock: socket | None = None,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
) -> tuple[Transport, _ProtocolT]: ...
@abstractmethod
async def sock_sendfile(
self,
sock: socket,
file: IO[bytes],
offset: int = 0,
count: int | None = None,
*,
fallback: bool | None = None,
) -> int: ...
@abstractmethod
async def sendfile(
self,
transport: WriteTransport,
file: IO[bytes],
offset: int = 0,
count: int | None = None,
*,
fallback: bool = True,
) -> int: ...
@abstractmethod
async def create_datagram_endpoint(
self,
protocol_factory: Callable[[], _ProtocolT],
local_addr: tuple[str, int] | str | None = None,
remote_addr: tuple[str, int] | str | None = None,
*,
family: int = 0,
proto: int = 0,
flags: int = 0,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
allow_broadcast: bool | None = None,
sock: socket | None = None,
) -> tuple[DatagramTransport, _ProtocolT]: ...
# Pipes and subprocesses.
@abstractmethod
async def connect_read_pipe(
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
) -> tuple[ReadTransport, _ProtocolT]: ...
@abstractmethod
async def connect_write_pipe(
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
) -> tuple[WriteTransport, _ProtocolT]: ...
@abstractmethod
async def subprocess_shell(
self,
protocol_factory: Callable[[], _ProtocolT],
cmd: bytes | str,
*,
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False, None] = ...,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
@abstractmethod
async def subprocess_exec(
self,
protocol_factory: Callable[[], _ProtocolT],
program: Any,
*args: Any,
stdin: int | IO[Any] | None = -1,
stdout: int | IO[Any] | None = -1,
stderr: int | IO[Any] | None = -1,
universal_newlines: Literal[False] = False,
shell: Literal[False] = False,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
@abstractmethod
def add_reader(
self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any
) -> None: ...
@abstractmethod
def remove_reader(self, fd: FileDescriptorLike) -> bool: ...
@abstractmethod
def add_writer(
self, fd: FileDescriptorLike, callback: Callable[..., Any], *args: Any
) -> None: ...
@abstractmethod
def remove_writer(self, fd: FileDescriptorLike) -> bool: ...
# Completion based I/O methods returning Futures prior to 3.7
@abstractmethod
async def sock_recv(self, sock: socket, nbytes: int) -> bytes: ...
@abstractmethod
async def sock_recv_into(self, sock: socket, buf: WriteableBuffer) -> int: ...
@abstractmethod
async def sock_sendall(self, sock: socket, data: ReadableBuffer) -> None: ...
@abstractmethod
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
@abstractmethod
async def sock_accept(self, sock: socket) -> tuple[socket, _RetAddress]: ...
if sys.version_info >= (3, 11):
@abstractmethod
async def sock_recvfrom(self, sock: socket, bufsize: int) -> tuple[bytes, _RetAddress]: ...
@abstractmethod
async def sock_recvfrom_into(
self, sock: socket, buf: WriteableBuffer, nbytes: int = 0
) -> tuple[int, _RetAddress]: ...
@abstractmethod
async def sock_sendto(
self, sock: socket, data: ReadableBuffer, address: _Address
) -> int: ...
# Signal handling.
@abstractmethod
def add_signal_handler(
self, sig: int, callback: Callable[..., object], *args: Any
) -> None: ...
@abstractmethod
def remove_signal_handler(self, sig: int) -> bool: ...
# Error handlers.
@abstractmethod
def set_exception_handler(self, handler: _ExceptionHandler | None) -> None: ...
@abstractmethod
def get_exception_handler(self) -> _ExceptionHandler | None: ...
@abstractmethod
def default_exception_handler(self, context: _Context) -> None: ...
@abstractmethod
def call_exception_handler(self, context: _Context) -> None: ...
# Debug flag management.
@abstractmethod
def get_debug(self) -> bool: ...
@abstractmethod
def set_debug(self, enabled: bool) -> None: ...
if sys.version_info >= (3, 9):
@abstractmethod
async def shutdown_default_executor(self) -> None: ...
class AbstractEventLoopPolicy:
@abstractmethod
def get_event_loop(self) -> AbstractEventLoop: ...
@abstractmethod
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
@abstractmethod
def new_event_loop(self) -> AbstractEventLoop: ...
# Child processes handling (Unix only).
@abstractmethod
def get_child_watcher(self) -> AbstractChildWatcher: ...
@abstractmethod
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta):
def get_event_loop(self) -> AbstractEventLoop: ...
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
def new_event_loop(self) -> AbstractEventLoop: ...
def get_event_loop_policy() -> AbstractEventLoopPolicy: ...
def set_event_loop_policy(policy: AbstractEventLoopPolicy | None) -> None: ...
def get_event_loop() -> AbstractEventLoop: ...
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
def new_event_loop() -> AbstractEventLoop: ...
def get_child_watcher() -> AbstractChildWatcher: ...
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
def _set_running_loop(__loop: AbstractEventLoop | None) -> None: ...
def _get_running_loop() -> AbstractEventLoop: ...
def get_running_loop() -> AbstractEventLoop: ...
if sys.version_info < (3, 8):
class SendfileNotAvailableError(RuntimeError): ...

View File

@@ -0,0 +1,38 @@
import sys
if sys.version_info >= (3, 11):
__all__ = (
"BrokenBarrierError",
"CancelledError",
"InvalidStateError",
"TimeoutError",
"IncompleteReadError",
"LimitOverrunError",
"SendfileNotAvailableError",
)
else:
__all__ = (
"CancelledError",
"InvalidStateError",
"TimeoutError",
"IncompleteReadError",
"LimitOverrunError",
"SendfileNotAvailableError",
)
class CancelledError(BaseException): ...
class TimeoutError(Exception): ...
class InvalidStateError(Exception): ...
class SendfileNotAvailableError(RuntimeError): ...
class IncompleteReadError(EOFError):
expected: int | None
partial: bytes
def __init__(self, partial: bytes, expected: int | None) -> None: ...
class LimitOverrunError(Exception):
consumed: int
def __init__(self, message: str, consumed: int) -> None: ...
if sys.version_info >= (3, 11):
class BrokenBarrierError(RuntimeError): ...

View File

@@ -0,0 +1,20 @@
import functools
import traceback
from collections.abc import Iterable
from types import FrameType, FunctionType
from typing import Any, overload
from typing_extensions import TypeAlias
class _HasWrapper:
__wrapper__: _HasWrapper | FunctionType
_FuncType: TypeAlias = FunctionType | _HasWrapper | functools.partial[Any] | functools.partialmethod[Any]
@overload
def _get_function_source(func: _FuncType) -> tuple[str, int]: ...
@overload
def _get_function_source(func: object) -> tuple[str, int] | None: ...
def _format_callback_source(func: object, args: Iterable[Any]) -> str: ...
def _format_args_and_kwargs(args: Iterable[Any], kwargs: dict[str, Any]) -> str: ...
def _format_callback(func: object, args: Iterable[Any], kwargs: dict[str, Any], suffix: str = "") -> str: ...
def extract_stack(f: FrameType | None = None, limit: int | None = None) -> traceback.StackSummary: ...

View File

@@ -0,0 +1,66 @@
import sys
from collections.abc import Awaitable, Callable, Generator, Iterable
from concurrent.futures._base import Error, Future as _ConcurrentFuture
from typing import Any, TypeVar
from typing_extensions import Literal, Self, TypeGuard
from .events import AbstractEventLoop
if sys.version_info < (3, 8):
from concurrent.futures import CancelledError as CancelledError, TimeoutError as TimeoutError
class InvalidStateError(Error): ...
from contextvars import Context
if sys.version_info >= (3, 9):
from types import GenericAlias
if sys.version_info >= (3, 8):
__all__ = ("Future", "wrap_future", "isfuture")
else:
__all__ = ("CancelledError", "TimeoutError", "InvalidStateError", "Future", "wrap_future", "isfuture")
_T = TypeVar("_T")
# asyncio defines 'isfuture()' in base_futures.py and re-imports it in futures.py
# but it leads to circular import error in pytype tool.
# That's why the import order is reversed.
def isfuture(obj: object) -> TypeGuard[Future[Any]]: ...
class Future(Awaitable[_T], Iterable[_T]):
_state: str
@property
def _exception(self) -> BaseException | None: ...
_blocking: bool
@property
def _log_traceback(self) -> bool: ...
@_log_traceback.setter
def _log_traceback(self, val: Literal[False]) -> None: ...
_asyncio_future_blocking: bool # is a part of duck-typing contract for `Future`
def __init__(self, *, loop: AbstractEventLoop | None = ...) -> None: ...
def __del__(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
@property
def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ...
def add_done_callback(self, __fn: Callable[[Self], object], *, context: Context | None = None) -> None: ...
if sys.version_info >= (3, 9):
def cancel(self, msg: Any | None = None) -> bool: ...
else:
def cancel(self) -> bool: ...
def cancelled(self) -> bool: ...
def done(self) -> bool: ...
def result(self) -> _T: ...
def exception(self) -> BaseException | None: ...
def remove_done_callback(self, __fn: Callable[[Self], object]) -> int: ...
def set_result(self, __result: _T) -> None: ...
def set_exception(self, __exception: type | BaseException) -> None: ...
def __iter__(self) -> Generator[Any, None, _T]: ...
def __await__(self) -> Generator[Any, None, _T]: ...
@property
def _loop(self) -> AbstractEventLoop: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...

View File

@@ -0,0 +1,116 @@
import enum
import sys
from _typeshed import Unused
from collections import deque
from collections.abc import Callable, Generator
from types import TracebackType
from typing import Any, TypeVar
from typing_extensions import Literal, Self
from .events import AbstractEventLoop
from .futures import Future
if sys.version_info >= (3, 11):
from .mixins import _LoopBoundMixin
if sys.version_info >= (3, 11):
__all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore", "Barrier")
else:
__all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore")
_T = TypeVar("_T")
if sys.version_info >= (3, 9):
class _ContextManagerMixin:
async def __aenter__(self) -> None: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> None: ...
else:
class _ContextManager:
def __init__(self, lock: Lock | Semaphore) -> None: ...
def __enter__(self) -> None: ...
def __exit__(self, *args: Unused) -> None: ...
class _ContextManagerMixin:
# Apparently this exists to *prohibit* use as a context manager.
# def __enter__(self) -> NoReturn: ... see: https://github.com/python/typing/issues/1043
# def __exit__(self, *args: Any) -> None: ...
def __iter__(self) -> Generator[Any, None, _ContextManager]: ...
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
async def __aenter__(self) -> None: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> None: ...
class Lock(_ContextManagerMixin):
if sys.version_info >= (3, 10):
def __init__(self) -> None: ...
else:
def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ...
def locked(self) -> bool: ...
async def acquire(self) -> Literal[True]: ...
def release(self) -> None: ...
class Event:
if sys.version_info >= (3, 10):
def __init__(self) -> None: ...
else:
def __init__(self, *, loop: AbstractEventLoop | None = None) -> None: ...
def is_set(self) -> bool: ...
def set(self) -> None: ...
def clear(self) -> None: ...
async def wait(self) -> Literal[True]: ...
class Condition(_ContextManagerMixin):
if sys.version_info >= (3, 10):
def __init__(self, lock: Lock | None = None) -> None: ...
else:
def __init__(self, lock: Lock | None = None, *, loop: AbstractEventLoop | None = None) -> None: ...
def locked(self) -> bool: ...
async def acquire(self) -> Literal[True]: ...
def release(self) -> None: ...
async def wait(self) -> Literal[True]: ...
async def wait_for(self, predicate: Callable[[], _T]) -> _T: ...
def notify(self, n: int = 1) -> None: ...
def notify_all(self) -> None: ...
class Semaphore(_ContextManagerMixin):
_value: int
_waiters: deque[Future[Any]] # type: ignore
if sys.version_info >= (3, 10):
def __init__(self, value: int = 1) -> None: ...
else:
def __init__(self, value: int = 1, *, loop: AbstractEventLoop | None = None) -> None: ...
def locked(self) -> bool: ...
async def acquire(self) -> Literal[True]: ...
def release(self) -> None: ...
def _wake_up_next(self) -> None: ...
class BoundedSemaphore(Semaphore): ...
if sys.version_info >= (3, 11):
class _BarrierState(enum.Enum): # undocumented
FILLING: str
DRAINING: str
RESETTING: str
BROKEN: str
class Barrier(_LoopBoundMixin):
def __init__(self, parties: int) -> None: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, *args: Unused) -> None: ...
async def wait(self) -> int: ...
async def abort(self) -> None: ...
async def reset(self) -> None: ...
@property
def parties(self) -> int: ...
@property
def n_waiting(self) -> int: ...
@property
def broken(self) -> bool: ...

View File

@@ -0,0 +1,3 @@
import logging
logger: logging.Logger

View File

@@ -0,0 +1,10 @@
import sys
import threading
from typing_extensions import Never
_global_lock: threading.Lock # type: ignore
class _LoopBoundMixin:
if sys.version_info < (3, 11):
def __init__(self, *, loop: Never = ...) -> None: ...

View File

@@ -0,0 +1,74 @@
import sys
from collections.abc import Mapping
from socket import socket
from typing import Any, ClassVar, Protocol
from typing_extensions import Literal
from . import base_events, constants, events, futures, streams, transports
__all__ = ("BaseProactorEventLoop",)
if sys.version_info >= (3, 8):
class _WarnCallbackProtocol(Protocol):
def __call__(
self, message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...
) -> object: ...
class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport):
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
) -> None: ...
if sys.version_info >= (3, 8):
def __del__(self, _warn: _WarnCallbackProtocol = ...) -> None: ...
else:
def __del__(self) -> None: ...
class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport):
if sys.version_info >= (3, 10):
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
buffer_size: int = 65536,
) -> None: ...
else:
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
) -> None: ...
class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): ...
class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): ...
class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ...
class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport):
_sendfile_compatible: ClassVar[constants._SendfileMode]
def __init__(
self,
loop: events.AbstractEventLoop,
sock: socket,
protocol: streams.StreamReaderProtocol,
waiter: futures.Future[Any] | None = None,
extra: Mapping[Any, Any] | None = None,
server: events.AbstractServer | None = None,
) -> None: ...
def _set_extra(self, sock: socket) -> None: ...
def can_write_eof(self) -> Literal[True]: ...
class BaseProactorEventLoop(base_events.BaseEventLoop):
def __init__(self, proactor: Any) -> None: ...

View File

@@ -0,0 +1,34 @@
from _typeshed import ReadableBuffer
from asyncio import transports
from typing import Any
__all__ = ("BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol", "BufferedProtocol")
class BaseProtocol:
def connection_made(self, transport: transports.BaseTransport) -> None: ...
def connection_lost(self, exc: Exception | None) -> None: ...
def pause_writing(self) -> None: ...
def resume_writing(self) -> None: ...
class Protocol(BaseProtocol):
def data_received(self, data: bytes) -> None: ...
def eof_received(self) -> bool | None: ...
class BufferedProtocol(BaseProtocol):
def get_buffer(self, sizehint: int) -> ReadableBuffer: ...
def buffer_updated(self, nbytes: int) -> None: ...
def eof_received(self) -> bool | None: ...
class DatagramProtocol(BaseProtocol):
def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore[override]
# addr can be a tuple[int, int] for some unusual protocols like socket.AF_NETLINK.
# Use tuple[str | Any, int] to not cause typechecking issues on most usual cases.
# This could be improved by using tuple[AnyOf[str, int], int] if the AnyOf feature is accepted.
# See https://github.com/python/typing/issues/566
def datagram_received(self, data: bytes, addr: tuple[str | Any, int]) -> None: ...
def error_received(self, exc: Exception) -> None: ...
class SubprocessProtocol(BaseProtocol):
def pipe_data_received(self, fd: int, data: bytes) -> None: ...
def pipe_connection_lost(self, fd: int, exc: Exception | None) -> None: ...
def process_exited(self) -> None: ...

View File

@@ -0,0 +1,40 @@
import sys
from asyncio.events import AbstractEventLoop
from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ("Queue", "PriorityQueue", "LifoQueue", "QueueFull", "QueueEmpty")
class QueueEmpty(Exception): ...
class QueueFull(Exception): ...
_T = TypeVar("_T")
class Queue(Generic[_T]):
if sys.version_info >= (3, 10):
def __init__(self, maxsize: int = 0) -> None: ...
else:
def __init__(self, maxsize: int = 0, *, loop: AbstractEventLoop | None = None) -> None: ...
def _init(self, maxsize: int) -> None: ...
def _get(self) -> _T: ...
def _put(self, item: _T) -> None: ...
def _format(self) -> str: ...
def qsize(self) -> int: ...
@property
def maxsize(self) -> int: ...
def empty(self) -> bool: ...
def full(self) -> bool: ...
async def put(self, item: _T) -> None: ...
def put_nowait(self, item: _T) -> None: ...
async def get(self) -> _T: ...
def get_nowait(self) -> _T: ...
async def join(self) -> None: ...
def task_done(self) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, type: Any) -> GenericAlias: ...
class PriorityQueue(Queue[_T]): ...
class LifoQueue(Queue[_T]): ...

View File

@@ -0,0 +1,35 @@
import sys
from _typeshed import Unused
from collections.abc import Callable, Coroutine
from contextvars import Context
from typing import Any, TypeVar
from typing_extensions import Self, final
from .events import AbstractEventLoop
if sys.version_info >= (3, 11):
__all__ = ("Runner", "run")
else:
__all__ = ("run",)
_T = TypeVar("_T")
if sys.version_info >= (3, 11):
@final
class Runner:
def __init__(self, *, debug: bool | None = None, loop_factory: Callable[[], AbstractEventLoop] | None = None) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, exc_type: Unused, exc_val: Unused, exc_tb: Unused) -> None: ...
def close(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = None) -> _T: ...
if sys.version_info >= (3, 12):
def run(
main: Coroutine[Any, Any, _T], *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...
) -> _T: ...
elif sys.version_info >= (3, 8):
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = None) -> _T: ...
else:
def run(main: Coroutine[Any, Any, _T], *, debug: bool = False) -> _T: ...

View File

@@ -0,0 +1,8 @@
import selectors
from . import base_events
__all__ = ("BaseSelectorEventLoop",)
class BaseSelectorEventLoop(base_events.BaseEventLoop):
def __init__(self, selector: selectors.BaseSelector | None = None) -> None: ...

View File

@@ -0,0 +1,176 @@
import sys
from collections import deque
from collections.abc import Callable
from enum import Enum
from typing import Any, ClassVar
import stdlib.ssl as ssl # type: ignore
from typing_extensions import Literal, TypeAlias
from . import constants, events, futures, protocols, transports
def _create_transport_context(
server_side: bool, server_hostname: str | None
) -> ssl.SSLContext: ...
if sys.version_info >= (3, 11):
SSLAgainErrors: tuple[type[ssl.SSLWantReadError], type[ssl.SSLSyscallError]]
class SSLProtocolState(Enum):
UNWRAPPED: str
DO_HANDSHAKE: str
WRAPPED: str
FLUSHING: str
SHUTDOWN: str
class AppProtocolState(Enum):
STATE_INIT: str
STATE_CON_MADE: str
STATE_EOF: str
STATE_CON_LOST: str
def add_flowcontrol_defaults(
high: int | None, low: int | None, kb: int
) -> tuple[int, int]: ...
else:
_UNWRAPPED: Literal["UNWRAPPED"]
_DO_HANDSHAKE: Literal["DO_HANDSHAKE"]
_WRAPPED: Literal["WRAPPED"]
_SHUTDOWN: Literal["SHUTDOWN"]
if sys.version_info < (3, 11):
class _SSLPipe:
max_size: ClassVar[int]
_context: ssl.SSLContext
_server_side: bool
_server_hostname: str | None
_state: str
_incoming: ssl.MemoryBIO
_outgoing: ssl.MemoryBIO
_sslobj: ssl.SSLObject | None
_need_ssldata: bool
_handshake_cb: Callable[[BaseException | None], None] | None
_shutdown_cb: Callable[[], None] | None
def __init__(
self, context: ssl.SSLContext, server_side: bool, server_hostname: str | None = None
) -> None: ...
@property
def context(self) -> ssl.SSLContext: ...
@property
def ssl_object(self) -> ssl.SSLObject | None: ...
@property
def need_ssldata(self) -> bool: ...
@property
def wrapped(self) -> bool: ...
def do_handshake(
self, callback: Callable[[BaseException | None], object] | None = None
) -> list[bytes]: ...
def shutdown(self, callback: Callable[[], object] | None = None) -> list[bytes]: ...
def feed_eof(self) -> None: ...
def feed_ssldata(
self, data: bytes, only_handshake: bool = False
) -> tuple[list[bytes], list[bytes]]: ...
def feed_appdata(self, data: bytes, offset: int = 0) -> tuple[list[bytes], int]: ...
class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
_sendfile_compatible: ClassVar[constants._SendfileMode]
_loop: events.AbstractEventLoop
if sys.version_info >= (3, 11):
_ssl_protocol: SSLProtocol | None
else:
_ssl_protocol: SSLProtocol
_closed: bool
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
def get_extra_info(self, name: str, default: Any | None = None) -> dict[str, Any]: ...
@property
def _protocol_paused(self) -> bool: ...
def write(self, data: bytes | bytearray | memoryview) -> None: ...
def can_write_eof(self) -> Literal[False]: ...
if sys.version_info >= (3, 11):
def get_write_buffer_limits(self) -> tuple[int, int]: ...
def get_read_buffer_limits(self) -> tuple[int, int]: ...
def set_read_buffer_limits(
self, high: int | None = None, low: int | None = None
) -> None: ...
def get_read_buffer_size(self) -> int: ...
if sys.version_info >= (3, 11):
_SSLProtocolBase: TypeAlias = protocols.BufferedProtocol
else:
_SSLProtocolBase: TypeAlias = protocols.Protocol
class SSLProtocol(_SSLProtocolBase):
_server_side: bool
_server_hostname: str | None
_sslcontext: ssl.SSLContext
_extra: dict[str, Any]
_write_backlog: deque[tuple[bytes, int]] # type: ignore
_write_buffer_size: int
_waiter: futures.Future[Any]
_loop: events.AbstractEventLoop
_app_transport: _SSLProtocolTransport
_transport: transports.BaseTransport | None
_ssl_handshake_timeout: int | None
_app_protocol: protocols.BaseProtocol
_app_protocol_is_buffer: bool
if sys.version_info >= (3, 11):
max_size: ClassVar[int]
else:
_sslpipe: _SSLPipe | None
_session_established: bool
_call_connection_made: bool
_in_handshake: bool
_in_shutdown: bool
if sys.version_info >= (3, 11):
def __init__(
self,
loop: events.AbstractEventLoop,
app_protocol: protocols.BaseProtocol,
sslcontext: ssl.SSLContext,
waiter: futures.Future[Any],
server_side: bool = False,
server_hostname: str | None = None,
call_connection_made: bool = True,
ssl_handshake_timeout: int | None = None,
ssl_shutdown_timeout: float | None = None,
) -> None: ...
else:
def __init__(
self,
loop: events.AbstractEventLoop,
app_protocol: protocols.BaseProtocol,
sslcontext: ssl.SSLContext,
waiter: futures.Future[Any],
server_side: bool = False,
server_hostname: str | None = None,
call_connection_made: bool = True,
ssl_handshake_timeout: int | None = None,
) -> None: ...
def _set_app_protocol(self, app_protocol: protocols.BaseProtocol) -> None: ...
def _wakeup_waiter(self, exc: BaseException | None = None) -> None: ...
def connection_lost(self, exc: BaseException | None) -> None: ...
def eof_received(self) -> None: ...
def _get_extra_info(self, name: str, default: Any | None = None) -> Any: ...
def _start_shutdown(self) -> None: ...
if sys.version_info >= (3, 11):
def _write_appdata(self, list_of_data: list[bytes]) -> None: ...
else:
def _write_appdata(self, data: bytes) -> None: ...
def _start_handshake(self) -> None: ...
def _check_handshake_timeout(self) -> None: ...
def _on_handshake_complete(self, handshake_exc: BaseException | None) -> None: ...
def _fatal_error(
self, exc: BaseException, message: str = "Fatal error on transport"
) -> None: ...
def _abort(self) -> None: ...
if sys.version_info >= (3, 11):
def get_buffer(self, n: int) -> memoryview: ...
else:
def _finalize(self) -> None: ...
def _process_write_backlog(self) -> None: ...

View File

@@ -0,0 +1,10 @@
from collections.abc import Awaitable, Callable, Iterable
from typing import Any
from . import events
__all__ = ("staggered_race",)
async def staggered_race(
coro_fns: Iterable[Callable[[], Awaitable[Any]]], delay: float | None, *, loop: events.AbstractEventLoop | None = None
) -> tuple[Any, int | None, list[Exception | None]]: ...

View File

@@ -0,0 +1,179 @@
import ssl
import sys
from _typeshed import StrPath
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence
from typing import Any
from typing_extensions import Self, SupportsIndex, TypeAlias
from . import events, protocols, transports
from .base_events import Server
if sys.platform == "win32":
if sys.version_info >= (3, 8):
__all__ = ("StreamReader", "StreamWriter", "StreamReaderProtocol", "open_connection", "start_server")
else:
__all__ = (
"StreamReader",
"StreamWriter",
"StreamReaderProtocol",
"open_connection",
"start_server",
"IncompleteReadError",
"LimitOverrunError",
)
else:
if sys.version_info >= (3, 8):
__all__ = (
"StreamReader",
"StreamWriter",
"StreamReaderProtocol",
"open_connection",
"start_server",
"open_unix_connection",
"start_unix_server",
)
else:
__all__ = (
"StreamReader",
"StreamWriter",
"StreamReaderProtocol",
"open_connection",
"start_server",
"IncompleteReadError",
"LimitOverrunError",
"open_unix_connection",
"start_unix_server",
)
_ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awaitable[None] | None]
if sys.version_info < (3, 8):
class IncompleteReadError(EOFError):
expected: int | None
partial: bytes
def __init__(self, partial: bytes, expected: int | None) -> None: ...
class LimitOverrunError(Exception):
consumed: int
def __init__(self, message: str, consumed: int) -> None: ...
if sys.version_info >= (3, 10):
async def open_connection(
host: str | None = None,
port: int | str | None = None,
*,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> tuple[StreamReader, StreamWriter]: ...
async def start_server(
client_connected_cb: _ClientConnectedCallback,
host: str | Sequence[str] | None = None,
port: int | str | None = None,
*,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> Server: ...
else:
async def open_connection(
host: str | None = None,
port: int | str | None = None,
*,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> tuple[StreamReader, StreamWriter]: ...
async def start_server(
client_connected_cb: _ClientConnectedCallback,
host: str | None = None,
port: int | str | None = None,
*,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
ssl_handshake_timeout: float | None = ...,
**kwds: Any,
) -> Server: ...
if sys.platform != "win32":
if sys.version_info >= (3, 10):
async def open_unix_connection(
path: StrPath | None = None, *, limit: int = 65536, **kwds: Any
) -> tuple[StreamReader, StreamWriter]: ...
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback, path: StrPath | None = None, *, limit: int = 65536, **kwds: Any
) -> Server: ...
else:
async def open_unix_connection(
path: StrPath | None = None, *, loop: events.AbstractEventLoop | None = None, limit: int = 65536, **kwds: Any
) -> tuple[StreamReader, StreamWriter]: ...
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback,
path: StrPath | None = None,
*,
loop: events.AbstractEventLoop | None = None,
limit: int = 65536,
**kwds: Any,
) -> Server: ...
class FlowControlMixin(protocols.Protocol):
def __init__(self, loop: events.AbstractEventLoop | None = None) -> None: ...
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __init__(
self,
stream_reader: StreamReader,
client_connected_cb: _ClientConnectedCallback | None = None,
loop: events.AbstractEventLoop | None = None,
) -> None: ...
class StreamWriter:
def __init__(
self,
transport: transports.WriteTransport,
protocol: protocols.BaseProtocol,
reader: StreamReader | None,
loop: events.AbstractEventLoop,
) -> None: ...
@property
def transport(self) -> transports.WriteTransport: ...
def write(self, data: bytes | bytearray | memoryview) -> None: ...
def writelines(self, data: Iterable[bytes | bytearray | memoryview]) -> None: ...
def write_eof(self) -> None: ...
def can_write_eof(self) -> bool: ...
def close(self) -> None: ...
def is_closing(self) -> bool: ...
async def wait_closed(self) -> None: ...
def get_extra_info(self, name: str, default: Any = None) -> Any: ...
async def drain(self) -> None: ...
if sys.version_info >= (3, 12):
async def start_tls(
self,
sslcontext: ssl.SSLContext,
*,
server_hostname: str | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
) -> None: ...
elif sys.version_info >= (3, 11):
async def start_tls(
self, sslcontext: ssl.SSLContext, *, server_hostname: str | None = None, ssl_handshake_timeout: float | None = None
) -> None: ...
class StreamReader(AsyncIterator[bytes]):
def __init__(self, limit: int = 65536, loop: events.AbstractEventLoop | None = None) -> None: ...
def exception(self) -> Exception: ...
def set_exception(self, exc: Exception) -> None: ...
def set_transport(self, transport: transports.BaseTransport) -> None: ...
def feed_eof(self) -> None: ...
def at_eof(self) -> bool: ...
def feed_data(self, data: Iterable[SupportsIndex]) -> None: ...
async def readline(self) -> bytes: ...
# Can be any buffer that supports len(); consider changing to a Protocol if PEP 688 is accepted
async def readuntil(self, separator: bytes | bytearray | memoryview = b"\n") -> bytes: ...
async def read(self, n: int = -1) -> bytes: ...
async def readexactly(self, n: int) -> bytes: ...
def __aiter__(self) -> Self: ...
async def __anext__(self) -> bytes: ...

View File

@@ -0,0 +1,20 @@
import sys
from contextvars import Context
from types import TracebackType
from typing import TypeVar
from typing_extensions import Self
from . import _CoroutineLike
from .tasks import Task
if sys.version_info >= (3, 12):
__all__ = ("TaskGroup",)
else:
__all__ = ["TaskGroup"]
_T = TypeVar("_T")
class TaskGroup:
async def __aenter__(self) -> Self: ...
async def __aexit__(self, et: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ...
def create_task(self, coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None) -> Task[_T]: ...

View File

@@ -0,0 +1,348 @@
import concurrent.futures
import sys
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
from types import FrameType
from typing import Any, Generic, TextIO, TypeVar, overload
from typing_extensions import Literal, TypeAlias
from . import _CoroutineLike
from .events import AbstractEventLoop
from .futures import Future
if sys.version_info >= (3, 9):
from types import GenericAlias
if sys.version_info >= (3, 11):
from contextvars import Context
__all__ = (
"Task",
"create_task",
"FIRST_COMPLETED",
"FIRST_EXCEPTION",
"ALL_COMPLETED",
"wait",
"wait_for",
"as_completed",
"sleep",
"gather",
"shield",
"ensure_future",
"run_coroutine_threadsafe",
"current_task",
"all_tasks",
"_register_task",
"_unregister_task",
"_enter_task",
"_leave_task",
)
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
_T3 = TypeVar("_T3")
_T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_FT = TypeVar("_FT", bound=Future[Any])
_FutureLike: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
_TaskYieldType: TypeAlias = Future[object] | None
FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED
FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION
ALL_COMPLETED = concurrent.futures.ALL_COMPLETED
if sys.version_info >= (3, 10):
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ...
else:
def as_completed(
fs: Iterable[_FutureLike[_T]], *, loop: AbstractEventLoop | None = None, timeout: float | None = None
) -> Iterator[Future[_T]]: ...
@overload
def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[misc]
@overload
def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = None) -> Task[_T]: ...
# `gather()` actually returns a list with length equal to the number
# of tasks passed; however, Tuple is used similar to the annotation for
# zip() because typing does not support variadic type variables. See
# typing PR #1550 for discussion.
#
# The many type: ignores here are because the overloads overlap,
# but having overlapping overloads is the only way to get acceptable type inference in all edge cases.
if sys.version_info >= (3, 10):
@overload
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[misc]
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, return_exceptions: Literal[False] = False
) -> Future[tuple[_T1, _T2]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
*,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
*,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
*,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def gather(__coro_or_future1: _FutureLike[_T1], *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[misc]
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1], __coro_or_future2: _FutureLike[_T2], *, return_exceptions: bool
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
*,
return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
*,
return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
*,
return_exceptions: bool,
) -> Future[
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
@overload
def gather(*coros_or_futures: _FutureLike[Any], return_exceptions: bool = False) -> Future[list[Any]]: ...
else:
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False
) -> Future[tuple[_T1]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1], *, loop: AbstractEventLoop | None = None, return_exceptions: bool
) -> Future[tuple[_T1 | BaseException]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
@overload
def gather( # type: ignore[misc]
__coro_or_future1: _FutureLike[_T1],
__coro_or_future2: _FutureLike[_T2],
__coro_or_future3: _FutureLike[_T3],
__coro_or_future4: _FutureLike[_T4],
__coro_or_future5: _FutureLike[_T5],
*,
loop: AbstractEventLoop | None = None,
return_exceptions: bool,
) -> Future[
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
@overload
def gather(
*coros_or_futures: _FutureLike[Any], loop: AbstractEventLoop | None = None, return_exceptions: bool = False
) -> Future[list[Any]]: ...
def run_coroutine_threadsafe(coro: _FutureLike[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
if sys.version_info >= (3, 10):
def shield(arg: _FutureLike[_T]) -> Future[_T]: ...
@overload
async def sleep(delay: float) -> None: ...
@overload
async def sleep(delay: float, result: _T) -> _T: ...
@overload
async def wait(fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED") -> tuple[set[_FT], set[_FT]]: ... # type: ignore[misc]
@overload
async def wait(
fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ...
else:
def shield(arg: _FutureLike[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
@overload
async def sleep(delay: float, *, loop: AbstractEventLoop | None = None) -> None: ...
@overload
async def sleep(delay: float, result: _T, *, loop: AbstractEventLoop | None = None) -> _T: ...
@overload
async def wait( # type: ignore[misc]
fs: Iterable[_FT],
*,
loop: AbstractEventLoop | None = None,
timeout: float | None = None,
return_when: str = "ALL_COMPLETED",
) -> tuple[set[_FT], set[_FT]]: ...
@overload
async def wait(
fs: Iterable[Awaitable[_T]],
*,
loop: AbstractEventLoop | None = None,
timeout: float | None = None,
return_when: str = "ALL_COMPLETED",
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
async def wait_for(fut: _FutureLike[_T], timeout: float | None, *, loop: AbstractEventLoop | None = None) -> _T: ...
if sys.version_info >= (3, 12):
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
else:
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co]
# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
# While this is true in general, here it's sort-of okay to have a covariant subclass,
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
# and `asyncio.Task.set_result()` always raises.
class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright: ignore[reportGeneralTypeIssues]
if sys.version_info >= (3, 12):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
name: str | None = ...,
context: Context | None = None,
eager_start: bool = False,
) -> None: ...
elif sys.version_info >= (3, 11):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop = ...,
name: str | None = ...,
context: Context | None = None,
) -> None: ...
elif sys.version_info >= (3, 8):
def __init__(
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ..., name: str | None = ...
) -> None: ...
else:
def __init__(self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop = ...) -> None: ...
if sys.version_info >= (3, 8):
def get_coro(self) -> _TaskCompatibleCoro[_T_co]: ...
def get_name(self) -> str: ...
def set_name(self, __value: object) -> None: ...
if sys.version_info >= (3, 12):
def get_context(self) -> Context: ...
def get_stack(self, *, limit: int | None = None) -> list[FrameType]: ...
def print_stack(self, *, limit: int | None = None, file: TextIO | None = None) -> None: ...
if sys.version_info >= (3, 11):
def cancelling(self) -> int: ...
def uncancel(self) -> int: ...
if sys.version_info < (3, 9):
@classmethod
def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
@classmethod
def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 11):
def create_task(coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None) -> Task[_T]: ...
elif sys.version_info >= (3, 8):
def create_task(coro: _CoroutineLike[_T], *, name: str | None = None) -> Task[_T]: ...
else:
def create_task(coro: _CoroutineLike[_T]) -> Task[_T]: ...
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _register_task(task: Task[Any]) -> None: ...
def _unregister_task(task: Task[Any]) -> None: ...

View File

@@ -0,0 +1,9 @@
from collections.abc import Callable
from typing import TypeVar
from typing_extensions import ParamSpec
__all__ = ("to_thread",)
_P = ParamSpec("_P")
_R = TypeVar("_R")
async def to_thread(__func: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ...

View File

@@ -0,0 +1,18 @@
from types import TracebackType
from typing_extensions import Self, final
__all__ = ("Timeout", "timeout", "timeout_at")
@final
class Timeout:
def __init__(self, when: float | None) -> None: ...
def when(self) -> float | None: ...
def reschedule(self, when: float | None) -> None: ...
def expired(self) -> bool: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def timeout(delay: float | None) -> Timeout: ...
def timeout_at(when: float | None) -> Timeout: ...

View File

@@ -0,0 +1,47 @@
from asyncio.events import AbstractEventLoop
from asyncio.protocols import BaseProtocol
from collections.abc import Iterable, Mapping
from stdlib.socket import _Address
from typing import Any
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")
class BaseTransport:
def __init__(self, extra: Mapping[str, Any] | None = None) -> None: ...
def get_extra_info(self, name: str, default: Any = None) -> Any: ...
def is_closing(self) -> bool: ...
def close(self) -> None: ...
def set_protocol(self, protocol: BaseProtocol) -> None: ...
def get_protocol(self) -> BaseProtocol: ...
class ReadTransport(BaseTransport):
def is_reading(self) -> bool: ...
def pause_reading(self) -> None: ...
def resume_reading(self) -> None: ...
class WriteTransport(BaseTransport):
def set_write_buffer_limits(self, high: int | None = None, low: int | None = None) -> None: ...
def get_write_buffer_size(self) -> int: ...
def get_write_buffer_limits(self) -> tuple[int, int]: ...
def write(self, data: bytes | bytearray | memoryview) -> None: ...
def writelines(self, list_of_data: Iterable[bytes | bytearray | memoryview]) -> None: ...
def write_eof(self) -> None: ...
def can_write_eof(self) -> bool: ...
def abort(self) -> None: ...
class Transport(ReadTransport, WriteTransport): ...
class DatagramTransport(BaseTransport):
def sendto(self, data: bytes | bytearray | memoryview, addr: _Address | None = None) -> None: ...
def abort(self) -> None: ...
class SubprocessTransport(BaseTransport):
def get_pid(self) -> int: ...
def get_returncode(self) -> int | None: ...
def get_pipe_transport(self, fd: int) -> BaseTransport | None: ...
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
class _FlowControlMixin(Transport):
def __init__(self, extra: Mapping[str, Any] | None = None, loop: AbstractEventLoop | None = None) -> None: ...

View File

@@ -0,0 +1,122 @@
import sys
from builtins import type as Type # alias to avoid name clashes with property named "type"
from collections.abc import Iterable
from types import TracebackType
from typing import Any, BinaryIO, NoReturn, overload
import stdlib.socket as socket
from _typeshed import ReadableBuffer
from typing_extensions import TypeAlias
# These are based in socket, maybe move them out into _typeshed.pyi or such
_Address: TypeAlias = socket._Address
_RetAddress: TypeAlias = Any
_WriteBuffer: TypeAlias = bytearray | memoryview
_CMSG: TypeAlias = tuple[int, int, bytes]
class TransportSocket:
def __init__(self, sock: socket.socket) -> None: ...
@property
def family(self) -> int: ...
@property
def type(self) -> int: ...
@property
def proto(self) -> int: ...
def __getstate__(self) -> NoReturn: ...
def fileno(self) -> int: ...
def dup(self) -> socket.socket: ...
def get_inheritable(self) -> bool: ...
def shutdown(self, how: int) -> None: ...
@overload
def getsockopt(self, level: int, optname: int) -> int: ...
@overload
def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
@overload
def setsockopt(self, level: int, optname: int, value: int | ReadableBuffer) -> None: ...
@overload
def setsockopt(self, level: int, optname: int, value: None, optlen: int) -> None: ...
def getpeername(self) -> _RetAddress: ...
def getsockname(self) -> _RetAddress: ...
def getsockbyname(
self,
) -> NoReturn: ... # This method doesn't exist on socket, yet is passed through?
def settimeout(self, value: float | None) -> None: ...
def gettimeout(self) -> float | None: ...
def setblocking(self, flag: bool) -> None: ...
if sys.version_info < (3, 11):
def _na(self, what: str) -> None: ...
def accept(self) -> tuple[socket.socket, _RetAddress]: ...
def connect(self, address: _Address) -> None: ...
def connect_ex(self, address: _Address) -> int: ...
def bind(self, address: _Address) -> None: ...
if sys.platform == "win32":
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ...
else:
def ioctl(
self, control: int, option: int | tuple[int, int, int] | bool
) -> NoReturn: ...
def listen(self, __backlog: int = ...) -> None: ...
def makefile(self) -> BinaryIO: ...
def sendfile(self, file: BinaryIO, offset: int = ..., count: int | None = ...) -> int: ...
def close(self) -> None: ...
def detach(self) -> int: ...
if sys.platform == "linux":
def sendmsg_afalg(
self,
msg: Iterable[ReadableBuffer] = ...,
*,
op: int,
iv: Any = ...,
assoclen: int = ...,
flags: int = ...
) -> int: ...
else:
def sendmsg_afalg(
self,
msg: Iterable[ReadableBuffer] = ...,
*,
op: int,
iv: Any = ...,
assoclen: int = ...,
flags: int = ...
) -> NoReturn: ...
def sendmsg(
self,
__buffers: Iterable[ReadableBuffer],
__ancdata: Iterable[_CMSG] = ...,
__flags: int = ...,
__address: _Address = ...,
) -> int: ...
@overload
def sendto(self, data: ReadableBuffer, address: _Address) -> int: ...
@overload
def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ...
def send(self, data: ReadableBuffer, flags: int = ...) -> int: ...
def sendall(self, data: ReadableBuffer, flags: int = ...) -> None: ...
def set_inheritable(self, inheritable: bool) -> None: ...
if sys.platform == "win32":
def share(self, process_id: int) -> bytes: ...
else:
def share(self, process_id: int) -> NoReturn: ...
def recv_into(self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...) -> int: ...
def recvfrom_into(
self, buffer: _WriteBuffer, nbytes: int = ..., flags: int = ...
) -> tuple[int, _RetAddress]: ...
def recvmsg_into(
self, __buffers: Iterable[_WriteBuffer], __ancbufsize: int = ..., __flags: int = ...
) -> tuple[int, list[_CMSG], int, Any]: ...
def recvmsg(
self, __bufsize: int, __ancbufsize: int = ..., __flags: int = ...
) -> tuple[bytes, list[_CMSG], int, Any]: ...
def recvfrom(self, bufsize: int, flags: int = ...) -> tuple[bytes, _RetAddress]: ...
def recv(self, bufsize: int, flags: int = ...) -> bytes: ...
def __enter__(self) -> socket.socket: ...
def __exit__(
self,
exc_type: Type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None: ...

View File

@@ -0,0 +1,127 @@
import sys
import types
from abc import ABCMeta, abstractmethod
from collections.abc import Callable
from typing import Any
from typing_extensions import Literal, Self
from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy
from .selector_events import BaseSelectorEventLoop
# This is also technically not available on Win,
# but other parts of typeshed need this definition.
# So, it is special cased.
class AbstractChildWatcher:
@abstractmethod
def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ...
@abstractmethod
def remove_child_handler(self, pid: int) -> bool: ...
@abstractmethod
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
@abstractmethod
def close(self) -> None: ...
@abstractmethod
def __enter__(self) -> Self: ...
@abstractmethod
def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
if sys.version_info >= (3, 8):
@abstractmethod
def is_active(self) -> bool: ...
if sys.platform != "win32":
if sys.version_info >= (3, 9):
__all__ = (
"SelectorEventLoop",
"AbstractChildWatcher",
"SafeChildWatcher",
"FastChildWatcher",
"PidfdChildWatcher",
"MultiLoopChildWatcher",
"ThreadedChildWatcher",
"DefaultEventLoopPolicy",
)
elif sys.version_info >= (3, 8):
__all__ = (
"SelectorEventLoop",
"AbstractChildWatcher",
"SafeChildWatcher",
"FastChildWatcher",
"MultiLoopChildWatcher",
"ThreadedChildWatcher",
"DefaultEventLoopPolicy",
)
else:
__all__ = ("SelectorEventLoop", "AbstractChildWatcher", "SafeChildWatcher", "FastChildWatcher", "DefaultEventLoopPolicy")
# Doesn't actually have ABCMeta metaclass at runtime, but mypy complains if we don't have it in the stub.
# See discussion in #7412
class BaseChildWatcher(AbstractChildWatcher, metaclass=ABCMeta):
def close(self) -> None: ...
if sys.version_info >= (3, 8):
def is_active(self) -> bool: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
class SafeChildWatcher(BaseChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
class FastChildWatcher(BaseChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
class _UnixSelectorEventLoop(BaseSelectorEventLoop): ...
class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy):
def get_child_watcher(self) -> AbstractChildWatcher: ...
def set_child_watcher(self, watcher: AbstractChildWatcher | None) -> None: ...
SelectorEventLoop = _UnixSelectorEventLoop
DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy
if sys.version_info >= (3, 8):
from typing import Protocol
class _Warn(Protocol):
def __call__(
self, message: str, category: type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...
) -> object: ...
class MultiLoopChildWatcher(AbstractChildWatcher):
def is_active(self) -> bool: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
class ThreadedChildWatcher(AbstractChildWatcher):
def is_active(self) -> Literal[True]: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def __del__(self, _warn: _Warn = ...) -> None: ...
def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
if sys.version_info >= (3, 9):
class PidfdChildWatcher(AbstractChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
) -> None: ...
def is_active(self) -> bool: ...
def close(self) -> None: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
def add_child_handler(self, pid: int, callback: Callable[..., object], *args: Any) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...

1958
.vscode/Pico-W-Stub/stdlib/builtins.pyi vendored Normal file

File diff suppressed because it is too large Load Diff

277
.vscode/Pico-W-Stub/stdlib/codecs.pyi vendored Normal file
View File

@@ -0,0 +1,277 @@
import types
from _codecs import *
from _typeshed import ReadableBuffer, Self
from abc import abstractmethod
from collections.abc import Callable, Generator, Iterable
from typing import Any, BinaryIO, Protocol, TextIO
from typing_extensions import Literal
__all__ = [
"register",
"lookup",
"open",
"EncodedFile",
"BOM",
"BOM_BE",
"BOM_LE",
"BOM32_BE",
"BOM32_LE",
"BOM64_BE",
"BOM64_LE",
"BOM_UTF8",
"BOM_UTF16",
"BOM_UTF16_LE",
"BOM_UTF16_BE",
"BOM_UTF32",
"BOM_UTF32_LE",
"BOM_UTF32_BE",
"CodecInfo",
"Codec",
"IncrementalEncoder",
"IncrementalDecoder",
"StreamReader",
"StreamWriter",
"StreamReaderWriter",
"StreamRecoder",
"getencoder",
"getdecoder",
"getincrementalencoder",
"getincrementaldecoder",
"getreader",
"getwriter",
"encode",
"decode",
"iterencode",
"iterdecode",
"strict_errors",
"ignore_errors",
"replace_errors",
"xmlcharrefreplace_errors",
"backslashreplace_errors",
"namereplace_errors",
"register_error",
"lookup_error",
]
BOM32_BE: Literal[b"\xfe\xff"]
BOM32_LE: Literal[b"\xff\xfe"]
BOM64_BE: Literal[b"\x00\x00\xfe\xff"]
BOM64_LE: Literal[b"\xff\xfe\x00\x00"]
class _WritableStream(Protocol):
def write(self, __data: bytes) -> object: ...
def seek(self, __offset: int, __whence: int) -> object: ...
def close(self) -> object: ...
class _ReadableStream(Protocol):
def read(self, __size: int = ...) -> bytes: ...
def seek(self, __offset: int, __whence: int) -> object: ...
def close(self) -> object: ...
class _Stream(_WritableStream, _ReadableStream, Protocol): ...
# TODO: this only satisfies the most common interface, where
# bytes is the raw form and str is the cooked form.
# In the long run, both should become template parameters maybe?
# There *are* bytes->bytes and str->str encodings in the standard library.
# They were much more common in Python 2 than in Python 3.
class _Encoder(Protocol):
def __call__(self, input: str, errors: str = ...) -> tuple[bytes, int]: ... # signature of Codec().encode
class _Decoder(Protocol):
def __call__(self, input: bytes, errors: str = ...) -> tuple[str, int]: ... # signature of Codec().decode
class _StreamReader(Protocol):
def __call__(self, stream: _ReadableStream, errors: str = ...) -> StreamReader: ...
class _StreamWriter(Protocol):
def __call__(self, stream: _WritableStream, errors: str = ...) -> StreamWriter: ...
class _IncrementalEncoder(Protocol):
def __call__(self, errors: str = ...) -> IncrementalEncoder: ...
class _IncrementalDecoder(Protocol):
def __call__(self, errors: str = ...) -> IncrementalDecoder: ...
class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
@property
def encode(self) -> _Encoder: ...
@property
def decode(self) -> _Decoder: ...
@property
def streamreader(self) -> _StreamReader: ...
@property
def streamwriter(self) -> _StreamWriter: ...
@property
def incrementalencoder(self) -> _IncrementalEncoder: ...
@property
def incrementaldecoder(self) -> _IncrementalDecoder: ...
name: str
def __new__(
cls: type[Self],
encode: _Encoder,
decode: _Decoder,
streamreader: _StreamReader | None = ...,
streamwriter: _StreamWriter | None = ...,
incrementalencoder: _IncrementalEncoder | None = ...,
incrementaldecoder: _IncrementalDecoder | None = ...,
name: str | None = ...,
*,
_is_text_encoding: bool | None = ...,
) -> Self: ...
def getencoder(encoding: str) -> _Encoder: ...
def getdecoder(encoding: str) -> _Decoder: ...
def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ...
def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
def getreader(encoding: str) -> _StreamReader: ...
def getwriter(encoding: str) -> _StreamWriter: ...
def open(
filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., buffering: int = ...
) -> StreamReaderWriter: ...
def EncodedFile(file: _Stream, data_encoding: str, file_encoding: str | None = ..., errors: str = ...) -> StreamRecoder: ...
def iterencode(iterator: Iterable[str], encoding: str, errors: str = ...) -> Generator[bytes, None, None]: ...
def iterdecode(iterator: Iterable[bytes], encoding: str, errors: str = ...) -> Generator[str, None, None]: ...
BOM: Literal[b"\xff\xfe", b"\xfe\xff"] # depends on `sys.byteorder`
BOM_BE: Literal[b"\xfe\xff"]
BOM_LE: Literal[b"\xff\xfe"]
BOM_UTF8: Literal[b"\xef\xbb\xbf"]
BOM_UTF16: Literal[b"\xff\xfe", b"\xfe\xff"] # depends on `sys.byteorder`
BOM_UTF16_BE: Literal[b"\xfe\xff"]
BOM_UTF16_LE: Literal[b"\xff\xfe"]
BOM_UTF32: Literal[b"\xff\xfe\x00\x00", b"\x00\x00\xfe\xff"] # depends on `sys.byteorder`
BOM_UTF32_BE: Literal[b"\x00\x00\xfe\xff"]
BOM_UTF32_LE: Literal[b"\xff\xfe\x00\x00"]
def strict_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ...
def replace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ...
def ignore_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ...
def xmlcharrefreplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ...
def backslashreplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ...
def namereplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ...
class Codec:
# These are sort of @abstractmethod but sort of not.
# The StreamReader and StreamWriter subclasses only implement one.
def encode(self, input: str, errors: str = ...) -> tuple[bytes, int]: ...
def decode(self, input: bytes, errors: str = ...) -> tuple[str, int]: ...
class IncrementalEncoder:
errors: str
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def encode(self, input: str, final: bool = ...) -> bytes: ...
def reset(self) -> None: ...
# documentation says int but str is needed for the subclass.
def getstate(self) -> int | str: ...
def setstate(self, state: int | str) -> None: ...
class IncrementalDecoder:
errors: str
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def decode(self, input: ReadableBuffer, final: bool = ...) -> str: ...
def reset(self) -> None: ...
def getstate(self) -> tuple[bytes, int]: ...
def setstate(self, state: tuple[bytes, int]) -> None: ...
# These are not documented but used in encodings/*.py implementations.
class BufferedIncrementalEncoder(IncrementalEncoder):
buffer: str
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def _buffer_encode(self, input: str, errors: str, final: bool) -> bytes: ...
def encode(self, input: str, final: bool = ...) -> bytes: ...
class BufferedIncrementalDecoder(IncrementalDecoder):
buffer: bytes
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def _buffer_decode(self, input: ReadableBuffer, errors: str, final: bool) -> tuple[str, int]: ...
def decode(self, input: ReadableBuffer, final: bool = ...) -> str: ...
# TODO: it is not possible to specify the requirement that all other
# attributes and methods are passed-through from the stream.
class StreamWriter(Codec):
stream: _WritableStream
errors: str
def __init__(self, stream: _WritableStream, errors: str = ...) -> None: ...
def write(self, object: str) -> None: ...
def writelines(self, list: Iterable[str]) -> None: ...
def reset(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
class StreamReader(Codec):
stream: _ReadableStream
errors: str
def __init__(self, stream: _ReadableStream, errors: str = ...) -> None: ...
def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> str: ...
def readline(self, size: int | None = ..., keepends: bool = ...) -> str: ...
def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> list[str]: ...
def reset(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __iter__(self: Self) -> Self: ...
def __next__(self) -> str: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
# Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing
# and delegates attributes to the underlying binary stream with __getattr__.
class StreamReaderWriter(TextIO):
stream: _Stream
def __init__(self, stream: _Stream, Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ...
def read(self, size: int = ...) -> str: ...
def readline(self, size: int | None = ...) -> str: ...
def readlines(self, sizehint: int | None = ...) -> list[str]: ...
def __next__(self) -> str: ...
def __iter__(self: Self) -> Self: ...
def write(self, data: str) -> None: ... # type: ignore[override]
def writelines(self, list: Iterable[str]) -> None: ...
def reset(self) -> None: ...
def seek(self, offset: int, whence: int = ...) -> None: ... # type: ignore[override]
def __enter__(self: Self) -> Self: ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __getattr__(self, name: str) -> Any: ...
# These methods don't actually exist directly, but they are needed to satisfy the TextIO
# interface. At runtime, they are delegated through __getattr__.
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def truncate(self, size: int | None = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def writable(self) -> bool: ...
class StreamRecoder(BinaryIO):
def __init__(
self, stream: _Stream, encode: _Encoder, decode: _Decoder, Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...
) -> None: ...
def read(self, size: int = ...) -> bytes: ...
def readline(self, size: int | None = ...) -> bytes: ...
def readlines(self, sizehint: int | None = ...) -> list[bytes]: ...
def __next__(self) -> bytes: ...
def __iter__(self: Self) -> Self: ...
def write(self, data: bytes) -> None: ... # type: ignore[override]
def writelines(self, list: Iterable[bytes]) -> None: ...
def reset(self) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
def seek(self, offset: int, whence: int = ...) -> None: ... # type: ignore[override]
# These methods don't actually exist directly, but they are needed to satisfy the BinaryIO
# interface. At runtime, they are delegated through __getattr__.
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def truncate(self, size: int | None = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def writable(self) -> bool: ...

View File

@@ -0,0 +1,432 @@
import sys
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import Self, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
from typing import Any, Generic, NoReturn, TypeVar, overload
from typing_extensions import SupportsIndex, final
if sys.version_info >= (3, 9):
from types import GenericAlias
if sys.version_info >= (3, 10):
from collections.abc import (
Callable,
ItemsView,
Iterable,
Iterator,
KeysView,
Mapping,
MutableMapping,
MutableSequence,
Reversible,
Sequence,
ValuesView,
)
else:
from _collections_abc import *
__all__ = ["ChainMap", "Counter", "OrderedDict", "UserDict", "UserList", "UserString", "defaultdict", "deque", "namedtuple"]
_S = TypeVar("_S")
_T = TypeVar("_T")
_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
_KT_co = TypeVar("_KT_co", covariant=True)
_VT_co = TypeVar("_VT_co", covariant=True)
# namedtuple is special-cased in the type checker; the initializer is ignored.
def namedtuple(
typename: str,
field_names: str | Iterable[str],
*,
rename: bool = ...,
module: str | None = ...,
defaults: Iterable[Any] | None = ...,
) -> type[tuple[Any, ...]]: ...
class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
data: dict[_KT, _VT]
# __init__ should be kept roughly in line with `dict.__init__`, which has the same semantics
@overload
def __init__(self, __dict: None = ...) -> None: ...
@overload
def __init__(self: UserDict[str, _VT], __dict: None = ..., **kwargs: _VT) -> None: ...
@overload
def __init__(self, __dict: SupportsKeysAndGetItem[_KT, _VT]) -> None: ...
@overload
def __init__(self: UserDict[str, _VT], __dict: SupportsKeysAndGetItem[str, _VT], **kwargs: _VT) -> None: ...
@overload
def __init__(self, __iterable: Iterable[tuple[_KT, _VT]]) -> None: ...
@overload
def __init__(self: UserDict[str, _VT], __iterable: Iterable[tuple[str, _VT]], **kwargs: _VT) -> None: ...
@overload
def __init__(self: UserDict[str, str], __iterable: Iterable[list[str]]) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, key: _KT) -> _VT: ...
def __setitem__(self, key: _KT, item: _VT) -> None: ...
def __delitem__(self, key: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
def __contains__(self, key: object) -> bool: ...
def copy(self: Self) -> Self: ...
def __copy__(self: Self) -> Self: ...
# `UserDict.fromkeys` has the same semantics as `dict.fromkeys`, so should be kept in line with `dict.fromkeys`.
# TODO: Much like `dict.fromkeys`, the true signature of `UserDict.fromkeys` is inexpressible in the current type system.
# See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963.
@classmethod
@overload
def fromkeys(cls, iterable: Iterable[_T], value: None = ...) -> UserDict[_T, Any | None]: ...
@classmethod
@overload
def fromkeys(cls, iterable: Iterable[_T], value: _S) -> UserDict[_T, _S]: ...
if sys.version_info >= (3, 9):
def __or__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ...
def __ror__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
# UserDict.__ior__ should be kept roughly in line with MutableMapping.update()
@overload # type: ignore[misc]
def __ior__(self: Self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ...
@overload
def __ior__(self: Self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...
class UserList(MutableSequence[_T]):
data: list[_T]
@overload
def __init__(self, initlist: None = ...) -> None: ...
@overload
def __init__(self, initlist: Iterable[_T]) -> None: ...
def __lt__(self, other: list[_T] | UserList[_T]) -> bool: ...
def __le__(self, other: list[_T] | UserList[_T]) -> bool: ...
def __gt__(self, other: list[_T] | UserList[_T]) -> bool: ...
def __ge__(self, other: list[_T] | UserList[_T]) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __contains__(self, item: object) -> bool: ...
def __len__(self) -> int: ...
@overload
def __getitem__(self, i: SupportsIndex) -> _T: ...
@overload
def __getitem__(self: Self, i: slice) -> Self: ...
@overload
def __setitem__(self, i: SupportsIndex, item: _T) -> None: ...
@overload
def __setitem__(self, i: slice, item: Iterable[_T]) -> None: ...
def __delitem__(self, i: SupportsIndex | slice) -> None: ...
def __add__(self: Self, other: Iterable[_T]) -> Self: ...
def __radd__(self: Self, other: Iterable[_T]) -> Self: ...
def __iadd__(self: Self, other: Iterable[_T]) -> Self: ...
def __mul__(self: Self, n: int) -> Self: ...
def __rmul__(self: Self, n: int) -> Self: ...
def __imul__(self: Self, n: int) -> Self: ...
def append(self, item: _T) -> None: ...
def insert(self, i: int, item: _T) -> None: ...
def pop(self, i: int = ...) -> _T: ...
def remove(self, item: _T) -> None: ...
def copy(self: Self) -> Self: ...
def __copy__(self: Self) -> Self: ...
def count(self, item: _T) -> int: ...
# All arguments are passed to `list.index` at runtime, so the signature should be kept in line with `list.index`.
def index(self, item: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ...
# All arguments are passed to `list.sort` at runtime, so the signature should be kept in line with `list.sort`.
@overload
def sort(self: UserList[SupportsRichComparisonT], *, key: None = ..., reverse: bool = ...) -> None: ...
@overload
def sort(self, *, key: Callable[[_T], SupportsRichComparison], reverse: bool = ...) -> None: ...
def extend(self, other: Iterable[_T]) -> None: ...
class UserString(Sequence[UserString]):
data: str
def __init__(self, seq: object) -> None: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
def __getnewargs__(self) -> tuple[str]: ...
def __lt__(self, string: str | UserString) -> bool: ...
def __le__(self, string: str | UserString) -> bool: ...
def __gt__(self, string: str | UserString) -> bool: ...
def __ge__(self, string: str | UserString) -> bool: ...
def __eq__(self, string: object) -> bool: ...
def __contains__(self, char: object) -> bool: ...
def __len__(self) -> int: ...
def __getitem__(self: Self, index: SupportsIndex | slice) -> Self: ...
def __iter__(self: Self) -> Iterator[Self]: ...
def __reversed__(self: Self) -> Iterator[Self]: ...
def __add__(self: Self, other: object) -> Self: ...
def __radd__(self: Self, other: object) -> Self: ...
def __mul__(self: Self, n: int) -> Self: ...
def __rmul__(self: Self, n: int) -> Self: ...
def __mod__(self: Self, args: Any) -> Self: ...
if sys.version_info >= (3, 8):
def __rmod__(self: Self, template: object) -> Self: ...
else:
def __rmod__(self: Self, format: Any) -> Self: ...
def capitalize(self: Self) -> Self: ...
def casefold(self: Self) -> Self: ...
def center(self: Self, width: int, *args: Any) -> Self: ...
def count(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
if sys.version_info >= (3, 8):
def encode(self: UserString, encoding: str | None = ..., errors: str | None = ...) -> bytes: ...
else:
def encode(self: Self, encoding: str | None = ..., errors: str | None = ...) -> Self: ...
def endswith(self, suffix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def expandtabs(self: Self, tabsize: int = ...) -> Self: ...
def find(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
def format(self, *args: Any, **kwds: Any) -> str: ...
def format_map(self, mapping: Mapping[str, Any]) -> str: ...
def index(self, sub: str, start: int = ..., end: int = ...) -> int: ...
def isalpha(self) -> bool: ...
def isalnum(self) -> bool: ...
def isdecimal(self) -> bool: ...
def isdigit(self) -> bool: ...
def isidentifier(self) -> bool: ...
def islower(self) -> bool: ...
def isnumeric(self) -> bool: ...
def isprintable(self) -> bool: ...
def isspace(self) -> bool: ...
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
def isascii(self) -> bool: ...
def join(self, seq: Iterable[str]) -> str: ...
def ljust(self: Self, width: int, *args: Any) -> Self: ...
def lower(self: Self) -> Self: ...
def lstrip(self: Self, chars: str | None = ...) -> Self: ...
@staticmethod
@overload
def maketrans(x: dict[int, _T] | dict[str, _T] | dict[str | int, _T]) -> dict[int, _T]: ...
@staticmethod
@overload
def maketrans(x: str, y: str, z: str = ...) -> dict[int, int | None]: ...
def partition(self, sep: str) -> tuple[str, str, str]: ...
if sys.version_info >= (3, 9):
def removeprefix(self: Self, __prefix: str | UserString) -> Self: ...
def removesuffix(self: Self, __suffix: str | UserString) -> Self: ...
def replace(self: Self, old: str | UserString, new: str | UserString, maxsplit: int = ...) -> Self: ...
def rfind(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
def rindex(self, sub: str | UserString, start: int = ..., end: int = ...) -> int: ...
def rjust(self: Self, width: int, *args: Any) -> Self: ...
def rpartition(self, sep: str) -> tuple[str, str, str]: ...
def rstrip(self: Self, chars: str | None = ...) -> Self: ...
def split(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ...
def rsplit(self, sep: str | None = ..., maxsplit: int = ...) -> list[str]: ...
def splitlines(self, keepends: bool = ...) -> list[str]: ...
def startswith(self, prefix: str | tuple[str, ...], start: int | None = ..., end: int | None = ...) -> bool: ...
def strip(self: Self, chars: str | None = ...) -> Self: ...
def swapcase(self: Self) -> Self: ...
def title(self: Self) -> Self: ...
def translate(self: Self, *args: Any) -> Self: ...
def upper(self: Self) -> Self: ...
def zfill(self: Self, width: int) -> Self: ...
class deque(MutableSequence[_T], Generic[_T]):
@property
def maxlen(self) -> int | None: ...
@overload
def __init__(self, *, maxlen: int | None = ...) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T], maxlen: int | None = ...) -> None: ...
def append(self, __x: _T) -> None: ...
def appendleft(self, __x: _T) -> None: ...
def copy(self: Self) -> Self: ...
def count(self, __x: _T) -> int: ...
def extend(self, __iterable: Iterable[_T]) -> None: ...
def extendleft(self, __iterable: Iterable[_T]) -> None: ...
def insert(self, __i: int, __x: _T) -> None: ...
def index(self, __x: _T, __start: int = ..., __stop: int = ...) -> int: ...
def pop(self) -> _T: ... # type: ignore[override]
def popleft(self) -> _T: ...
def remove(self, __value: _T) -> None: ...
def rotate(self, __n: int = ...) -> None: ...
def __copy__(self: Self) -> Self: ...
def __len__(self) -> int: ...
# These methods of deque don't take slices, unlike MutableSequence, hence the type: ignores
def __getitem__(self, __index: SupportsIndex) -> _T: ... # type: ignore[override]
def __setitem__(self, __i: SupportsIndex, __x: _T) -> None: ... # type: ignore[override]
def __delitem__(self, __i: SupportsIndex) -> None: ... # type: ignore[override]
def __contains__(self, __o: object) -> bool: ...
def __reduce__(self: Self) -> tuple[type[Self], tuple[()], None, Iterator[_T]]: ...
def __iadd__(self: Self, __iterable: Iterable[_T]) -> Self: ...
def __add__(self: Self, __other: Self) -> Self: ...
def __mul__(self: Self, __other: int) -> Self: ...
def __imul__(self: Self, __other: int) -> Self: ...
def __lt__(self, __other: deque[_T]) -> bool: ...
def __le__(self, __other: deque[_T]) -> bool: ...
def __gt__(self, __other: deque[_T]) -> bool: ...
def __ge__(self, __other: deque[_T]) -> bool: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
class Counter(dict[_T, int], Generic[_T]):
@overload
def __init__(self, __iterable: None = ...) -> None: ...
@overload
def __init__(self: Counter[str], __iterable: None = ..., **kwargs: int) -> None: ...
@overload
def __init__(self, __mapping: SupportsKeysAndGetItem[_T, int]) -> None: ...
@overload
def __init__(self, __iterable: Iterable[_T]) -> None: ...
def copy(self: Self) -> Self: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: int | None = ...) -> list[tuple[_T, int]]: ...
@classmethod
def fromkeys(cls, iterable: Any, v: int | None = ...) -> NoReturn: ... # type: ignore[override]
@overload
def subtract(self, __iterable: None = ...) -> None: ...
@overload
def subtract(self, __mapping: Mapping[_T, int]) -> None: ...
@overload
def subtract(self, __iterable: Iterable[_T]) -> None: ...
# Unlike dict.update(), use Mapping instead of SupportsKeysAndGetItem for the first overload
# (source code does an `isinstance(other, Mapping)` check)
#
# The second overload is also deliberately different to dict.update()
# (if it were `Iterable[_T] | Iterable[tuple[_T, int]]`,
# the tuples would be added as keys, breaking type safety)
@overload # type: ignore[override]
def update(self, __m: Mapping[_T, int], **kwargs: int) -> None: ...
@overload
def update(self, __m: Iterable[_T], **kwargs: int) -> None: ...
@overload
def update(self, __m: None = ..., **kwargs: int) -> None: ...
def __missing__(self, key: _T) -> int: ...
def __delitem__(self, elem: object) -> None: ...
if sys.version_info >= (3, 10):
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __add__(self, other: Counter[_S]) -> Counter[_T | _S]: ...
def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...
def __and__(self, other: Counter[_T]) -> Counter[_T]: ...
def __or__(self, other: Counter[_S]) -> Counter[_T | _S]: ... # type: ignore[override]
def __pos__(self) -> Counter[_T]: ...
def __neg__(self) -> Counter[_T]: ...
# several type: ignores because __iadd__ is supposedly incompatible with __add__, etc.
def __iadd__(self: Self, other: Counter[_T]) -> Self: ... # type: ignore[misc]
def __isub__(self: Self, other: Counter[_T]) -> Self: ...
def __iand__(self: Self, other: Counter[_T]) -> Self: ...
def __ior__(self: Self, other: Counter[_T]) -> Self: ... # type: ignore[override,misc]
if sys.version_info >= (3, 10):
def total(self) -> int: ...
def __le__(self, other: Counter[Any]) -> bool: ...
def __lt__(self, other: Counter[Any]) -> bool: ...
def __ge__(self, other: Counter[Any]) -> bool: ...
def __gt__(self, other: Counter[Any]) -> bool: ...
# The pure-Python implementations of the "views" classes
# These are exposed at runtime in `collections/__init__.py`
class _OrderedDictKeysView(KeysView[_KT_co], Reversible[_KT_co]):
def __reversed__(self) -> Iterator[_KT_co]: ...
class _OrderedDictItemsView(ItemsView[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]):
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
class _OrderedDictValuesView(ValuesView[_VT_co], Reversible[_VT_co]):
def __reversed__(self) -> Iterator[_VT_co]: ...
# The C implementations of the "views" classes
# (At runtime, these are called `odict_keys`, `odict_items` and `odict_values`,
# but they are not exposed anywhere)
@final
class _odict_keys(dict_keys[_KT_co, _VT_co], Reversible[_KT_co]): # type: ignore[misc]
def __reversed__(self) -> Iterator[_KT_co]: ...
@final
class _odict_items(dict_items[_KT_co, _VT_co], Reversible[tuple[_KT_co, _VT_co]]): # type: ignore[misc]
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
@final
class _odict_values(dict_values[_KT_co, _VT_co], Reversible[_VT_co], Generic[_KT_co, _VT_co]): # type: ignore[misc]
def __reversed__(self) -> Iterator[_VT_co]: ...
class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def popitem(self, last: bool = ...) -> tuple[_KT, _VT]: ...
def move_to_end(self, key: _KT, last: bool = ...) -> None: ...
def copy(self: Self) -> Self: ...
def __reversed__(self) -> Iterator[_KT]: ...
def keys(self) -> _odict_keys[_KT, _VT]: ...
def items(self) -> _odict_items[_KT, _VT]: ...
def values(self) -> _odict_values[_KT, _VT]: ...
# The signature of OrderedDict.fromkeys should be kept in line with `dict.fromkeys`, modulo positional-only differences.
# Like dict.fromkeys, its true signature is not expressible in the current type system.
# See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963.
@classmethod
@overload
def fromkeys(cls, iterable: Iterable[_T], value: None = ...) -> OrderedDict[_T, Any | None]: ...
@classmethod
@overload
def fromkeys(cls, iterable: Iterable[_T], value: _S) -> OrderedDict[_T, _S]: ...
# Keep OrderedDict.setdefault in line with MutableMapping.setdefault, modulo positional-only differences.
@overload
def setdefault(self: OrderedDict[_KT, _T | None], key: _KT) -> _T | None: ...
@overload
def setdefault(self, key: _KT, default: _VT) -> _VT: ...
class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
default_factory: Callable[[], _VT] | None
@overload
def __init__(self) -> None: ...
@overload
def __init__(self: defaultdict[str, _VT], **kwargs: _VT) -> None: ...
@overload
def __init__(self, __default_factory: Callable[[], _VT] | None) -> None: ...
@overload
def __init__(self: defaultdict[str, _VT], __default_factory: Callable[[], _VT] | None, **kwargs: _VT) -> None: ...
@overload
def __init__(self, __default_factory: Callable[[], _VT] | None, __map: SupportsKeysAndGetItem[_KT, _VT]) -> None: ...
@overload
def __init__(
self: defaultdict[str, _VT],
__default_factory: Callable[[], _VT] | None,
__map: SupportsKeysAndGetItem[str, _VT],
**kwargs: _VT,
) -> None: ...
@overload
def __init__(self, __default_factory: Callable[[], _VT] | None, __iterable: Iterable[tuple[_KT, _VT]]) -> None: ...
@overload
def __init__(
self: defaultdict[str, _VT],
__default_factory: Callable[[], _VT] | None,
__iterable: Iterable[tuple[str, _VT]],
**kwargs: _VT,
) -> None: ...
def __missing__(self, __key: _KT) -> _VT: ...
def __copy__(self: Self) -> Self: ...
def copy(self: Self) -> Self: ...
class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
maps: list[MutableMapping[_KT, _VT]]
def __init__(self, *maps: MutableMapping[_KT, _VT]) -> None: ...
def new_child(self: Self, m: MutableMapping[_KT, _VT] | None = ...) -> Self: ...
@property
def parents(self: Self) -> Self: ...
def __setitem__(self, key: _KT, value: _VT) -> None: ...
def __delitem__(self, key: _KT) -> None: ...
def __getitem__(self, key: _KT) -> _VT: ...
def __iter__(self) -> Iterator[_KT]: ...
def __len__(self) -> int: ...
def __contains__(self, key: object) -> bool: ...
def __missing__(self, key: _KT) -> _VT: ... # undocumented
def __bool__(self) -> bool: ...
def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ...
@overload
def pop(self, key: _KT) -> _VT: ...
@overload
def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
def copy(self: Self) -> Self: ...
__copy__ = copy
# All arguments to `fromkeys` are passed to `dict.fromkeys` at runtime, so the signature should be kept in line with `dict.fromkeys`.
@classmethod
@overload
def fromkeys(cls, iterable: Iterable[_T], __value: None = ...) -> ChainMap[_T, Any | None]: ...
@classmethod
@overload
def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> ChainMap[_T, _S]: ...
if sys.version_info >= (3, 9):
def __or__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ...
def __ror__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ...
# ChainMap.__ior__ should be kept roughly in line with MutableMapping.update()
@overload # type: ignore[misc]
def __ior__(self: Self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ...
@overload
def __ior__(self: Self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...

View File

@@ -0,0 +1,2 @@
from _collections_abc import *
from _collections_abc import __all__ as __all__

View File

@@ -0,0 +1,207 @@
import abc
import sys
from _typeshed import FileDescriptorOrPath, Unused
from abc import abstractmethod
from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Generator, Iterator
from types import TracebackType
from typing import IO, Any, Generic, Protocol, TypeVar, overload, runtime_checkable
from typing_extensions import ParamSpec, Self, TypeAlias
__all__ = [
"contextmanager",
"closing",
"AbstractContextManager",
"ContextDecorator",
"ExitStack",
"redirect_stdout",
"redirect_stderr",
"suppress",
"AbstractAsyncContextManager",
"AsyncExitStack",
"asynccontextmanager",
"nullcontext",
]
if sys.version_info >= (3, 10):
__all__ += ["aclosing"]
if sys.version_info >= (3, 11):
__all__ += ["chdir"]
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T_io = TypeVar("_T_io", bound=IO[str] | None)
_F = TypeVar("_F", bound=Callable[..., Any])
_P = ParamSpec("_P")
_ExitFunc: TypeAlias = Callable[[type[BaseException] | None, BaseException | None, TracebackType | None], bool | None]
_CM_EF = TypeVar("_CM_EF", bound=AbstractContextManager[Any] | _ExitFunc)
@runtime_checkable
class AbstractContextManager(Protocol[_T_co]):
def __enter__(self) -> _T_co: ...
@abstractmethod
def __exit__(
self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
) -> bool | None: ...
@runtime_checkable
class AbstractAsyncContextManager(Protocol[_T_co]):
async def __aenter__(self) -> _T_co: ...
@abstractmethod
async def __aexit__(
self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
) -> bool | None: ...
class ContextDecorator:
def __call__(self, func: _F) -> _F: ...
class _GeneratorContextManager(AbstractContextManager[_T_co], ContextDecorator, Generic[_T_co]):
# __init__ and all instance attributes are actually inherited from _GeneratorContextManagerBase
# _GeneratorContextManagerBase is more trouble than it's worth to include in the stub; see #6676
def __init__(self, func: Callable[..., Iterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
gen: Generator[_T_co, Any, Any]
func: Callable[..., Generator[_T_co, Any, Any]]
args: tuple[Any, ...]
kwds: dict[str, Any]
if sys.version_info >= (3, 9):
def __exit__(
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
else:
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ...
if sys.version_info >= (3, 10):
_AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]])
class AsyncContextDecorator:
def __call__(self, func: _AF) -> _AF: ...
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], AsyncContextDecorator, Generic[_T_co]):
# __init__ and these attributes are actually defined in the base class _GeneratorContextManagerBase,
# which is more trouble than it's worth to include in the stub (see #6676)
def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
gen: AsyncGenerator[_T_co, Any]
func: Callable[..., AsyncGenerator[_T_co, Any]]
args: tuple[Any, ...]
kwds: dict[str, Any]
async def __aexit__(
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
else:
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]):
def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
gen: AsyncGenerator[_T_co, Any]
func: Callable[..., AsyncGenerator[_T_co, Any]]
args: tuple[Any, ...]
kwds: dict[str, Any]
async def __aexit__(
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ...
class _SupportsClose(Protocol):
def close(self) -> object: ...
_SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose)
class closing(AbstractContextManager[_SupportsCloseT]):
def __init__(self, thing: _SupportsCloseT) -> None: ...
def __exit__(self, *exc_info: Unused) -> None: ...
if sys.version_info >= (3, 10):
class _SupportsAclose(Protocol):
def aclose(self) -> Awaitable[object]: ...
_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose)
class aclosing(AbstractAsyncContextManager[_SupportsAcloseT]):
def __init__(self, thing: _SupportsAcloseT) -> None: ...
async def __aexit__(self, *exc_info: Unused) -> None: ...
class suppress(AbstractContextManager[None]):
def __init__(self, *exceptions: type[BaseException]) -> None: ...
def __exit__(
self, exctype: type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None
) -> bool: ...
class _RedirectStream(AbstractContextManager[_T_io]):
def __init__(self, new_target: _T_io) -> None: ...
def __exit__(
self, exctype: type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None
) -> None: ...
class redirect_stdout(_RedirectStream[_T_io]): ...
class redirect_stderr(_RedirectStream[_T_io]): ...
# In reality this is a subclass of `AbstractContextManager`;
# see #7961 for why we don't do that in the stub
class ExitStack(metaclass=abc.ABCMeta):
def enter_context(self, cm: AbstractContextManager[_T]) -> _T: ...
def push(self, exit: _CM_EF) -> _CM_EF: ...
def callback(self, __callback: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ...
def pop_all(self) -> Self: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
) -> bool: ...
_ExitCoroFunc: TypeAlias = Callable[
[type[BaseException] | None, BaseException | None, TracebackType | None], Awaitable[bool | None]
]
_ACM_EF = TypeVar("_ACM_EF", bound=AbstractAsyncContextManager[Any] | _ExitCoroFunc)
# In reality this is a subclass of `AbstractAsyncContextManager`;
# see #7961 for why we don't do that in the stub
class AsyncExitStack(metaclass=abc.ABCMeta):
def enter_context(self, cm: AbstractContextManager[_T]) -> _T: ...
async def enter_async_context(self, cm: AbstractAsyncContextManager[_T]) -> _T: ...
def push(self, exit: _CM_EF) -> _CM_EF: ...
def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ...
def callback(self, __callback: Callable[_P, _T], *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ...
def push_async_callback(
self, __callback: Callable[_P, Awaitable[_T]], *args: _P.args, **kwds: _P.kwargs
) -> Callable[_P, Awaitable[_T]]: ...
def pop_all(self) -> Self: ...
async def aclose(self) -> None: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(
self, __exc_type: type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None
) -> bool: ...
if sys.version_info >= (3, 10):
class nullcontext(AbstractContextManager[_T], AbstractAsyncContextManager[_T]):
enter_result: _T
@overload
def __init__(self: nullcontext[None], enter_result: None = None) -> None: ...
@overload
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
def __enter__(self) -> _T: ...
def __exit__(self, *exctype: Unused) -> None: ...
async def __aenter__(self) -> _T: ...
async def __aexit__(self, *exctype: Unused) -> None: ...
else:
class nullcontext(AbstractContextManager[_T]):
enter_result: _T
@overload
def __init__(self: nullcontext[None], enter_result: None = None) -> None: ...
@overload
def __init__(self: nullcontext[_T], enter_result: _T) -> None: ...
def __enter__(self) -> _T: ...
def __exit__(self, *exctype: Unused) -> None: ...
if sys.version_info >= (3, 11):
_T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=FileDescriptorOrPath)
class chdir(AbstractContextManager[None], Generic[_T_fd_or_any_path]):
path: _T_fd_or_any_path
def __init__(self, path: _T_fd_or_any_path) -> None: ...
def __enter__(self) -> None: ...
def __exit__(self, *excinfo: Unused) -> None: ...

View File

@@ -0,0 +1,70 @@
import sys
from collections.abc import Callable, Iterator, Mapping
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing_extensions import ParamSpec, final
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ("Context", "ContextVar", "Token", "copy_context")
_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: ...
if sys.version_info >= (3, 8):
@overload
def get(self, default: _T) -> _T: ...
@overload
def get(self, default: _D) -> _D | _T: ...
else:
@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: ... # type: ignore[misc] # overlapping overloads
@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: ...

View File

@@ -0,0 +1,322 @@
import enum
import sys
import types
from _typeshed import DataclassInstance
from builtins import type as Type # alias to avoid name clashes with fields named "type"
from collections.abc import Callable, Iterable, Mapping
from typing import Any, Generic, Protocol, TypeVar, overload
from typing_extensions import Literal, TypeAlias, TypeGuard
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
__all__ = [
"dataclass",
"field",
"Field",
"FrozenInstanceError",
"InitVar",
"MISSING",
"fields",
"asdict",
"astuple",
"make_dataclass",
"replace",
"is_dataclass",
]
if sys.version_info >= (3, 10):
__all__ += ["KW_ONLY"]
_DataclassT = TypeVar("_DataclassT", bound=DataclassInstance)
# define _MISSING_TYPE as an enum within the type stubs,
# even though that is not really its type at runtime
# this allows us to use Literal[_MISSING_TYPE.MISSING]
# for background, see:
# https://github.com/python/typeshed/pull/5900#issuecomment-895513797
class _MISSING_TYPE(enum.Enum):
MISSING = enum.auto()
MISSING = _MISSING_TYPE.MISSING
if sys.version_info >= (3, 10):
class KW_ONLY: ...
@overload
def asdict(obj: DataclassInstance) -> dict[str, Any]: ...
@overload
def asdict(obj: DataclassInstance, *, dict_factory: Callable[[list[tuple[str, Any]]], _T]) -> _T: ...
@overload
def astuple(obj: DataclassInstance) -> tuple[Any, ...]: ...
@overload
def astuple(obj: DataclassInstance, *, tuple_factory: Callable[[list[Any]], _T]) -> _T: ...
if sys.version_info >= (3, 8):
# cls argument is now positional-only
@overload
def dataclass(__cls: None) -> Callable[[type[_T]], type[_T]]: ...
@overload
def dataclass(__cls: type[_T]) -> type[_T]: ...
else:
@overload
def dataclass(_cls: None) -> Callable[[type[_T]], type[_T]]: ...
@overload
def dataclass(_cls: type[_T]) -> type[_T]: ...
if sys.version_info >= (3, 11):
@overload
def dataclass(
*,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
match_args: bool = True,
kw_only: bool = False,
slots: bool = False,
weakref_slot: bool = False,
) -> Callable[[type[_T]], type[_T]]: ...
elif sys.version_info >= (3, 10):
@overload
def dataclass(
*,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
match_args: bool = True,
kw_only: bool = False,
slots: bool = False,
) -> Callable[[type[_T]], type[_T]]: ...
else:
@overload
def dataclass(
*,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
) -> Callable[[type[_T]], type[_T]]: ...
# See https://github.com/python/mypy/issues/10750
class _DefaultFactory(Protocol[_T_co]):
def __call__(self) -> _T_co: ...
class Field(Generic[_T]):
name: str
type: Type[_T]
default: _T | Literal[_MISSING_TYPE.MISSING]
default_factory: _DefaultFactory[_T] | Literal[_MISSING_TYPE.MISSING]
repr: bool
hash: bool | None
init: bool
compare: bool
metadata: types.MappingProxyType[Any, Any]
if sys.version_info >= (3, 10):
kw_only: bool | Literal[_MISSING_TYPE.MISSING]
def __init__(
self,
default: _T,
default_factory: Callable[[], _T],
init: bool,
repr: bool,
hash: bool | None,
compare: bool,
metadata: Mapping[Any, Any],
kw_only: bool,
) -> None: ...
else:
def __init__(
self,
default: _T,
default_factory: Callable[[], _T],
init: bool,
repr: bool,
hash: bool | None,
compare: bool,
metadata: Mapping[Any, Any],
) -> None: ...
def __set_name__(self, owner: Type[Any], name: str) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
# NOTE: Actual return type is 'Field[_T]', but we want to help type checkers
# to understand the magic that happens at runtime.
if sys.version_info >= (3, 10):
@overload # `default` and `default_factory` are optional and mutually exclusive.
def field(
*,
default: _T,
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
kw_only: bool = ...,
) -> _T: ...
@overload
def field(
*,
default_factory: Callable[[], _T],
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
kw_only: bool = ...,
) -> _T: ...
@overload
def field(
*,
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
kw_only: bool = ...,
) -> Any: ...
else:
@overload # `default` and `default_factory` are optional and mutually exclusive.
def field(
*,
default: _T,
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
) -> _T: ...
@overload
def field(
*,
default_factory: Callable[[], _T],
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
) -> _T: ...
@overload
def field(
*,
init: bool = True,
repr: bool = True,
hash: bool | None = None,
compare: bool = True,
metadata: Mapping[Any, Any] | None = None,
) -> Any: ...
def fields(class_or_instance: DataclassInstance | type[DataclassInstance]) -> tuple[Field[Any], ...]: ...
@overload
def is_dataclass(obj: DataclassInstance) -> Literal[True]: ...
@overload
def is_dataclass(obj: type) -> TypeGuard[type[DataclassInstance]]: ...
@overload
def is_dataclass(obj: object) -> TypeGuard[DataclassInstance | type[DataclassInstance]]: ...
class FrozenInstanceError(AttributeError): ...
if sys.version_info >= (3, 9):
_InitVarMeta: TypeAlias = type
else:
class _InitVarMeta(type):
# Not used, instead `InitVar.__class_getitem__` is called.
def __getitem__(self, params: Any) -> InitVar[Any]: ...
class InitVar(Generic[_T], metaclass=_InitVarMeta):
type: Type[_T]
def __init__(self, type: Type[_T]) -> None: ...
if sys.version_info >= (3, 9):
@overload
def __class_getitem__(cls, type: Type[_T]) -> InitVar[_T]: ...
@overload
def __class_getitem__(cls, type: Any) -> InitVar[Any]: ...
if sys.version_info >= (3, 12):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
match_args: bool = True,
kw_only: bool = False,
slots: bool = False,
weakref_slot: bool = False,
module: str | None = None,
) -> type: ...
elif sys.version_info >= (3, 11):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
match_args: bool = True,
kw_only: bool = False,
slots: bool = False,
weakref_slot: bool = False,
) -> type: ...
elif sys.version_info >= (3, 10):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
match_args: bool = True,
kw_only: bool = False,
slots: bool = False,
) -> type: ...
else:
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
*,
bases: tuple[type, ...] = (),
namespace: dict[str, Any] | None = None,
init: bool = True,
repr: bool = True,
eq: bool = True,
order: bool = False,
unsafe_hash: bool = False,
frozen: bool = False,
) -> type: ...
def replace(__obj: _DataclassT, **changes: Any) -> _DataclassT: ...

View File

@@ -0,0 +1,2 @@
from _decimal import *
from _decimal import __libmpdec_version__ as __libmpdec_version__, __version__ as __version__

299
.vscode/Pico-W-Stub/stdlib/enum.pyi vendored Normal file
View File

@@ -0,0 +1,299 @@
import _typeshed
import sys
import types
from _typeshed import SupportsKeysAndGetItem, Unused
from builtins import property as _builtins_property
from collections.abc import Callable, Iterable, Iterator, Mapping
from typing import Any, Generic, TypeVar, overload
from typing_extensions import Literal, Self, TypeAlias
__all__ = ["EnumMeta", "Enum", "IntEnum", "Flag", "IntFlag", "auto", "unique"]
if sys.version_info >= (3, 11):
__all__ += [
"CONFORM",
"CONTINUOUS",
"EJECT",
"EnumCheck",
"EnumType",
"FlagBoundary",
"KEEP",
"NAMED_FLAGS",
"ReprEnum",
"STRICT",
"StrEnum",
"UNIQUE",
"global_enum",
"global_enum_repr",
"global_flag_repr",
"global_str",
"member",
"nonmember",
"property",
"verify",
]
if sys.version_info >= (3, 12):
__all__ += ["pickle_by_enum_name", "pickle_by_global_name"]
_EnumMemberT = TypeVar("_EnumMemberT")
_EnumerationT = TypeVar("_EnumerationT", bound=type[Enum])
# The following all work:
# >>> from enum import Enum
# >>> from string import ascii_lowercase
# >>> Enum('Foo', names='RED YELLOW GREEN')
# <enum 'Foo'>
# >>> Enum('Foo', names=[('RED', 1), ('YELLOW, 2)])
# <enum 'Foo'>
# >>> Enum('Foo', names=((x for x in (ascii_lowercase[i], i)) for i in range(5)))
# <enum 'Foo'>
# >>> Enum('Foo', names={'RED': 1, 'YELLOW': 2})
# <enum 'Foo'>
_EnumNames: TypeAlias = str | Iterable[str] | Iterable[Iterable[str | Any]] | Mapping[str, Any]
if sys.version_info >= (3, 11):
class nonmember(Generic[_EnumMemberT]):
value: _EnumMemberT
def __init__(self, value: _EnumMemberT) -> None: ...
class member(Generic[_EnumMemberT]):
value: _EnumMemberT
def __init__(self, value: _EnumMemberT) -> None: ...
class _EnumDict(dict[str, Any]):
def __init__(self) -> None: ...
def __setitem__(self, key: str, value: Any) -> None: ...
if sys.version_info >= (3, 11):
# See comment above `typing.MutableMapping.update`
# for why overloads are preferable to a Union here
#
# Unlike with MutableMapping.update(), the first argument is required,
# hence the type: ignore
@overload # type: ignore[override]
def update(self, members: SupportsKeysAndGetItem[str, Any], **more_members: Any) -> None: ...
@overload
def update(self, members: Iterable[tuple[str, Any]], **more_members: Any) -> None: ...
# Structurally: Iterable[T], Reversible[T], Container[T] where T is the enum itself
class EnumMeta(type):
if sys.version_info >= (3, 11):
def __new__(
metacls: type[_typeshed.Self],
cls: str,
bases: tuple[type, ...],
classdict: _EnumDict,
*,
boundary: FlagBoundary | None = None,
_simple: bool = False,
**kwds: Any,
) -> _typeshed.Self: ...
elif sys.version_info >= (3, 9):
def __new__(
metacls: type[_typeshed.Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any
) -> _typeshed.Self: ...
else:
def __new__(metacls: type[_typeshed.Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> _typeshed.Self: ...
if sys.version_info >= (3, 9):
@classmethod
def __prepare__(metacls, cls: str, bases: tuple[type, ...], **kwds: Any) -> _EnumDict: ... # type: ignore[override]
else:
@classmethod
def __prepare__(metacls, cls: str, bases: tuple[type, ...]) -> _EnumDict: ... # type: ignore[override]
def __iter__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ...
def __reversed__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ...
if sys.version_info >= (3, 12):
def __contains__(self: type[Any], value: object) -> bool: ...
elif sys.version_info >= (3, 11):
def __contains__(self: type[Any], member: object) -> bool: ...
elif sys.version_info >= (3, 10):
def __contains__(self: type[Any], obj: object) -> bool: ...
else:
def __contains__(self: type[Any], member: object) -> bool: ...
def __getitem__(self: type[_EnumMemberT], name: str) -> _EnumMemberT: ...
@_builtins_property
def __members__(self: type[_EnumMemberT]) -> types.MappingProxyType[str, _EnumMemberT]: ...
def __len__(self) -> int: ...
def __bool__(self) -> Literal[True]: ...
def __dir__(self) -> list[str]: ...
# Simple value lookup
@overload
def __call__(cls: type[_EnumMemberT], value: Any, names: None = None) -> _EnumMemberT: ...
# Functional Enum API
if sys.version_info >= (3, 11):
@overload
def __call__(
cls,
value: str,
names: _EnumNames,
*,
module: str | None = None,
qualname: str | None = None,
type: type | None = None,
start: int = 1,
boundary: FlagBoundary | None = None,
) -> type[Enum]: ...
else:
@overload
def __call__(
cls,
value: str,
names: _EnumNames,
*,
module: str | None = None,
qualname: str | None = None,
type: type | None = None,
start: int = 1,
) -> type[Enum]: ...
_member_names_: list[str] # undocumented
_member_map_: dict[str, Enum] # undocumented
_value2member_map_: dict[Any, Enum] # undocumented
if sys.version_info >= (3, 11):
# In 3.11 `EnumMeta` metaclass is renamed to `EnumType`, but old name also exists.
EnumType = EnumMeta
class property(types.DynamicClassAttribute):
def __set_name__(self, ownerclass: type[Enum], name: str) -> None: ...
name: str
clsname: str
_magic_enum_attr = property
else:
_magic_enum_attr = types.DynamicClassAttribute
class Enum(metaclass=EnumMeta):
@_magic_enum_attr
def name(self) -> str: ...
@_magic_enum_attr
def value(self) -> Any: ...
_name_: str
_value_: Any
_ignore_: str | list[str]
_order_: str
__order__: str
@classmethod
def _missing_(cls, value: object) -> Any: ...
@staticmethod
def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any: ...
# It's not true that `__new__` will accept any argument type,
# so ideally we'd use `Any` to indicate that the argument type is inexpressible.
# However, using `Any` causes too many false-positives for those using mypy's `--disallow-any-expr`
# (see #7752, #2539, mypy/#5788),
# and in practice using `object` here has the same effect as using `Any`.
def __new__(cls, value: object) -> Self: ...
def __dir__(self) -> list[str]: ...
def __hash__(self) -> int: ...
def __format__(self, format_spec: str) -> str: ...
def __reduce_ex__(self, proto: Unused) -> tuple[Any, ...]: ...
if sys.version_info >= (3, 12):
def __copy__(self) -> Self: ...
def __deepcopy__(self, memo: Any) -> Self: ...
if sys.version_info >= (3, 11):
class ReprEnum(Enum): ...
if sys.version_info >= (3, 11):
_IntEnumBase = ReprEnum
else:
_IntEnumBase = Enum
class IntEnum(int, _IntEnumBase):
_value_: int
@_magic_enum_attr
def value(self) -> int: ...
def __new__(cls, value: int) -> Self: ...
def unique(enumeration: _EnumerationT) -> _EnumerationT: ...
_auto_null: Any
class Flag(Enum):
_name_: str | None # type: ignore[assignment]
_value_: int
@_magic_enum_attr
def name(self) -> str | None: ... # type: ignore[override]
@_magic_enum_attr
def value(self) -> int: ...
def __contains__(self, other: Self) -> bool: ...
def __bool__(self) -> bool: ...
def __or__(self, other: Self) -> Self: ...
def __and__(self, other: Self) -> Self: ...
def __xor__(self, other: Self) -> Self: ...
def __invert__(self) -> Self: ...
if sys.version_info >= (3, 11):
def __iter__(self) -> Iterator[Self]: ...
def __len__(self) -> int: ...
__ror__ = __or__
__rand__ = __and__
__rxor__ = __xor__
if sys.version_info >= (3, 11):
class StrEnum(str, ReprEnum):
def __new__(cls, value: str) -> Self: ...
_value_: str
@_magic_enum_attr
def value(self) -> str: ...
@staticmethod
def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str: ...
class EnumCheck(StrEnum):
CONTINUOUS: str
NAMED_FLAGS: str
UNIQUE: str
CONTINUOUS = EnumCheck.CONTINUOUS
NAMED_FLAGS = EnumCheck.NAMED_FLAGS
UNIQUE = EnumCheck.UNIQUE
class verify:
def __init__(self, *checks: EnumCheck) -> None: ...
def __call__(self, enumeration: _EnumerationT) -> _EnumerationT: ...
class FlagBoundary(StrEnum):
STRICT: str
CONFORM: str
EJECT: str
KEEP: str
STRICT = FlagBoundary.STRICT
CONFORM = FlagBoundary.CONFORM
EJECT = FlagBoundary.EJECT
KEEP = FlagBoundary.KEEP
def global_str(self: Enum) -> str: ...
def global_enum(cls: _EnumerationT, update_str: bool = False) -> _EnumerationT: ...
def global_enum_repr(self: Enum) -> str: ...
def global_flag_repr(self: Flag) -> str: ...
if sys.version_info >= (3, 11):
# The body of the class is the same, but the base classes are different.
class IntFlag(int, ReprEnum, Flag, boundary=KEEP): # type: ignore[misc] # complaints about incompatible bases
def __new__(cls, value: int) -> Self: ...
def __or__(self, other: int) -> Self: ...
def __and__(self, other: int) -> Self: ...
def __xor__(self, other: int) -> Self: ...
__ror__ = __or__
__rand__ = __and__
__rxor__ = __xor__
else:
class IntFlag(int, Flag): # type: ignore[misc] # complaints about incompatible bases
def __new__(cls, value: int) -> Self: ...
def __or__(self, other: int) -> Self: ...
def __and__(self, other: int) -> Self: ...
def __xor__(self, other: int) -> Self: ...
__ror__ = __or__
__rand__ = __and__
__rxor__ = __xor__
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
class auto(IntFlag):
_value_: Any
@_magic_enum_attr
def value(self) -> Any: ...
def __new__(cls) -> Self: ...
if sys.version_info >= (3, 12):
def pickle_by_global_name(self: Enum, proto: int) -> str: ...
def pickle_by_enum_name(self: _EnumMemberT, proto: int) -> tuple[Callable[..., Any], tuple[type[_EnumMemberT], str]]: ...

162
.vscode/Pico-W-Stub/stdlib/fractions.pyi vendored Normal file
View File

@@ -0,0 +1,162 @@
import sys
from collections.abc import Callable
from decimal import Decimal
from numbers import Integral, Rational, Real
from typing import Any, overload
from typing_extensions import Literal, Self, SupportsIndex, TypeAlias
_ComparableNum: TypeAlias = int | float | Decimal | Real
if sys.version_info >= (3, 9):
__all__ = ["Fraction"]
else:
__all__ = ["Fraction", "gcd"]
@overload
def gcd(a: int, b: int) -> int: ...
@overload
def gcd(a: Integral, b: int) -> Integral: ...
@overload
def gcd(a: int, b: Integral) -> Integral: ...
@overload
def gcd(a: Integral, b: Integral) -> Integral: ...
class Fraction(Rational):
@overload
def __new__(cls, numerator: int | Rational = 0, denominator: int | Rational | None = None) -> Self: ...
@overload
def __new__(cls, __value: float | Decimal | str) -> Self: ...
@classmethod
def from_float(cls, f: float) -> Self: ...
@classmethod
def from_decimal(cls, dec: Decimal) -> Self: ...
def limit_denominator(self, max_denominator: int = 1000000) -> Fraction: ...
if sys.version_info >= (3, 8):
def as_integer_ratio(self) -> tuple[int, int]: ...
if sys.version_info >= (3, 12):
def is_integer(self) -> bool: ...
@property
def numerator(a) -> int: ...
@property
def denominator(a) -> int: ...
@overload
def __add__(a, b: int | Fraction) -> Fraction: ...
@overload
def __add__(a, b: float) -> float: ...
@overload
def __add__(a, b: complex) -> complex: ...
@overload
def __radd__(b, a: int | Fraction) -> Fraction: ...
@overload
def __radd__(b, a: float) -> float: ...
@overload
def __radd__(b, a: complex) -> complex: ...
@overload
def __sub__(a, b: int | Fraction) -> Fraction: ...
@overload
def __sub__(a, b: float) -> float: ...
@overload
def __sub__(a, b: complex) -> complex: ...
@overload
def __rsub__(b, a: int | Fraction) -> Fraction: ...
@overload
def __rsub__(b, a: float) -> float: ...
@overload
def __rsub__(b, a: complex) -> complex: ...
@overload
def __mul__(a, b: int | Fraction) -> Fraction: ...
@overload
def __mul__(a, b: float) -> float: ...
@overload
def __mul__(a, b: complex) -> complex: ...
@overload
def __rmul__(b, a: int | Fraction) -> Fraction: ...
@overload
def __rmul__(b, a: float) -> float: ...
@overload
def __rmul__(b, a: complex) -> complex: ...
@overload
def __truediv__(a, b: int | Fraction) -> Fraction: ...
@overload
def __truediv__(a, b: float) -> float: ...
@overload
def __truediv__(a, b: complex) -> complex: ...
@overload
def __rtruediv__(b, a: int | Fraction) -> Fraction: ...
@overload
def __rtruediv__(b, a: float) -> float: ...
@overload
def __rtruediv__(b, a: complex) -> complex: ...
@overload
def __floordiv__(a, b: int | Fraction) -> int: ...
@overload
def __floordiv__(a, b: float) -> float: ...
@overload
def __rfloordiv__(b, a: int | Fraction) -> int: ...
@overload
def __rfloordiv__(b, a: float) -> float: ...
@overload
def __mod__(a, b: int | Fraction) -> Fraction: ...
@overload
def __mod__(a, b: float) -> float: ...
@overload
def __rmod__(b, a: int | Fraction) -> Fraction: ...
@overload
def __rmod__(b, a: float) -> float: ...
if sys.version_info >= (3, 8):
@overload
def __divmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __divmod__(a, b: float) -> tuple[float, Fraction]: ...
@overload
def __rdivmod__(a, b: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __rdivmod__(a, b: float) -> tuple[float, Fraction]: ...
else:
@overload
def __divmod__(self, other: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __divmod__(self, other: float) -> tuple[float, Fraction]: ...
@overload
def __rdivmod__(self, other: int | Fraction) -> tuple[int, Fraction]: ...
@overload
def __rdivmod__(self, other: float) -> tuple[float, Fraction]: ...
@overload
def __pow__(a, b: int) -> Fraction: ...
@overload
def __pow__(a, b: float | Fraction) -> float: ...
@overload
def __pow__(a, b: complex) -> complex: ...
@overload
def __rpow__(b, a: float | Fraction) -> float: ...
@overload
def __rpow__(b, a: complex) -> complex: ...
def __pos__(a) -> Fraction: ...
def __neg__(a) -> Fraction: ...
def __abs__(a) -> Fraction: ...
def __trunc__(a) -> int: ...
def __floor__(a) -> int: ...
def __ceil__(a) -> int: ...
@overload
def __round__(self, ndigits: None = None) -> int: ...
@overload
def __round__(self, ndigits: int) -> Fraction: ...
def __hash__(self) -> int: ...
def __eq__(a, b: object) -> bool: ...
def __lt__(a, b: _ComparableNum) -> bool: ...
def __gt__(a, b: _ComparableNum) -> bool: ...
def __le__(a, b: _ComparableNum) -> bool: ...
def __ge__(a, b: _ComparableNum) -> bool: ...
def __bool__(a) -> bool: ...
def __copy__(self) -> Self: ...
def __deepcopy__(self, memo: Any) -> Self: ...
if sys.version_info >= (3, 11):
def __int__(a, _index: Callable[[SupportsIndex], int] = ...) -> int: ...
# Not actually defined within fractions.py, but provides more useful
# overrides
@property
def real(self) -> Fraction: ...
@property
def imag(self) -> Literal[0]: ...
def conjugate(self) -> Fraction: ...

222
.vscode/Pico-W-Stub/stdlib/functools.pyi vendored Normal file
View File

@@ -0,0 +1,222 @@
import sys
import types
from _typeshed import SupportsAllComparisons, SupportsItems
from collections.abc import Callable, Hashable, Iterable, Sequence, Sized
from typing import Any, Generic, NamedTuple, TypeVar, overload
from typing_extensions import Literal, ParamSpec, Self, TypeAlias, TypedDict, final
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [
"update_wrapper",
"wraps",
"WRAPPER_ASSIGNMENTS",
"WRAPPER_UPDATES",
"total_ordering",
"cmp_to_key",
"lru_cache",
"reduce",
"partial",
"partialmethod",
"singledispatch",
]
if sys.version_info >= (3, 8):
__all__ += ["cached_property", "singledispatchmethod"]
if sys.version_info >= (3, 9):
__all__ += ["cache"]
_T = TypeVar("_T")
_S = TypeVar("_S")
_PWrapped = ParamSpec("_PWrapped")
_RWrapped = TypeVar("_RWrapped")
_PWrapper = ParamSpec("_PWrapper")
_RWapper = TypeVar("_RWapper")
@overload
def reduce(function: Callable[[_T, _S], _T], sequence: Iterable[_S], initial: _T) -> _T: ...
@overload
def reduce(function: Callable[[_T, _T], _T], sequence: Iterable[_T]) -> _T: ...
class _CacheInfo(NamedTuple):
hits: int
misses: int
maxsize: int | None
currsize: int
if sys.version_info >= (3, 9):
class _CacheParameters(TypedDict):
maxsize: int
typed: bool
@final
class _lru_cache_wrapper(Generic[_T]):
__wrapped__: Callable[..., _T]
def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ...
def cache_info(self) -> _CacheInfo: ...
def cache_clear(self) -> None: ...
if sys.version_info >= (3, 9):
def cache_parameters(self) -> _CacheParameters: ...
def __copy__(self) -> _lru_cache_wrapper[_T]: ...
def __deepcopy__(self, __memo: Any) -> _lru_cache_wrapper[_T]: ...
if sys.version_info >= (3, 8):
@overload
def lru_cache(maxsize: int | None = 128, typed: bool = False) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ...
@overload
def lru_cache(maxsize: Callable[..., _T], typed: bool = False) -> _lru_cache_wrapper[_T]: ...
else:
def lru_cache(maxsize: int | None = 128, typed: bool = False) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ...
if sys.version_info >= (3, 12):
WRAPPER_ASSIGNMENTS: tuple[
Literal["__module__"],
Literal["__name__"],
Literal["__qualname__"],
Literal["__doc__"],
Literal["__annotations__"],
Literal["__type_params__"],
]
else:
WRAPPER_ASSIGNMENTS: tuple[
Literal["__module__"], Literal["__name__"], Literal["__qualname__"], Literal["__doc__"], Literal["__annotations__"]
]
WRAPPER_UPDATES: tuple[Literal["__dict__"]]
class _Wrapped(Generic[_PWrapped, _RWrapped, _PWrapper, _RWapper]):
__wrapped__: Callable[_PWrapped, _RWrapped]
def __call__(self, *args: _PWrapper.args, **kwargs: _PWrapper.kwargs) -> _RWapper: ...
# as with ``Callable``, we'll assume that these attributes exist
__name__: str
__qualname__: str
class _Wrapper(Generic[_PWrapped, _RWrapped]):
def __call__(self, f: Callable[_PWrapper, _RWapper]) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWapper]: ...
if sys.version_info >= (3, 12):
def update_wrapper(
wrapper: Callable[_PWrapper, _RWapper],
wrapped: Callable[_PWrapped, _RWrapped],
assigned: Sequence[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotations__", "__type_params__"),
updated: Sequence[str] = ("__dict__",),
) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWapper]: ...
def wraps(
wrapped: Callable[_PWrapped, _RWrapped],
assigned: Sequence[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotations__", "__type_params__"),
updated: Sequence[str] = ("__dict__",),
) -> _Wrapper[_PWrapped, _RWrapped]: ...
else:
def update_wrapper(
wrapper: Callable[_PWrapper, _RWapper],
wrapped: Callable[_PWrapped, _RWrapped],
assigned: Sequence[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotations__"),
updated: Sequence[str] = ("__dict__",),
) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWapper]: ...
def wraps(
wrapped: Callable[_PWrapped, _RWrapped],
assigned: Sequence[str] = ("__module__", "__name__", "__qualname__", "__doc__", "__annotations__"),
updated: Sequence[str] = ("__dict__",),
) -> _Wrapper[_PWrapped, _RWrapped]: ...
def total_ordering(cls: type[_T]) -> type[_T]: ...
def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], SupportsAllComparisons]: ...
class partial(Generic[_T]):
@property
def func(self) -> Callable[..., _T]: ...
@property
def args(self) -> tuple[Any, ...]: ...
@property
def keywords(self) -> dict[str, Any]: ...
def __new__(cls, __func: Callable[..., _T], *args: Any, **kwargs: Any) -> Self: ...
def __call__(__self, *args: Any, **kwargs: Any) -> _T: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
# With protocols, this could change into a generic protocol that defines __get__ and returns _T
_Descriptor: TypeAlias = Any
class partialmethod(Generic[_T]):
func: Callable[..., _T] | _Descriptor
args: tuple[Any, ...]
keywords: dict[str, Any]
@overload
def __init__(self, __func: Callable[..., _T], *args: Any, **keywords: Any) -> None: ...
@overload
def __init__(self, __func: _Descriptor, *args: Any, **keywords: Any) -> None: ...
if sys.version_info >= (3, 8):
def __get__(self, obj: Any, cls: type[Any] | None = None) -> Callable[..., _T]: ...
else:
def __get__(self, obj: Any, cls: type[Any] | None) -> Callable[..., _T]: ...
@property
def __isabstractmethod__(self) -> bool: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
class _SingleDispatchCallable(Generic[_T]):
registry: types.MappingProxyType[Any, Callable[..., _T]]
def dispatch(self, cls: Any) -> Callable[..., _T]: ...
# @fun.register(complex)
# def _(arg, verbose=False): ...
@overload
def register(self, cls: type[Any], func: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
# @fun.register
# def _(arg: int, verbose=False):
@overload
def register(self, cls: Callable[..., _T], func: None = None) -> Callable[..., _T]: ...
# fun.register(int, lambda x: x)
@overload
def register(self, cls: type[Any], func: Callable[..., _T]) -> Callable[..., _T]: ...
def _clear_cache(self) -> None: ...
def __call__(__self, *args: Any, **kwargs: Any) -> _T: ...
def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ...
if sys.version_info >= (3, 8):
class singledispatchmethod(Generic[_T]):
dispatcher: _SingleDispatchCallable[_T]
func: Callable[..., _T]
def __init__(self, func: Callable[..., _T]) -> None: ...
@property
def __isabstractmethod__(self) -> bool: ...
@overload
def register(self, cls: type[Any], method: None = None) -> Callable[[Callable[..., _T]], Callable[..., _T]]: ...
@overload
def register(self, cls: Callable[..., _T], method: None = None) -> Callable[..., _T]: ...
@overload
def register(self, cls: type[Any], method: Callable[..., _T]) -> Callable[..., _T]: ...
def __get__(self, obj: _S, cls: type[_S] | None = None) -> Callable[..., _T]: ...
class cached_property(Generic[_T]):
func: Callable[[Any], _T]
attrname: str | None
def __init__(self, func: Callable[[Any], _T]) -> None: ...
@overload
def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ...
@overload
def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ...
def __set_name__(self, owner: type[Any], name: str) -> None: ...
# __set__ is not defined at runtime, but @cached_property is designed to be settable
def __set__(self, instance: object, value: _T) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
if sys.version_info >= (3, 9):
def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ...
def _make_key(
args: tuple[Hashable, ...],
kwds: SupportsItems[Any, Any],
typed: bool,
kwd_mark: tuple[object, ...] = ...,
fasttypes: set[type] = ...,
tuple: type = ...,
type: Any = ...,
len: Callable[[Sized], int] = ...,
) -> Hashable: ...

196
.vscode/Pico-W-Stub/stdlib/io.pyi vendored Normal file
View File

@@ -0,0 +1,196 @@
import abc
import builtins
import codecs
import sys
from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer
from collections.abc import Callable, Iterable, Iterator
from stdlib.os import _Opener
from types import TracebackType
from typing import IO, Any, BinaryIO, TextIO
from typing_extensions import Literal
__all__ = [
"BlockingIOError",
"open",
"IOBase",
"RawIOBase",
"FileIO",
"BytesIO",
"StringIO",
"BufferedIOBase",
"BufferedReader",
"BufferedWriter",
"BufferedRWPair",
"BufferedRandom",
"TextIOBase",
"TextIOWrapper",
"UnsupportedOperation",
"SEEK_SET",
"SEEK_CUR",
"SEEK_END",
]
if sys.version_info >= (3, 8):
__all__ += ["open_code"]
DEFAULT_BUFFER_SIZE: Literal[8192]
SEEK_SET: Literal[0]
SEEK_CUR: Literal[1]
SEEK_END: Literal[2]
open = builtins.open
if sys.version_info >= (3, 8):
def open_code(path: str) -> IO[bytes]: ...
BlockingIOError = builtins.BlockingIOError
class UnsupportedOperation(OSError, ValueError): ...
class IOBase(metaclass=abc.ABCMeta):
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self: Self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
read: Callable[..., Any]
def readlines(self, __hint: int = ...) -> list[bytes]: ...
def seek(self, __offset: int, __whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, __size: int | None = ...) -> int: ...
def writable(self) -> bool: ...
write: Callable[..., Any]
def writelines(self, __lines: Iterable[ReadableBuffer]) -> None: ...
def readline(self, __size: int | None = ...) -> bytes: ...
def __del__(self) -> None: ...
@property
def closed(self) -> bool: ...
def _checkClosed(self, msg: str | None = ...) -> None: ... # undocumented
class RawIOBase(IOBase):
def readall(self) -> bytes: ...
def readinto(self, __buffer: WriteableBuffer) -> int | None: ...
def write(self, __b: ReadableBuffer) -> int | None: ...
def read(self, __size: int = ...) -> bytes | None: ...
class BufferedIOBase(IOBase):
raw: RawIOBase # This is not part of the BufferedIOBase API and may not exist on some implementations.
def detach(self) -> RawIOBase: ...
def readinto(self, __buffer: WriteableBuffer) -> int: ...
def write(self, __buffer: ReadableBuffer) -> int: ...
def readinto1(self, __buffer: WriteableBuffer) -> int: ...
def read(self, __size: int | None = ...) -> bytes: ...
def read1(self, __size: int = ...) -> bytes: ...
class FileIO(RawIOBase, BinaryIO):
mode: str
name: StrOrBytesPath | int # type: ignore[assignment]
def __init__(
self, file: StrOrBytesPath | int, mode: str = ..., closefd: bool = ..., opener: _Opener | None = ...
) -> None: ...
@property
def closefd(self) -> bool: ...
def write(self, __b: ReadableBuffer) -> int: ...
def read(self, __size: int = ...) -> bytes: ...
def __enter__(self: Self) -> Self: ...
class BytesIO(BufferedIOBase, BinaryIO):
def __init__(self, initial_bytes: ReadableBuffer = ...) -> None: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def __enter__(self: Self) -> Self: ...
def getvalue(self) -> bytes: ...
def getbuffer(self) -> memoryview: ...
def read1(self, __size: int | None = ...) -> bytes: ...
class BufferedReader(BufferedIOBase, BinaryIO):
def __enter__(self: Self) -> Self: ...
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def peek(self, __size: int = ...) -> bytes: ...
class BufferedWriter(BufferedIOBase, BinaryIO):
def __enter__(self: Self) -> Self: ...
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def write(self, __buffer: ReadableBuffer) -> int: ...
class BufferedRandom(BufferedReader, BufferedWriter):
def __enter__(self: Self) -> Self: ...
def seek(self, __target: int, __whence: int = ...) -> int: ... # stubtest needs this
class BufferedRWPair(BufferedIOBase):
def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = ...) -> None: ...
def peek(self, __size: int = ...) -> bytes: ...
class TextIOBase(IOBase):
encoding: str
errors: str | None
newlines: str | tuple[str, ...] | None
def __iter__(self) -> Iterator[str]: ... # type: ignore[override]
def __next__(self) -> str: ... # type: ignore[override]
def detach(self) -> BinaryIO: ...
def write(self, __s: str) -> int: ...
def writelines(self, __lines: Iterable[str]) -> None: ... # type: ignore[override]
def readline(self, __size: int = ...) -> str: ... # type: ignore[override]
def readlines(self, __hint: int = ...) -> list[str]: ... # type: ignore[override]
def read(self, __size: int | None = ...) -> str: ...
class TextIOWrapper(TextIOBase, TextIO):
def __init__(
self,
buffer: IO[bytes],
encoding: str | None = ...,
errors: str | None = ...,
newline: str | None = ...,
line_buffering: bool = ...,
write_through: bool = ...,
) -> None: ...
@property
def buffer(self) -> BinaryIO: ...
@property
def closed(self) -> bool: ...
@property
def line_buffering(self) -> bool: ...
@property
def write_through(self) -> bool: ...
def reconfigure(
self,
*,
encoding: str | None = ...,
errors: str | None = ...,
newline: str | None = ...,
line_buffering: bool | None = ...,
write_through: bool | None = ...,
) -> None: ...
# These are inherited from TextIOBase, but must exist in the stub to satisfy mypy.
def __enter__(self: Self) -> Self: ...
def __iter__(self) -> Iterator[str]: ... # type: ignore[override]
def __next__(self) -> str: ... # type: ignore[override]
def writelines(self, __lines: Iterable[str]) -> None: ... # type: ignore[override]
def readline(self, __size: int = ...) -> str: ... # type: ignore[override]
def readlines(self, __hint: int = ...) -> list[str]: ... # type: ignore[override]
def seek(self, __cookie: int, __whence: int = ...) -> int: ... # stubtest needs this
class StringIO(TextIOWrapper):
def __init__(self, initial_value: str | None = ..., newline: str | None = ...) -> None: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> str: ...
class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ...
def decode(self, input: ReadableBuffer | str, final: bool = ...) -> str: ...
@property
def newlines(self) -> str | tuple[str, ...] | None: ...
def setstate(self, __state: tuple[bytes, int]) -> None: ...

129
.vscode/Pico-W-Stub/stdlib/numbers.pyi vendored Normal file
View File

@@ -0,0 +1,129 @@
# Note: these stubs are incomplete. The more complex type
# signatures are currently omitted.
from abc import ABCMeta, abstractmethod
from typing import Any, SupportsFloat, overload
__all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
class Number(metaclass=ABCMeta):
@abstractmethod
def __hash__(self) -> int: ...
class Complex(Number):
@abstractmethod
def __complex__(self) -> complex: ...
def __bool__(self) -> bool: ...
@property
@abstractmethod
def real(self) -> Any: ...
@property
@abstractmethod
def imag(self) -> Any: ...
@abstractmethod
def __add__(self, other: Any) -> Any: ...
@abstractmethod
def __radd__(self, other: Any) -> Any: ...
@abstractmethod
def __neg__(self) -> Any: ...
@abstractmethod
def __pos__(self) -> Any: ...
def __sub__(self, other: Any) -> Any: ...
def __rsub__(self, other: Any) -> Any: ...
@abstractmethod
def __mul__(self, other: Any) -> Any: ...
@abstractmethod
def __rmul__(self, other: Any) -> Any: ...
@abstractmethod
def __truediv__(self, other: Any) -> Any: ...
@abstractmethod
def __rtruediv__(self, other: Any) -> Any: ...
@abstractmethod
def __pow__(self, exponent: Any) -> Any: ...
@abstractmethod
def __rpow__(self, base: Any) -> Any: ...
@abstractmethod
def __abs__(self) -> Real: ...
@abstractmethod
def conjugate(self) -> Any: ...
@abstractmethod
def __eq__(self, other: object) -> bool: ...
class Real(Complex, SupportsFloat):
@abstractmethod
def __float__(self) -> float: ...
@abstractmethod
def __trunc__(self) -> int: ...
@abstractmethod
def __floor__(self) -> int: ...
@abstractmethod
def __ceil__(self) -> int: ...
@abstractmethod
@overload
def __round__(self, ndigits: None = None) -> int: ...
@abstractmethod
@overload
def __round__(self, ndigits: int) -> Any: ...
def __divmod__(self, other: Any) -> Any: ...
def __rdivmod__(self, other: Any) -> Any: ...
@abstractmethod
def __floordiv__(self, other: Any) -> int: ...
@abstractmethod
def __rfloordiv__(self, other: Any) -> int: ...
@abstractmethod
def __mod__(self, other: Any) -> Any: ...
@abstractmethod
def __rmod__(self, other: Any) -> Any: ...
@abstractmethod
def __lt__(self, other: Any) -> bool: ...
@abstractmethod
def __le__(self, other: Any) -> bool: ...
def __complex__(self) -> complex: ...
@property
def real(self) -> Any: ...
@property
def imag(self) -> Any: ...
def conjugate(self) -> Any: ...
class Rational(Real):
@property
@abstractmethod
def numerator(self) -> int: ...
@property
@abstractmethod
def denominator(self) -> int: ...
def __float__(self) -> float: ...
class Integral(Rational):
@abstractmethod
def __int__(self) -> int: ...
def __index__(self) -> int: ...
@abstractmethod
def __pow__(self, exponent: Any, modulus: Any | None = None) -> Any: ...
@abstractmethod
def __lshift__(self, other: Any) -> Any: ...
@abstractmethod
def __rlshift__(self, other: Any) -> Any: ...
@abstractmethod
def __rshift__(self, other: Any) -> Any: ...
@abstractmethod
def __rrshift__(self, other: Any) -> Any: ...
@abstractmethod
def __and__(self, other: Any) -> Any: ...
@abstractmethod
def __rand__(self, other: Any) -> Any: ...
@abstractmethod
def __xor__(self, other: Any) -> Any: ...
@abstractmethod
def __rxor__(self, other: Any) -> Any: ...
@abstractmethod
def __or__(self, other: Any) -> Any: ...
@abstractmethod
def __ror__(self, other: Any) -> Any: ...
@abstractmethod
def __invert__(self) -> Any: ...
def __float__(self) -> float: ...
@property
def numerator(self) -> int: ...
@property
def denominator(self) -> int: ...

1132
.vscode/Pico-W-Stub/stdlib/os/__init__.pyi vendored Normal file

File diff suppressed because it is too large Load Diff

58
.vscode/Pico-W-Stub/stdlib/queue.pyi vendored Normal file
View File

@@ -0,0 +1,58 @@
import sys
from threading import Condition, Lock # type: ignore
from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue", "SimpleQueue"]
_T = TypeVar("_T")
class Empty(Exception): ...
class Full(Exception): ...
class Queue(Generic[_T]):
maxsize: int
mutex: Lock # undocumented # type: ignore
not_empty: Condition # undocumented
not_full: Condition # undocumented
all_tasks_done: Condition # undocumented
unfinished_tasks: int # undocumented
# Despite the fact that `queue` has `deque` type,
# we treat it as `Any` to allow different implementations in subtypes.
queue: Any # undocumented
def __init__(self, maxsize: int = 0) -> None: ...
def _init(self, maxsize: int) -> None: ...
def empty(self) -> bool: ...
def full(self) -> bool: ...
def get(self, block: bool = True, timeout: float | None = None) -> _T: ...
def get_nowait(self) -> _T: ...
def _get(self) -> _T: ...
def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ...
def put_nowait(self, item: _T) -> None: ...
def _put(self, item: _T) -> None: ...
def join(self) -> None: ...
def qsize(self) -> int: ...
def _qsize(self) -> int: ...
def task_done(self) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
class PriorityQueue(Queue[_T]):
queue: list[_T]
class LifoQueue(Queue[_T]):
queue: list[_T]
class SimpleQueue(Generic[_T]):
def __init__(self) -> None: ...
def empty(self) -> bool: ...
def get(self, block: bool = True, timeout: float | None = None) -> _T: ...
def get_nowait(self) -> _T: ...
def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ...
def put_nowait(self, item: _T) -> None: ...
def qsize(self) -> int: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

270
.vscode/Pico-W-Stub/stdlib/re.pyi vendored Normal file
View File

@@ -0,0 +1,270 @@
import enum
import sre_compile
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable, Iterator, Mapping
from sre_constants import error as error
from typing import Any, AnyStr, Generic, TypeVar, overload
from typing_extensions import Literal, TypeAlias, final
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [
"match",
"fullmatch",
"search",
"sub",
"subn",
"split",
"findall",
"finditer",
"compile",
"purge",
"template",
"escape",
"error",
"A",
"I",
"L",
"M",
"S",
"X",
"U",
"ASCII",
"IGNORECASE",
"LOCALE",
"MULTILINE",
"DOTALL",
"VERBOSE",
"UNICODE",
"Match",
"Pattern",
]
if sys.version_info >= (3, 11):
__all__ += ["NOFLAG", "RegexFlag"]
_T = TypeVar("_T")
@final
class Match(Generic[AnyStr]):
@property
def pos(self) -> int: ...
@property
def endpos(self) -> int: ...
@property
def lastindex(self) -> int | None: ...
@property
def lastgroup(self) -> str | None: ...
@property
def string(self) -> AnyStr: ...
# The regular expression object whose match() or search() method produced
# this match instance.
@property
def re(self) -> Pattern[AnyStr]: ...
@overload
def expand(self: Match[str], template: str) -> str: ...
@overload
def expand(self: Match[bytes], template: ReadableBuffer) -> bytes: ...
# group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
@overload
def group(self, __group: Literal[0] = ...) -> AnyStr: ...
@overload
def group(self, __group: str | int) -> AnyStr | Any: ...
@overload
def group(self, __group1: str | int, __group2: str | int, *groups: str | int) -> tuple[AnyStr | Any, ...]: ...
# Each item of groups()'s return tuple is either "AnyStr" or
# "AnyStr | None", depending on the pattern.
@overload
def groups(self) -> tuple[AnyStr | Any, ...]: ...
@overload
def groups(self, default: _T) -> tuple[AnyStr | _T, ...]: ...
# Each value in groupdict()'s return dict is either "AnyStr" or
# "AnyStr | None", depending on the pattern.
@overload
def groupdict(self) -> dict[str, AnyStr | Any]: ...
@overload
def groupdict(self, default: _T) -> dict[str, AnyStr | _T]: ...
def start(self, __group: int | str = ...) -> int: ...
def end(self, __group: int | str = ...) -> int: ...
def span(self, __group: int | str = ...) -> tuple[int, int]: ...
@property
def regs(self) -> tuple[tuple[int, int], ...]: ... # undocumented
# __getitem__() returns "AnyStr" or "AnyStr | None", depending on the pattern.
@overload
def __getitem__(self, __key: Literal[0]) -> AnyStr: ...
@overload
def __getitem__(self, __key: int | str) -> AnyStr | Any: ...
def __copy__(self) -> Match[AnyStr]: ...
def __deepcopy__(self, __memo: Any) -> Match[AnyStr]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
@final
class Pattern(Generic[AnyStr]):
@property
def flags(self) -> int: ...
@property
def groupindex(self) -> Mapping[str, int]: ...
@property
def groups(self) -> int: ...
@property
def pattern(self) -> AnyStr: ...
@overload
def search(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> Match[str] | None: ...
@overload
def search(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> Match[bytes] | None: ...
@overload
def match(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> Match[str] | None: ...
@overload
def match(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> Match[bytes] | None: ...
@overload
def fullmatch(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> Match[str] | None: ...
@overload
def fullmatch(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> Match[bytes] | None: ...
@overload
def split(self: Pattern[str], string: str, maxsplit: int = ...) -> list[str | Any]: ...
@overload
def split(self: Pattern[bytes], string: ReadableBuffer, maxsplit: int = ...) -> list[bytes | Any]: ...
# return type depends on the number of groups in the pattern
@overload
def findall(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> list[Any]: ...
@overload
def findall(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> list[Any]: ...
@overload
def finditer(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> Iterator[Match[str]]: ...
@overload
def finditer(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> Iterator[Match[bytes]]: ...
@overload
def sub(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = ...) -> str: ...
@overload
def sub(
self: Pattern[bytes],
repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer],
string: ReadableBuffer,
count: int = ...,
) -> bytes: ...
@overload
def subn(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = ...) -> tuple[str, int]: ...
@overload
def subn(
self: Pattern[bytes],
repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer],
string: ReadableBuffer,
count: int = ...,
) -> tuple[bytes, int]: ...
def __copy__(self) -> Pattern[AnyStr]: ...
def __deepcopy__(self, __memo: Any) -> Pattern[AnyStr]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
# ----- re variables and constants -----
class RegexFlag(enum.IntFlag):
A = sre_compile.SRE_FLAG_ASCII
ASCII = A
DEBUG = sre_compile.SRE_FLAG_DEBUG
I = sre_compile.SRE_FLAG_IGNORECASE
IGNORECASE = I
L = sre_compile.SRE_FLAG_LOCALE
LOCALE = L
M = sre_compile.SRE_FLAG_MULTILINE
MULTILINE = M
S = sre_compile.SRE_FLAG_DOTALL
DOTALL = S
X = sre_compile.SRE_FLAG_VERBOSE
VERBOSE = X
U = sre_compile.SRE_FLAG_UNICODE
UNICODE = U
T = sre_compile.SRE_FLAG_TEMPLATE
TEMPLATE = T
if sys.version_info >= (3, 11):
NOFLAG: int
A = RegexFlag.A
ASCII = RegexFlag.ASCII
DEBUG = RegexFlag.DEBUG
I = RegexFlag.I
IGNORECASE = RegexFlag.IGNORECASE
L = RegexFlag.L
LOCALE = RegexFlag.LOCALE
M = RegexFlag.M
MULTILINE = RegexFlag.MULTILINE
S = RegexFlag.S
DOTALL = RegexFlag.DOTALL
X = RegexFlag.X
VERBOSE = RegexFlag.VERBOSE
U = RegexFlag.U
UNICODE = RegexFlag.UNICODE
T = RegexFlag.T
TEMPLATE = RegexFlag.TEMPLATE
if sys.version_info >= (3, 11):
NOFLAG = RegexFlag.NOFLAG
_FlagsType: TypeAlias = int | RegexFlag
# Type-wise the compile() overloads are unnecessary, they could also be modeled using
# unions in the parameter types. However mypy has a bug regarding TypeVar
# constraints (https://github.com/python/mypy/issues/11880),
# which limits us here because AnyStr is a constrained TypeVar.
# pattern arguments do *not* accept arbitrary buffers such as bytearray,
# because the pattern must be hashable.
@overload
def compile(pattern: AnyStr, flags: _FlagsType = ...) -> Pattern[AnyStr]: ...
@overload
def compile(pattern: Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ...
@overload
def search(pattern: str | Pattern[str], string: str, flags: _FlagsType = ...) -> Match[str] | None: ...
@overload
def search(pattern: bytes | Pattern[bytes], string: ReadableBuffer, flags: _FlagsType = ...) -> Match[bytes] | None: ...
@overload
def match(pattern: str | Pattern[str], string: str, flags: _FlagsType = ...) -> Match[str] | None: ...
@overload
def match(pattern: bytes | Pattern[bytes], string: ReadableBuffer, flags: _FlagsType = ...) -> Match[bytes] | None: ...
@overload
def fullmatch(pattern: str | Pattern[str], string: str, flags: _FlagsType = ...) -> Match[str] | None: ...
@overload
def fullmatch(pattern: bytes | Pattern[bytes], string: ReadableBuffer, flags: _FlagsType = ...) -> Match[bytes] | None: ...
@overload
def split(pattern: str | Pattern[str], string: str, maxsplit: int = ..., flags: _FlagsType = ...) -> list[str | Any]: ...
@overload
def split(
pattern: bytes | Pattern[bytes], string: ReadableBuffer, maxsplit: int = ..., flags: _FlagsType = ...
) -> list[bytes | Any]: ...
@overload
def findall(pattern: str | Pattern[str], string: str, flags: _FlagsType = ...) -> list[Any]: ...
@overload
def findall(pattern: bytes | Pattern[bytes], string: ReadableBuffer, flags: _FlagsType = ...) -> list[Any]: ...
@overload
def finditer(pattern: str | Pattern[str], string: str, flags: _FlagsType = ...) -> Iterator[Match[str]]: ...
@overload
def finditer(pattern: bytes | Pattern[bytes], string: ReadableBuffer, flags: _FlagsType = ...) -> Iterator[Match[bytes]]: ...
@overload
def sub(
pattern: str | Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = ..., flags: _FlagsType = ...
) -> str: ...
@overload
def sub(
pattern: bytes | Pattern[bytes],
repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer],
string: ReadableBuffer,
count: int = ...,
flags: _FlagsType = ...,
) -> bytes: ...
@overload
def subn(
pattern: str | Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = ..., flags: _FlagsType = ...
) -> tuple[str, int]: ...
@overload
def subn(
pattern: bytes | Pattern[bytes],
repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer],
string: ReadableBuffer,
count: int = ...,
flags: _FlagsType = ...,
) -> tuple[bytes, int]: ...
def escape(pattern: AnyStr) -> AnyStr: ...
def purge() -> None: ...
def template(pattern: AnyStr | Pattern[AnyStr], flags: _FlagsType = ...) -> Pattern[AnyStr]: ...

View File

@@ -0,0 +1,73 @@
import sys
from _typeshed import FileDescriptor, FileDescriptorLike, Unused
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping
from typing import Any, NamedTuple
from typing_extensions import Self, TypeAlias
_EventMask: TypeAlias = int
EVENT_READ: _EventMask
EVENT_WRITE: _EventMask
class SelectorKey(NamedTuple):
fileobj: FileDescriptorLike
fd: FileDescriptor
events: _EventMask
data: Any
class BaseSelector(metaclass=ABCMeta):
@abstractmethod
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
@abstractmethod
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
def modify(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
@abstractmethod
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
def close(self) -> None: ...
def get_key(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
@abstractmethod
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: Unused) -> None: ...
class SelectSelector(BaseSelector):
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
if sys.platform != "win32":
class PollSelector(BaseSelector):
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
if sys.platform == "linux":
class EpollSelector(BaseSelector):
def fileno(self) -> int: ...
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
class DevpollSelector(BaseSelector):
def fileno(self) -> int: ...
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
class KqueueSelector(BaseSelector):
def fileno(self) -> int: ...
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
class DefaultSelector(BaseSelector):
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...

831
.vscode/Pico-W-Stub/stdlib/socket.pyi vendored Normal file
View File

@@ -0,0 +1,831 @@
# Ideally, we'd just do "from _socket import *". Unfortunately, socket
# overrides some definitions from _socket incompatibly. mypy incorrectly
# prefers the definitions from _socket over those defined here.
import _socket
import sys
from _socket import (
_FD,
EAI_AGAIN as EAI_AGAIN,
EAI_BADFLAGS as EAI_BADFLAGS,
EAI_FAIL as EAI_FAIL,
EAI_FAMILY as EAI_FAMILY,
EAI_MEMORY as EAI_MEMORY,
EAI_NODATA as EAI_NODATA,
EAI_NONAME as EAI_NONAME,
EAI_SERVICE as EAI_SERVICE,
EAI_SOCKTYPE as EAI_SOCKTYPE,
INADDR_ALLHOSTS_GROUP as INADDR_ALLHOSTS_GROUP,
INADDR_ANY as INADDR_ANY,
INADDR_BROADCAST as INADDR_BROADCAST,
INADDR_LOOPBACK as INADDR_LOOPBACK,
INADDR_MAX_LOCAL_GROUP as INADDR_MAX_LOCAL_GROUP,
INADDR_NONE as INADDR_NONE,
INADDR_UNSPEC_GROUP as INADDR_UNSPEC_GROUP,
IP_ADD_MEMBERSHIP as IP_ADD_MEMBERSHIP,
IP_DROP_MEMBERSHIP as IP_DROP_MEMBERSHIP,
IP_HDRINCL as IP_HDRINCL,
IP_MULTICAST_IF as IP_MULTICAST_IF,
IP_MULTICAST_LOOP as IP_MULTICAST_LOOP,
IP_MULTICAST_TTL as IP_MULTICAST_TTL,
IP_OPTIONS as IP_OPTIONS,
IP_RECVDSTADDR as IP_RECVDSTADDR,
IP_TOS as IP_TOS,
IP_TTL as IP_TTL,
IPPORT_RESERVED as IPPORT_RESERVED,
IPPORT_USERRESERVED as IPPORT_USERRESERVED,
IPPROTO_ICMP as IPPROTO_ICMP,
IPPROTO_IP as IPPROTO_IP,
IPPROTO_RAW as IPPROTO_RAW,
IPPROTO_TCP as IPPROTO_TCP,
IPPROTO_UDP as IPPROTO_UDP,
IPV6_CHECKSUM as IPV6_CHECKSUM,
IPV6_JOIN_GROUP as IPV6_JOIN_GROUP,
IPV6_LEAVE_GROUP as IPV6_LEAVE_GROUP,
IPV6_MULTICAST_HOPS as IPV6_MULTICAST_HOPS,
IPV6_MULTICAST_IF as IPV6_MULTICAST_IF,
IPV6_MULTICAST_LOOP as IPV6_MULTICAST_LOOP,
IPV6_RECVTCLASS as IPV6_RECVTCLASS,
IPV6_TCLASS as IPV6_TCLASS,
IPV6_UNICAST_HOPS as IPV6_UNICAST_HOPS,
IPV6_V6ONLY as IPV6_V6ONLY,
NI_DGRAM as NI_DGRAM,
NI_MAXHOST as NI_MAXHOST,
NI_MAXSERV as NI_MAXSERV,
NI_NAMEREQD as NI_NAMEREQD,
NI_NOFQDN as NI_NOFQDN,
NI_NUMERICHOST as NI_NUMERICHOST,
NI_NUMERICSERV as NI_NUMERICSERV,
SHUT_RD as SHUT_RD,
SHUT_RDWR as SHUT_RDWR,
SHUT_WR as SHUT_WR,
SO_ACCEPTCONN as SO_ACCEPTCONN,
SO_BROADCAST as SO_BROADCAST,
SO_DEBUG as SO_DEBUG,
SO_DONTROUTE as SO_DONTROUTE,
SO_ERROR as SO_ERROR,
SO_KEEPALIVE as SO_KEEPALIVE,
SO_LINGER as SO_LINGER,
SO_OOBINLINE as SO_OOBINLINE,
SO_RCVBUF as SO_RCVBUF,
SO_RCVLOWAT as SO_RCVLOWAT,
SO_RCVTIMEO as SO_RCVTIMEO,
SO_REUSEADDR as SO_REUSEADDR,
SO_SNDBUF as SO_SNDBUF,
SO_SNDLOWAT as SO_SNDLOWAT,
SO_SNDTIMEO as SO_SNDTIMEO,
SO_TYPE as SO_TYPE,
SO_USELOOPBACK as SO_USELOOPBACK,
SOL_IP as SOL_IP,
SOL_SOCKET as SOL_SOCKET,
SOL_TCP as SOL_TCP,
SOL_UDP as SOL_UDP,
SOMAXCONN as SOMAXCONN,
TCP_FASTOPEN as TCP_FASTOPEN,
TCP_KEEPCNT as TCP_KEEPCNT,
TCP_MAXSEG as TCP_MAXSEG,
TCP_NODELAY as TCP_NODELAY,
SocketType as SocketType,
_Address as _Address,
_RetAddress as _RetAddress,
dup as dup,
error as error,
gaierror as gaierror,
getdefaulttimeout as getdefaulttimeout,
gethostbyaddr as gethostbyaddr,
gethostbyname as gethostbyname,
gethostbyname_ex as gethostbyname_ex,
gethostname as gethostname,
getnameinfo as getnameinfo,
getprotobyname as getprotobyname,
getservbyname as getservbyname,
getservbyport as getservbyport,
has_ipv6 as has_ipv6,
herror as herror,
htonl as htonl,
htons as htons,
inet_aton as inet_aton,
inet_ntoa as inet_ntoa,
inet_ntop as inet_ntop,
inet_pton as inet_pton,
ntohl as ntohl,
ntohs as ntohs,
setdefaulttimeout as setdefaulttimeout,
timeout as timeout,
)
from _typeshed import ReadableBuffer, Unused, WriteableBuffer
from collections.abc import Iterable
from enum import IntEnum, IntFlag
from io import BufferedReader, BufferedRWPair, BufferedWriter, IOBase, RawIOBase, TextIOWrapper
from typing import Any, Protocol, overload
from typing_extensions import Literal, Self
if sys.platform != "darwin" or sys.version_info >= (3, 9):
from _socket import (
IPV6_DONTFRAG as IPV6_DONTFRAG,
IPV6_HOPLIMIT as IPV6_HOPLIMIT,
IPV6_HOPOPTS as IPV6_HOPOPTS,
IPV6_PKTINFO as IPV6_PKTINFO,
IPV6_RECVRTHDR as IPV6_RECVRTHDR,
IPV6_RTHDR as IPV6_RTHDR,
)
if sys.platform != "darwin":
from _socket import SO_EXCLUSIVEADDRUSE as SO_EXCLUSIVEADDRUSE
if sys.version_info >= (3, 10):
from _socket import IP_RECVTOS as IP_RECVTOS
elif sys.platform != "darwin" and sys.platform != "win32":
from _socket import IP_RECVTOS as IP_RECVTOS
from _socket import TCP_KEEPINTVL as TCP_KEEPINTVL, close as close
if sys.platform != "darwin":
from _socket import TCP_KEEPIDLE as TCP_KEEPIDLE
if sys.platform != "win32" or sys.version_info >= (3, 8):
from _socket import (
IPPROTO_AH as IPPROTO_AH,
IPPROTO_DSTOPTS as IPPROTO_DSTOPTS,
IPPROTO_EGP as IPPROTO_EGP,
IPPROTO_ESP as IPPROTO_ESP,
IPPROTO_FRAGMENT as IPPROTO_FRAGMENT,
IPPROTO_GGP as IPPROTO_GGP,
IPPROTO_HOPOPTS as IPPROTO_HOPOPTS,
IPPROTO_ICMPV6 as IPPROTO_ICMPV6,
IPPROTO_IDP as IPPROTO_IDP,
IPPROTO_IGMP as IPPROTO_IGMP,
IPPROTO_IPV4 as IPPROTO_IPV4,
IPPROTO_IPV6 as IPPROTO_IPV6,
IPPROTO_MAX as IPPROTO_MAX,
IPPROTO_ND as IPPROTO_ND,
IPPROTO_NONE as IPPROTO_NONE,
IPPROTO_PIM as IPPROTO_PIM,
IPPROTO_PUP as IPPROTO_PUP,
IPPROTO_ROUTING as IPPROTO_ROUTING,
IPPROTO_SCTP as IPPROTO_SCTP,
)
if sys.platform != "darwin":
from _socket import (
IPPROTO_CBT as IPPROTO_CBT,
IPPROTO_ICLFXBM as IPPROTO_ICLFXBM,
IPPROTO_IGP as IPPROTO_IGP,
IPPROTO_L2TP as IPPROTO_L2TP,
IPPROTO_PGM as IPPROTO_PGM,
IPPROTO_RDP as IPPROTO_RDP,
IPPROTO_ST as IPPROTO_ST,
)
if sys.platform != "win32" and sys.platform != "darwin":
from _socket import (
IP_TRANSPARENT as IP_TRANSPARENT,
IPPROTO_BIP as IPPROTO_BIP,
IPPROTO_MOBILE as IPPROTO_MOBILE,
IPPROTO_VRRP as IPPROTO_VRRP,
IPX_TYPE as IPX_TYPE,
SCM_CREDENTIALS as SCM_CREDENTIALS,
SO_BINDTODEVICE as SO_BINDTODEVICE,
SO_MARK as SO_MARK,
SO_PASSCRED as SO_PASSCRED,
SO_PEERCRED as SO_PEERCRED,
SO_PRIORITY as SO_PRIORITY,
SO_SETFIB as SO_SETFIB,
SOL_ATALK as SOL_ATALK,
SOL_AX25 as SOL_AX25,
SOL_HCI as SOL_HCI,
SOL_IPX as SOL_IPX,
SOL_NETROM as SOL_NETROM,
SOL_ROSE as SOL_ROSE,
TCP_CORK as TCP_CORK,
TCP_DEFER_ACCEPT as TCP_DEFER_ACCEPT,
TCP_INFO as TCP_INFO,
TCP_LINGER2 as TCP_LINGER2,
TCP_QUICKACK as TCP_QUICKACK,
TCP_SYNCNT as TCP_SYNCNT,
TCP_USER_TIMEOUT as TCP_USER_TIMEOUT,
TCP_WINDOW_CLAMP as TCP_WINDOW_CLAMP,
)
if sys.platform != "win32":
from _socket import (
CMSG_LEN as CMSG_LEN,
CMSG_SPACE as CMSG_SPACE,
EAI_ADDRFAMILY as EAI_ADDRFAMILY,
EAI_BADHINTS as EAI_BADHINTS,
EAI_MAX as EAI_MAX,
EAI_OVERFLOW as EAI_OVERFLOW,
EAI_PROTOCOL as EAI_PROTOCOL,
EAI_SYSTEM as EAI_SYSTEM,
IP_DEFAULT_MULTICAST_LOOP as IP_DEFAULT_MULTICAST_LOOP,
IP_DEFAULT_MULTICAST_TTL as IP_DEFAULT_MULTICAST_TTL,
IP_MAX_MEMBERSHIPS as IP_MAX_MEMBERSHIPS,
IP_RECVOPTS as IP_RECVOPTS,
IP_RECVRETOPTS as IP_RECVRETOPTS,
IP_RETOPTS as IP_RETOPTS,
IPPROTO_EON as IPPROTO_EON,
IPPROTO_GRE as IPPROTO_GRE,
IPPROTO_HELLO as IPPROTO_HELLO,
IPPROTO_IPCOMP as IPPROTO_IPCOMP,
IPPROTO_IPIP as IPPROTO_IPIP,
IPPROTO_RSVP as IPPROTO_RSVP,
IPPROTO_TP as IPPROTO_TP,
IPPROTO_XTP as IPPROTO_XTP,
IPV6_RTHDR_TYPE_0 as IPV6_RTHDR_TYPE_0,
LOCAL_PEERCRED as LOCAL_PEERCRED,
SCM_CREDS as SCM_CREDS,
SCM_RIGHTS as SCM_RIGHTS,
SO_REUSEPORT as SO_REUSEPORT,
sethostname as sethostname,
)
if sys.platform != "darwin" or sys.version_info >= (3, 9):
from _socket import (
IPV6_DSTOPTS as IPV6_DSTOPTS,
IPV6_NEXTHOP as IPV6_NEXTHOP,
IPV6_PATHMTU as IPV6_PATHMTU,
IPV6_RECVDSTOPTS as IPV6_RECVDSTOPTS,
IPV6_RECVHOPLIMIT as IPV6_RECVHOPLIMIT,
IPV6_RECVHOPOPTS as IPV6_RECVHOPOPTS,
IPV6_RECVPATHMTU as IPV6_RECVPATHMTU,
IPV6_RECVPKTINFO as IPV6_RECVPKTINFO,
IPV6_RTHDRDSTOPTS as IPV6_RTHDRDSTOPTS,
IPV6_USE_MIN_MTU as IPV6_USE_MIN_MTU,
)
if sys.platform != "win32" or sys.version_info >= (3, 8):
from _socket import if_indextoname as if_indextoname, if_nameindex as if_nameindex, if_nametoindex as if_nametoindex
if sys.platform != "darwin":
if sys.platform != "win32" or sys.version_info >= (3, 9):
from _socket import BDADDR_ANY as BDADDR_ANY, BDADDR_LOCAL as BDADDR_LOCAL, BTPROTO_RFCOMM as BTPROTO_RFCOMM
if sys.platform == "darwin" and sys.version_info >= (3, 10):
from _socket import TCP_KEEPALIVE as TCP_KEEPALIVE
if sys.platform == "linux":
from _socket import (
ALG_OP_DECRYPT as ALG_OP_DECRYPT,
ALG_OP_ENCRYPT as ALG_OP_ENCRYPT,
ALG_OP_SIGN as ALG_OP_SIGN,
ALG_OP_VERIFY as ALG_OP_VERIFY,
ALG_SET_AEAD_ASSOCLEN as ALG_SET_AEAD_ASSOCLEN,
ALG_SET_AEAD_AUTHSIZE as ALG_SET_AEAD_AUTHSIZE,
ALG_SET_IV as ALG_SET_IV,
ALG_SET_KEY as ALG_SET_KEY,
ALG_SET_OP as ALG_SET_OP,
ALG_SET_PUBKEY as ALG_SET_PUBKEY,
CAN_BCM as CAN_BCM,
CAN_BCM_RX_CHANGED as CAN_BCM_RX_CHANGED,
CAN_BCM_RX_DELETE as CAN_BCM_RX_DELETE,
CAN_BCM_RX_READ as CAN_BCM_RX_READ,
CAN_BCM_RX_SETUP as CAN_BCM_RX_SETUP,
CAN_BCM_RX_STATUS as CAN_BCM_RX_STATUS,
CAN_BCM_RX_TIMEOUT as CAN_BCM_RX_TIMEOUT,
CAN_BCM_TX_DELETE as CAN_BCM_TX_DELETE,
CAN_BCM_TX_EXPIRED as CAN_BCM_TX_EXPIRED,
CAN_BCM_TX_READ as CAN_BCM_TX_READ,
CAN_BCM_TX_SEND as CAN_BCM_TX_SEND,
CAN_BCM_TX_SETUP as CAN_BCM_TX_SETUP,
CAN_BCM_TX_STATUS as CAN_BCM_TX_STATUS,
CAN_EFF_FLAG as CAN_EFF_FLAG,
CAN_EFF_MASK as CAN_EFF_MASK,
CAN_ERR_FLAG as CAN_ERR_FLAG,
CAN_ERR_MASK as CAN_ERR_MASK,
CAN_RAW as CAN_RAW,
CAN_RAW_ERR_FILTER as CAN_RAW_ERR_FILTER,
CAN_RAW_FD_FRAMES as CAN_RAW_FD_FRAMES,
CAN_RAW_FILTER as CAN_RAW_FILTER,
CAN_RAW_LOOPBACK as CAN_RAW_LOOPBACK,
CAN_RAW_RECV_OWN_MSGS as CAN_RAW_RECV_OWN_MSGS,
CAN_RTR_FLAG as CAN_RTR_FLAG,
CAN_SFF_MASK as CAN_SFF_MASK,
NETLINK_ARPD as NETLINK_ARPD,
NETLINK_CRYPTO as NETLINK_CRYPTO,
NETLINK_DNRTMSG as NETLINK_DNRTMSG,
NETLINK_FIREWALL as NETLINK_FIREWALL,
NETLINK_IP6_FW as NETLINK_IP6_FW,
NETLINK_NFLOG as NETLINK_NFLOG,
NETLINK_ROUTE as NETLINK_ROUTE,
NETLINK_ROUTE6 as NETLINK_ROUTE6,
NETLINK_SKIP as NETLINK_SKIP,
NETLINK_TAPBASE as NETLINK_TAPBASE,
NETLINK_TCPDIAG as NETLINK_TCPDIAG,
NETLINK_USERSOCK as NETLINK_USERSOCK,
NETLINK_W1 as NETLINK_W1,
NETLINK_XFRM as NETLINK_XFRM,
PACKET_BROADCAST as PACKET_BROADCAST,
PACKET_FASTROUTE as PACKET_FASTROUTE,
PACKET_HOST as PACKET_HOST,
PACKET_LOOPBACK as PACKET_LOOPBACK,
PACKET_MULTICAST as PACKET_MULTICAST,
PACKET_OTHERHOST as PACKET_OTHERHOST,
PACKET_OUTGOING as PACKET_OUTGOING,
PF_CAN as PF_CAN,
PF_PACKET as PF_PACKET,
PF_RDS as PF_RDS,
RDS_CANCEL_SENT_TO as RDS_CANCEL_SENT_TO,
RDS_CMSG_RDMA_ARGS as RDS_CMSG_RDMA_ARGS,
RDS_CMSG_RDMA_DEST as RDS_CMSG_RDMA_DEST,
RDS_CMSG_RDMA_MAP as RDS_CMSG_RDMA_MAP,
RDS_CMSG_RDMA_STATUS as RDS_CMSG_RDMA_STATUS,
RDS_CMSG_RDMA_UPDATE as RDS_CMSG_RDMA_UPDATE,
RDS_CONG_MONITOR as RDS_CONG_MONITOR,
RDS_FREE_MR as RDS_FREE_MR,
RDS_GET_MR as RDS_GET_MR,
RDS_GET_MR_FOR_DEST as RDS_GET_MR_FOR_DEST,
RDS_RDMA_DONTWAIT as RDS_RDMA_DONTWAIT,
RDS_RDMA_FENCE as RDS_RDMA_FENCE,
RDS_RDMA_INVALIDATE as RDS_RDMA_INVALIDATE,
RDS_RDMA_NOTIFY_ME as RDS_RDMA_NOTIFY_ME,
RDS_RDMA_READWRITE as RDS_RDMA_READWRITE,
RDS_RDMA_SILENT as RDS_RDMA_SILENT,
RDS_RDMA_USE_ONCE as RDS_RDMA_USE_ONCE,
RDS_RECVERR as RDS_RECVERR,
SOL_ALG as SOL_ALG,
SOL_CAN_BASE as SOL_CAN_BASE,
SOL_CAN_RAW as SOL_CAN_RAW,
SOL_RDS as SOL_RDS,
SOL_TIPC as SOL_TIPC,
TIPC_ADDR_ID as TIPC_ADDR_ID,
TIPC_ADDR_NAME as TIPC_ADDR_NAME,
TIPC_ADDR_NAMESEQ as TIPC_ADDR_NAMESEQ,
TIPC_CFG_SRV as TIPC_CFG_SRV,
TIPC_CLUSTER_SCOPE as TIPC_CLUSTER_SCOPE,
TIPC_CONN_TIMEOUT as TIPC_CONN_TIMEOUT,
TIPC_CRITICAL_IMPORTANCE as TIPC_CRITICAL_IMPORTANCE,
TIPC_DEST_DROPPABLE as TIPC_DEST_DROPPABLE,
TIPC_HIGH_IMPORTANCE as TIPC_HIGH_IMPORTANCE,
TIPC_IMPORTANCE as TIPC_IMPORTANCE,
TIPC_LOW_IMPORTANCE as TIPC_LOW_IMPORTANCE,
TIPC_MEDIUM_IMPORTANCE as TIPC_MEDIUM_IMPORTANCE,
TIPC_NODE_SCOPE as TIPC_NODE_SCOPE,
TIPC_PUBLISHED as TIPC_PUBLISHED,
TIPC_SRC_DROPPABLE as TIPC_SRC_DROPPABLE,
TIPC_SUB_CANCEL as TIPC_SUB_CANCEL,
TIPC_SUB_PORTS as TIPC_SUB_PORTS,
TIPC_SUB_SERVICE as TIPC_SUB_SERVICE,
TIPC_SUBSCR_TIMEOUT as TIPC_SUBSCR_TIMEOUT,
TIPC_TOP_SRV as TIPC_TOP_SRV,
TIPC_WAIT_FOREVER as TIPC_WAIT_FOREVER,
TIPC_WITHDRAWN as TIPC_WITHDRAWN,
TIPC_ZONE_SCOPE as TIPC_ZONE_SCOPE,
)
if sys.platform == "linux":
from _socket import (
CAN_ISOTP as CAN_ISOTP,
IOCTL_VM_SOCKETS_GET_LOCAL_CID as IOCTL_VM_SOCKETS_GET_LOCAL_CID,
SO_VM_SOCKETS_BUFFER_MAX_SIZE as SO_VM_SOCKETS_BUFFER_MAX_SIZE,
SO_VM_SOCKETS_BUFFER_MIN_SIZE as SO_VM_SOCKETS_BUFFER_MIN_SIZE,
SO_VM_SOCKETS_BUFFER_SIZE as SO_VM_SOCKETS_BUFFER_SIZE,
VM_SOCKETS_INVALID_VERSION as VM_SOCKETS_INVALID_VERSION,
VMADDR_CID_ANY as VMADDR_CID_ANY,
VMADDR_CID_HOST as VMADDR_CID_HOST,
VMADDR_PORT_ANY as VMADDR_PORT_ANY,
)
if sys.platform != "win32":
from _socket import TCP_NOTSENT_LOWAT as TCP_NOTSENT_LOWAT
if sys.platform == "linux" and sys.version_info >= (3, 8):
from _socket import (
CAN_BCM_CAN_FD_FRAME as CAN_BCM_CAN_FD_FRAME,
CAN_BCM_RX_ANNOUNCE_RESUME as CAN_BCM_RX_ANNOUNCE_RESUME,
CAN_BCM_RX_CHECK_DLC as CAN_BCM_RX_CHECK_DLC,
CAN_BCM_RX_FILTER_ID as CAN_BCM_RX_FILTER_ID,
CAN_BCM_RX_NO_AUTOTIMER as CAN_BCM_RX_NO_AUTOTIMER,
CAN_BCM_RX_RTR_FRAME as CAN_BCM_RX_RTR_FRAME,
CAN_BCM_SETTIMER as CAN_BCM_SETTIMER,
CAN_BCM_STARTTIMER as CAN_BCM_STARTTIMER,
CAN_BCM_TX_ANNOUNCE as CAN_BCM_TX_ANNOUNCE,
CAN_BCM_TX_COUNTEVT as CAN_BCM_TX_COUNTEVT,
CAN_BCM_TX_CP_CAN_ID as CAN_BCM_TX_CP_CAN_ID,
CAN_BCM_TX_RESET_MULTI_IDX as CAN_BCM_TX_RESET_MULTI_IDX,
)
if sys.platform == "linux" and sys.version_info >= (3, 9):
from _socket import (
CAN_J1939 as CAN_J1939,
CAN_RAW_JOIN_FILTERS as CAN_RAW_JOIN_FILTERS,
J1939_EE_INFO_NONE as J1939_EE_INFO_NONE,
J1939_EE_INFO_TX_ABORT as J1939_EE_INFO_TX_ABORT,
J1939_FILTER_MAX as J1939_FILTER_MAX,
J1939_IDLE_ADDR as J1939_IDLE_ADDR,
J1939_MAX_UNICAST_ADDR as J1939_MAX_UNICAST_ADDR,
J1939_NLA_BYTES_ACKED as J1939_NLA_BYTES_ACKED,
J1939_NLA_PAD as J1939_NLA_PAD,
J1939_NO_ADDR as J1939_NO_ADDR,
J1939_NO_NAME as J1939_NO_NAME,
J1939_NO_PGN as J1939_NO_PGN,
J1939_PGN_ADDRESS_CLAIMED as J1939_PGN_ADDRESS_CLAIMED,
J1939_PGN_ADDRESS_COMMANDED as J1939_PGN_ADDRESS_COMMANDED,
J1939_PGN_MAX as J1939_PGN_MAX,
J1939_PGN_PDU1_MAX as J1939_PGN_PDU1_MAX,
J1939_PGN_REQUEST as J1939_PGN_REQUEST,
SCM_J1939_DEST_ADDR as SCM_J1939_DEST_ADDR,
SCM_J1939_DEST_NAME as SCM_J1939_DEST_NAME,
SCM_J1939_ERRQUEUE as SCM_J1939_ERRQUEUE,
SCM_J1939_PRIO as SCM_J1939_PRIO,
SO_J1939_ERRQUEUE as SO_J1939_ERRQUEUE,
SO_J1939_FILTER as SO_J1939_FILTER,
SO_J1939_PROMISC as SO_J1939_PROMISC,
SO_J1939_SEND_PRIO as SO_J1939_SEND_PRIO,
)
if sys.platform == "linux" and sys.version_info >= (3, 10):
from _socket import IPPROTO_MPTCP as IPPROTO_MPTCP
if sys.platform == "linux" and sys.version_info >= (3, 11):
from _socket import SO_INCOMING_CPU as SO_INCOMING_CPU
if sys.platform == "win32":
from _socket import (
RCVALL_MAX as RCVALL_MAX,
RCVALL_OFF as RCVALL_OFF,
RCVALL_ON as RCVALL_ON,
RCVALL_SOCKETLEVELONLY as RCVALL_SOCKETLEVELONLY,
SIO_KEEPALIVE_VALS as SIO_KEEPALIVE_VALS,
SIO_LOOPBACK_FAST_PATH as SIO_LOOPBACK_FAST_PATH,
SIO_RCVALL as SIO_RCVALL,
)
if sys.version_info >= (3, 12):
from _socket import (
IP_ADD_SOURCE_MEMBERSHIP as IP_ADD_SOURCE_MEMBERSHIP,
IP_BLOCK_SOURCE as IP_BLOCK_SOURCE,
IP_DROP_SOURCE_MEMBERSHIP as IP_DROP_SOURCE_MEMBERSHIP,
IP_PKTINFO as IP_PKTINFO,
IP_UNBLOCK_SOURCE as IP_UNBLOCK_SOURCE,
)
if sys.platform == "win32":
from _socket import (
HV_GUID_BROADCAST as HV_GUID_BROADCAST,
HV_GUID_CHILDREN as HV_GUID_CHILDREN,
HV_GUID_LOOPBACK as HV_GUID_LOOPBACK,
HV_GUID_PARENT as HV_GUID_PARENT,
HV_GUID_WILDCARD as HV_GUID_WILDCARD,
HV_GUID_ZERO as HV_GUID_ZERO,
HV_PROTOCOL_RAW as HV_PROTOCOL_RAW,
HVSOCKET_ADDRESS_FLAG_PASSTHRU as HVSOCKET_ADDRESS_FLAG_PASSTHRU,
HVSOCKET_CONNECT_TIMEOUT as HVSOCKET_CONNECT_TIMEOUT,
HVSOCKET_CONNECT_TIMEOUT_MAX as HVSOCKET_CONNECT_TIMEOUT_MAX,
HVSOCKET_CONNECTED_SUSPEND as HVSOCKET_CONNECTED_SUSPEND,
)
else:
from _socket import (
ETHERTYPE_ARP as ETHERTYPE_ARP,
ETHERTYPE_IP as ETHERTYPE_IP,
ETHERTYPE_IPV6 as ETHERTYPE_IPV6,
ETHERTYPE_VLAN as ETHERTYPE_VLAN,
)
if sys.version_info >= (3, 11) and sys.platform == "darwin":
from _socket import TCP_CONNECTION_INFO as TCP_CONNECTION_INFO
# Re-exported from errno
EBADF: int
EAGAIN: int
EWOULDBLOCK: int
class AddressFamily(IntEnum):
AF_INET: int
AF_INET6: int
AF_APPLETALK: int
AF_DECnet: int
AF_IPX: int
AF_SNA: int
AF_UNSPEC: int
if sys.platform != "darwin":
AF_IRDA: int
if sys.platform != "win32":
AF_ROUTE: int
AF_SYSTEM: int
AF_UNIX: int
if sys.platform != "darwin" and sys.platform != "win32":
AF_AAL5: int
AF_ASH: int
AF_ATMPVC: int
AF_ATMSVC: int
AF_AX25: int
AF_BRIDGE: int
AF_ECONET: int
AF_KEY: int
AF_LLC: int
AF_NETBEUI: int
AF_NETROM: int
AF_PPPOX: int
AF_ROSE: int
AF_SECURITY: int
AF_WANPIPE: int
AF_X25: int
if sys.platform == "linux":
AF_CAN: int
AF_PACKET: int
AF_RDS: int
AF_TIPC: int
AF_ALG: int
AF_NETLINK: int
AF_VSOCK: int
if sys.version_info >= (3, 8):
AF_QIPCRTR: int
if sys.platform != "win32" or sys.version_info >= (3, 9):
AF_LINK: int
if sys.platform != "darwin":
AF_BLUETOOTH: int
if sys.platform == "win32" and sys.version_info >= (3, 12):
AF_HYPERV: int
AF_INET = AddressFamily.AF_INET
AF_INET6 = AddressFamily.AF_INET6
AF_APPLETALK = AddressFamily.AF_APPLETALK
AF_DECnet = AddressFamily.AF_DECnet
AF_IPX = AddressFamily.AF_IPX
AF_SNA = AddressFamily.AF_SNA
AF_UNSPEC = AddressFamily.AF_UNSPEC
if sys.platform != "darwin":
AF_IRDA = AddressFamily.AF_IRDA
if sys.platform != "win32":
AF_ROUTE = AddressFamily.AF_ROUTE
AF_SYSTEM = AddressFamily.AF_SYSTEM
AF_UNIX = AddressFamily.AF_UNIX
if sys.platform != "win32" and sys.platform != "darwin":
AF_AAL5 = AddressFamily.AF_AAL5
AF_ASH = AddressFamily.AF_ASH
AF_ATMPVC = AddressFamily.AF_ATMPVC
AF_ATMSVC = AddressFamily.AF_ATMSVC
AF_AX25 = AddressFamily.AF_AX25
AF_BRIDGE = AddressFamily.AF_BRIDGE
AF_ECONET = AddressFamily.AF_ECONET
AF_KEY = AddressFamily.AF_KEY
AF_LLC = AddressFamily.AF_LLC
AF_NETBEUI = AddressFamily.AF_NETBEUI
AF_NETROM = AddressFamily.AF_NETROM
AF_PPPOX = AddressFamily.AF_PPPOX
AF_ROSE = AddressFamily.AF_ROSE
AF_SECURITY = AddressFamily.AF_SECURITY
AF_WANPIPE = AddressFamily.AF_WANPIPE
AF_X25 = AddressFamily.AF_X25
if sys.platform == "linux":
AF_CAN = AddressFamily.AF_CAN
AF_PACKET = AddressFamily.AF_PACKET
AF_RDS = AddressFamily.AF_RDS
AF_TIPC = AddressFamily.AF_TIPC
AF_ALG = AddressFamily.AF_ALG
AF_NETLINK = AddressFamily.AF_NETLINK
AF_VSOCK = AddressFamily.AF_VSOCK
if sys.version_info >= (3, 8):
AF_QIPCRTR = AddressFamily.AF_QIPCRTR
if sys.platform != "win32" or sys.version_info >= (3, 9):
AF_LINK = AddressFamily.AF_LINK
if sys.platform != "darwin":
AF_BLUETOOTH = AddressFamily.AF_BLUETOOTH
if sys.platform == "win32" and sys.version_info >= (3, 12):
AF_HYPERV = AddressFamily.AF_HYPERV
class SocketKind(IntEnum):
SOCK_STREAM: int
SOCK_DGRAM: int
SOCK_RAW: int
SOCK_RDM: int
SOCK_SEQPACKET: int
if sys.platform == "linux":
SOCK_CLOEXEC: int
SOCK_NONBLOCK: int
SOCK_STREAM = SocketKind.SOCK_STREAM
SOCK_DGRAM = SocketKind.SOCK_DGRAM
SOCK_RAW = SocketKind.SOCK_RAW
SOCK_RDM = SocketKind.SOCK_RDM
SOCK_SEQPACKET = SocketKind.SOCK_SEQPACKET
if sys.platform == "linux":
SOCK_CLOEXEC = SocketKind.SOCK_CLOEXEC
SOCK_NONBLOCK = SocketKind.SOCK_NONBLOCK
class MsgFlag(IntFlag):
MSG_CTRUNC: int
MSG_DONTROUTE: int
MSG_OOB: int
MSG_PEEK: int
MSG_TRUNC: int
MSG_WAITALL: int
if sys.platform != "darwin":
MSG_BCAST: int
MSG_MCAST: int
MSG_ERRQUEUE: int
if sys.platform != "win32" and sys.platform != "darwin":
MSG_BTAG: int
MSG_CMSG_CLOEXEC: int
MSG_CONFIRM: int
MSG_ETAG: int
MSG_FASTOPEN: int
MSG_MORE: int
MSG_NOTIFICATION: int
if sys.platform != "win32":
MSG_DONTWAIT: int
MSG_EOF: int
MSG_EOR: int
MSG_NOSIGNAL: int # sometimes this exists on darwin, sometimes not
MSG_CTRUNC = MsgFlag.MSG_CTRUNC
MSG_DONTROUTE = MsgFlag.MSG_DONTROUTE
MSG_OOB = MsgFlag.MSG_OOB
MSG_PEEK = MsgFlag.MSG_PEEK
MSG_TRUNC = MsgFlag.MSG_TRUNC
MSG_WAITALL = MsgFlag.MSG_WAITALL
if sys.platform != "darwin":
MSG_BCAST = MsgFlag.MSG_BCAST
MSG_MCAST = MsgFlag.MSG_MCAST
MSG_ERRQUEUE = MsgFlag.MSG_ERRQUEUE
if sys.platform != "win32":
MSG_DONTWAIT = MsgFlag.MSG_DONTWAIT
MSG_EOF = MsgFlag.MSG_EOF
MSG_EOR = MsgFlag.MSG_EOR
MSG_NOSIGNAL = MsgFlag.MSG_NOSIGNAL # Sometimes this exists on darwin, sometimes not
if sys.platform != "win32" and sys.platform != "darwin":
MSG_BTAG = MsgFlag.MSG_BTAG
MSG_CMSG_CLOEXEC = MsgFlag.MSG_CMSG_CLOEXEC
MSG_CONFIRM = MsgFlag.MSG_CONFIRM
MSG_ETAG = MsgFlag.MSG_ETAG
MSG_FASTOPEN = MsgFlag.MSG_FASTOPEN
MSG_MORE = MsgFlag.MSG_MORE
MSG_NOTIFICATION = MsgFlag.MSG_NOTIFICATION
class AddressInfo(IntFlag):
AI_ADDRCONFIG: int
AI_ALL: int
AI_CANONNAME: int
AI_NUMERICHOST: int
AI_NUMERICSERV: int
AI_PASSIVE: int
AI_V4MAPPED: int
if sys.platform != "win32":
AI_DEFAULT: int
AI_MASK: int
AI_V4MAPPED_CFG: int
AI_ADDRCONFIG = AddressInfo.AI_ADDRCONFIG
AI_ALL = AddressInfo.AI_ALL
AI_CANONNAME = AddressInfo.AI_CANONNAME
AI_NUMERICHOST = AddressInfo.AI_NUMERICHOST
AI_NUMERICSERV = AddressInfo.AI_NUMERICSERV
AI_PASSIVE = AddressInfo.AI_PASSIVE
AI_V4MAPPED = AddressInfo.AI_V4MAPPED
if sys.platform != "win32":
AI_DEFAULT = AddressInfo.AI_DEFAULT
AI_MASK = AddressInfo.AI_MASK
AI_V4MAPPED_CFG = AddressInfo.AI_V4MAPPED_CFG
if sys.platform == "win32":
errorTab: dict[int, str] # undocumented
class _SendableFile(Protocol):
def read(self, __size: int) -> bytes: ...
def seek(self, __offset: int) -> object: ...
# optional fields:
#
# @property
# def mode(self) -> str: ...
# def fileno(self) -> int: ...
class socket(_socket.socket):
def __init__(
self, family: AddressFamily | int = -1, type: SocketKind | int = -1, proto: int = -1, fileno: int | None = None
) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: Unused) -> None: ...
def dup(self) -> Self: ... # noqa: F811
def accept(self) -> tuple[socket, _RetAddress]: ...
# Note that the makefile's documented windows-specific behavior is not represented
# mode strings with duplicates are intentionally excluded
@overload
def makefile(
self,
mode: Literal["b", "rb", "br", "wb", "bw", "rwb", "rbw", "wrb", "wbr", "brw", "bwr"],
buffering: Literal[0],
*,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
) -> SocketIO: ...
@overload
def makefile(
self,
mode: Literal["rwb", "rbw", "wrb", "wbr", "brw", "bwr"],
buffering: Literal[-1, 1] | None = None,
*,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
) -> BufferedRWPair: ...
@overload
def makefile(
self,
mode: Literal["rb", "br"],
buffering: Literal[-1, 1] | None = None,
*,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
) -> BufferedReader: ...
@overload
def makefile(
self,
mode: Literal["wb", "bw"],
buffering: Literal[-1, 1] | None = None,
*,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
) -> BufferedWriter: ...
@overload
def makefile(
self,
mode: Literal["b", "rb", "br", "wb", "bw", "rwb", "rbw", "wrb", "wbr", "brw", "bwr"],
buffering: int,
*,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
) -> IOBase: ...
@overload
def makefile(
self,
mode: Literal["r", "w", "rw", "wr", ""] = "r",
buffering: int | None = None,
*,
encoding: str | None = None,
errors: str | None = None,
newline: str | None = None,
) -> TextIOWrapper: ...
def sendfile(self, file: _SendableFile, offset: int = 0, count: int | None = None) -> int: ...
@property
def family(self) -> AddressFamily: ...
@property
def type(self) -> SocketKind: ...
def get_inheritable(self) -> bool: ...
def set_inheritable(self, inheritable: bool) -> None: ...
def fromfd(fd: _FD, family: AddressFamily | int, type: SocketKind | int, proto: int = 0) -> socket: ...
if sys.platform != "win32":
if sys.version_info >= (3, 9):
def send_fds(
sock: socket, buffers: Iterable[ReadableBuffer], fds: Iterable[int], flags: Unused = 0, address: Unused = None
) -> int: ...
def recv_fds(sock: socket, bufsize: int, maxfds: int, flags: int = 0) -> tuple[bytes, list[int], int, Any]: ...
if sys.platform == "win32":
def fromshare(info: bytes) -> socket: ...
if sys.platform == "win32":
def socketpair(family: int = ..., type: int = ..., proto: int = 0) -> tuple[socket, socket]: ...
else:
def socketpair(
family: int | AddressFamily | None = None, type: SocketType | int = ..., proto: int = 0
) -> tuple[socket, socket]: ...
class SocketIO(RawIOBase):
def __init__(self, sock: socket, mode: Literal["r", "w", "rw", "rb", "wb", "rwb"]) -> None: ...
def readinto(self, b: WriteableBuffer) -> int | None: ...
def write(self, b: ReadableBuffer) -> int | None: ...
@property
def name(self) -> int: ... # return value is really "int"
@property
def mode(self) -> Literal["rb", "wb", "rwb"]: ...
def getfqdn(name: str = "") -> str: ...
if sys.version_info >= (3, 11):
def create_connection(
address: tuple[str | None, int],
timeout: float | None = ..., # noqa: F811
source_address: _Address | None = None,
*,
all_errors: bool = False,
) -> socket: ...
else:
def create_connection(
address: tuple[str | None, int], timeout: float | None = ..., source_address: _Address | None = None # noqa: F811
) -> socket: ...
if sys.version_info >= (3, 8):
def has_dualstack_ipv6() -> bool: ...
def create_server(
address: _Address,
*,
family: int = ...,
backlog: int | None = None,
reuse_port: bool = False,
dualstack_ipv6: bool = False,
) -> socket: ...
# the 5th tuple item is an address
def getaddrinfo(
host: bytes | str | None, port: bytes | str | int | None, family: int = 0, type: int = 0, proto: int = 0, flags: int = 0
) -> list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]: ...

View File

@@ -0,0 +1,11 @@
from re import Pattern
from sre_constants import *
from sre_constants import _NamedIntConstant
from sre_parse import SubPattern
from typing import Any
MAXCODE: int
def dis(code: list[_NamedIntConstant]) -> None: ...
def isstring(obj: Any) -> bool: ...
def compile(p: str | bytes | SubPattern, flags: int = 0) -> Pattern[Any]: ...

View File

@@ -0,0 +1,130 @@
import sys
from typing import Any
from typing_extensions import Self
MAXGROUPS: int
MAGIC: int
class error(Exception):
msg: str
pattern: str | bytes | None
pos: int | None
lineno: int
colno: int
def __init__(self, msg: str, pattern: str | bytes | None = None, pos: int | None = None) -> None: ...
class _NamedIntConstant(int):
name: Any
def __new__(cls, value: int, name: str) -> Self: ...
MAXREPEAT: _NamedIntConstant
OPCODES: list[_NamedIntConstant]
ATCODES: list[_NamedIntConstant]
CHCODES: list[_NamedIntConstant]
OP_IGNORE: dict[_NamedIntConstant, _NamedIntConstant]
OP_LOCALE_IGNORE: dict[_NamedIntConstant, _NamedIntConstant]
OP_UNICODE_IGNORE: dict[_NamedIntConstant, _NamedIntConstant]
AT_MULTILINE: dict[_NamedIntConstant, _NamedIntConstant]
AT_LOCALE: dict[_NamedIntConstant, _NamedIntConstant]
AT_UNICODE: dict[_NamedIntConstant, _NamedIntConstant]
CH_LOCALE: dict[_NamedIntConstant, _NamedIntConstant]
CH_UNICODE: dict[_NamedIntConstant, _NamedIntConstant]
SRE_FLAG_TEMPLATE: int
SRE_FLAG_IGNORECASE: int
SRE_FLAG_LOCALE: int
SRE_FLAG_MULTILINE: int
SRE_FLAG_DOTALL: int
SRE_FLAG_UNICODE: int
SRE_FLAG_VERBOSE: int
SRE_FLAG_DEBUG: int
SRE_FLAG_ASCII: int
SRE_INFO_PREFIX: int
SRE_INFO_LITERAL: int
SRE_INFO_CHARSET: int
# Stubgen above; manually defined constants below (dynamic at runtime)
# from OPCODES
FAILURE: _NamedIntConstant
SUCCESS: _NamedIntConstant
ANY: _NamedIntConstant
ANY_ALL: _NamedIntConstant
ASSERT: _NamedIntConstant
ASSERT_NOT: _NamedIntConstant
AT: _NamedIntConstant
BRANCH: _NamedIntConstant
if sys.version_info < (3, 11):
CALL: _NamedIntConstant
CATEGORY: _NamedIntConstant
CHARSET: _NamedIntConstant
BIGCHARSET: _NamedIntConstant
GROUPREF: _NamedIntConstant
GROUPREF_EXISTS: _NamedIntConstant
GROUPREF_IGNORE: _NamedIntConstant
IN: _NamedIntConstant
IN_IGNORE: _NamedIntConstant
INFO: _NamedIntConstant
JUMP: _NamedIntConstant
LITERAL: _NamedIntConstant
LITERAL_IGNORE: _NamedIntConstant
MARK: _NamedIntConstant
MAX_UNTIL: _NamedIntConstant
MIN_UNTIL: _NamedIntConstant
NOT_LITERAL: _NamedIntConstant
NOT_LITERAL_IGNORE: _NamedIntConstant
NEGATE: _NamedIntConstant
RANGE: _NamedIntConstant
REPEAT: _NamedIntConstant
REPEAT_ONE: _NamedIntConstant
SUBPATTERN: _NamedIntConstant
MIN_REPEAT_ONE: _NamedIntConstant
if sys.version_info >= (3, 11):
ATOMIC_GROUP: _NamedIntConstant
POSSESSIVE_REPEAT: _NamedIntConstant
POSSESSIVE_REPEAT_ONE: _NamedIntConstant
RANGE_UNI_IGNORE: _NamedIntConstant
GROUPREF_LOC_IGNORE: _NamedIntConstant
GROUPREF_UNI_IGNORE: _NamedIntConstant
IN_LOC_IGNORE: _NamedIntConstant
IN_UNI_IGNORE: _NamedIntConstant
LITERAL_LOC_IGNORE: _NamedIntConstant
LITERAL_UNI_IGNORE: _NamedIntConstant
NOT_LITERAL_LOC_IGNORE: _NamedIntConstant
NOT_LITERAL_UNI_IGNORE: _NamedIntConstant
MIN_REPEAT: _NamedIntConstant
MAX_REPEAT: _NamedIntConstant
# from ATCODES
AT_BEGINNING: _NamedIntConstant
AT_BEGINNING_LINE: _NamedIntConstant
AT_BEGINNING_STRING: _NamedIntConstant
AT_BOUNDARY: _NamedIntConstant
AT_NON_BOUNDARY: _NamedIntConstant
AT_END: _NamedIntConstant
AT_END_LINE: _NamedIntConstant
AT_END_STRING: _NamedIntConstant
AT_LOC_BOUNDARY: _NamedIntConstant
AT_LOC_NON_BOUNDARY: _NamedIntConstant
AT_UNI_BOUNDARY: _NamedIntConstant
AT_UNI_NON_BOUNDARY: _NamedIntConstant
# from CHCODES
CATEGORY_DIGIT: _NamedIntConstant
CATEGORY_NOT_DIGIT: _NamedIntConstant
CATEGORY_SPACE: _NamedIntConstant
CATEGORY_NOT_SPACE: _NamedIntConstant
CATEGORY_WORD: _NamedIntConstant
CATEGORY_NOT_WORD: _NamedIntConstant
CATEGORY_LINEBREAK: _NamedIntConstant
CATEGORY_NOT_LINEBREAK: _NamedIntConstant
CATEGORY_LOC_WORD: _NamedIntConstant
CATEGORY_LOC_NOT_WORD: _NamedIntConstant
CATEGORY_UNI_DIGIT: _NamedIntConstant
CATEGORY_UNI_NOT_DIGIT: _NamedIntConstant
CATEGORY_UNI_SPACE: _NamedIntConstant
CATEGORY_UNI_NOT_SPACE: _NamedIntConstant
CATEGORY_UNI_WORD: _NamedIntConstant
CATEGORY_UNI_NOT_WORD: _NamedIntConstant
CATEGORY_UNI_LINEBREAK: _NamedIntConstant
CATEGORY_UNI_NOT_LINEBREAK: _NamedIntConstant

125
.vscode/Pico-W-Stub/stdlib/sre_parse.pyi vendored Normal file
View File

@@ -0,0 +1,125 @@
import sys
from collections.abc import Iterable
from re import Match, Pattern as _Pattern
from sre_constants import *
from sre_constants import _NamedIntConstant as _NIC, error as _Error
from typing import Any, overload
from typing_extensions import TypeAlias
SPECIAL_CHARS: str
REPEAT_CHARS: str
DIGITS: frozenset[str]
OCTDIGITS: frozenset[str]
HEXDIGITS: frozenset[str]
ASCIILETTERS: frozenset[str]
WHITESPACE: frozenset[str]
ESCAPES: dict[str, tuple[_NIC, int]]
CATEGORIES: dict[str, tuple[_NIC, _NIC] | tuple[_NIC, list[tuple[_NIC, _NIC]]]]
FLAGS: dict[str, int]
TYPE_FLAGS: int
GLOBAL_FLAGS: int
if sys.version_info < (3, 11):
class Verbose(Exception): ...
class _State:
flags: int
groupdict: dict[str, int]
groupwidths: list[int | None]
lookbehindgroups: int | None
@property
def groups(self) -> int: ...
def opengroup(self, name: str | None = ...) -> int: ...
def closegroup(self, gid: int, p: SubPattern) -> None: ...
def checkgroup(self, gid: int) -> bool: ...
def checklookbehindgroup(self, gid: int, source: Tokenizer) -> None: ...
if sys.version_info >= (3, 8):
State: TypeAlias = _State
else:
Pattern: TypeAlias = _State
_OpSubpatternType: TypeAlias = tuple[int | None, int, int, SubPattern]
_OpGroupRefExistsType: TypeAlias = tuple[int, SubPattern, SubPattern]
_OpInType: TypeAlias = list[tuple[_NIC, int]]
_OpBranchType: TypeAlias = tuple[None, list[SubPattern]]
_AvType: TypeAlias = _OpInType | _OpBranchType | Iterable[SubPattern] | _OpGroupRefExistsType | _OpSubpatternType
_CodeType: TypeAlias = tuple[_NIC, _AvType]
class SubPattern:
data: list[_CodeType]
width: int | None
if sys.version_info >= (3, 8):
state: State
def __init__(self, state: State, data: list[_CodeType] | None = None) -> None: ...
else:
pattern: Pattern
def __init__(self, pattern: Pattern, data: list[_CodeType] | None = None) -> None: ...
def dump(self, level: int = 0) -> None: ...
def __len__(self) -> int: ...
def __delitem__(self, index: int | slice) -> None: ...
def __getitem__(self, index: int | slice) -> SubPattern | _CodeType: ...
def __setitem__(self, index: int | slice, code: _CodeType) -> None: ...
def insert(self, index: int, code: _CodeType) -> None: ...
def append(self, code: _CodeType) -> None: ...
def getwidth(self) -> tuple[int, int]: ...
class Tokenizer:
istext: bool
string: Any
decoded_string: str
index: int
next: str | None
def __init__(self, string: Any) -> None: ...
def match(self, char: str) -> bool: ...
def get(self) -> str | None: ...
def getwhile(self, n: int, charset: Iterable[str]) -> str: ...
if sys.version_info >= (3, 8):
def getuntil(self, terminator: str, name: str) -> str: ...
else:
def getuntil(self, terminator: str) -> str: ...
@property
def pos(self) -> int: ...
def tell(self) -> int: ...
def seek(self, index: int) -> None: ...
def error(self, msg: str, offset: int = 0) -> _Error: ...
if sys.version_info >= (3, 12):
def checkgroupname(self, name: str, offset: int) -> None: ...
elif sys.version_info >= (3, 11):
def checkgroupname(self, name: str, offset: int, nested: int) -> None: ...
def fix_flags(src: str | bytes, flags: int) -> int: ...
_TemplateType: TypeAlias = tuple[list[tuple[int, int]], list[str | None]]
_TemplateByteType: TypeAlias = tuple[list[tuple[int, int]], list[bytes | None]]
if sys.version_info >= (3, 12):
@overload
def parse_template(source: str, pattern: _Pattern[Any]) -> _TemplateType: ...
@overload
def parse_template(source: bytes, pattern: _Pattern[Any]) -> _TemplateByteType: ...
elif sys.version_info >= (3, 8):
@overload
def parse_template(source: str, state: _Pattern[Any]) -> _TemplateType: ...
@overload
def parse_template(source: bytes, state: _Pattern[Any]) -> _TemplateByteType: ...
else:
@overload
def parse_template(source: str, pattern: _Pattern[Any]) -> _TemplateType: ...
@overload
def parse_template(source: bytes, pattern: _Pattern[Any]) -> _TemplateByteType: ...
if sys.version_info >= (3, 8):
def parse(str: str, flags: int = 0, state: State | None = None) -> SubPattern: ...
else:
def parse(str: str, flags: int = 0, pattern: Pattern | None = None) -> SubPattern: ...
if sys.version_info < (3, 12):
def expand_template(template: _TemplateType, match: Match[Any]) -> str: ...

369
.vscode/Pico-W-Stub/stdlib/sys.pyi vendored Normal file
View File

@@ -0,0 +1,369 @@
import sys
from builtins import object as _object
from collections.abc import AsyncGenerator, Callable, Coroutine, Sequence
from importlib.abc import PathEntryFinder # type: ignore
from importlib.machinery import ModuleSpec # type: ignore
from io import TextIOWrapper
from types import FrameType, ModuleType, TracebackType
from typing import Any, NoReturn, Protocol, TextIO, TypeVar, overload
from _typeshed import OptExcInfo, ProfileFunction, TraceFunction, structseq
from typing_extensions import Literal, TypeAlias, final
_T = TypeVar("_T")
# see https://github.com/python/typeshed/issues/8513#issue-1333671093 for the rationale behind this alias
_ExitCode: TypeAlias = str | int | None
_OptExcInfo: TypeAlias = OptExcInfo # noqa: Y047 # TODO: obsolete, remove fall 2022 or later
# Intentionally omits one deprecated and one optional method of `importlib.abc.MetaPathFinder`
class _MetaPathFinder(Protocol):
def find_spec(
self, fullname: str, path: Sequence[str] | None, target: ModuleType | None = ...
) -> ModuleSpec | None: ...
# ----- sys variables -----
if sys.platform != "win32":
abiflags: str
argv: list[str]
base_exec_prefix: str
base_prefix: str
byteorder: Literal["little", "big"]
builtin_module_names: Sequence[str] # actually a tuple of strings
copyright: str
if sys.platform == "win32":
dllhandle: int
dont_write_bytecode: bool
displayhook: Callable[[object], Any]
excepthook: Callable[[type[BaseException], BaseException, TracebackType | None], Any]
exec_prefix: str
executable: str
float_repr_style: Literal["short", "legacy"]
hexversion: int
last_type: type[BaseException] | None
last_value: BaseException | None
last_traceback: TracebackType | None
maxsize: int
maxunicode: int
meta_path: list[_MetaPathFinder]
modules: dict[str, ModuleType]
if sys.version_info >= (3, 10):
orig_argv: list[str]
path: list[str]
path_hooks: list[Callable[[str], PathEntryFinder]]
path_importer_cache: dict[str, PathEntryFinder | None]
platform: str
if sys.version_info >= (3, 9):
platlibdir: str
prefix: str
if sys.version_info >= (3, 8):
pycache_prefix: str | None
ps1: object
ps2: object
stdin: TextIO
stdout: TextIO
stderr: TextIO
if sys.version_info >= (3, 10):
stdlib_module_names: frozenset[str]
__stdin__: TextIOWrapper
__stdout__: TextIOWrapper
__stderr__: TextIOWrapper
tracebacklimit: int
version: str
api_version: int
warnoptions: Any
# Each entry is a tuple of the form (action, message, category, module,
# lineno)
if sys.platform == "win32":
winver: str
_xoptions: dict[Any, Any]
# Type alias used as a mixin for structseq classes that cannot be instantiated at runtime
# This can't be represented in the type system, so we just use `structseq[Any]`
_UninstantiableStructseq: TypeAlias = structseq[Any]
flags: _flags
if sys.version_info >= (3, 10):
_FlagTuple: TypeAlias = tuple[
int, int, int, int, int, int, int, int, int, int, int, int, int, bool, int, int
]
else:
_FlagTuple: TypeAlias = tuple[
int, int, int, int, int, int, int, int, int, int, int, int, int, bool, int
]
@final
class _flags(_UninstantiableStructseq, _FlagTuple):
@property
def debug(self) -> int: ...
@property
def inspect(self) -> int: ...
@property
def interactive(self) -> int: ...
@property
def optimize(self) -> int: ...
@property
def dont_write_bytecode(self) -> int: ...
@property
def no_user_site(self) -> int: ...
@property
def no_site(self) -> int: ...
@property
def ignore_environment(self) -> int: ...
@property
def verbose(self) -> int: ...
@property
def bytes_warning(self) -> int: ...
@property
def quiet(self) -> int: ...
@property
def hash_randomization(self) -> int: ...
@property
def isolated(self) -> int: ...
@property
def dev_mode(self) -> bool: ...
@property
def utf8_mode(self) -> int: ...
if sys.version_info >= (3, 10):
@property
def warn_default_encoding(self) -> int: ... # undocumented
if sys.version_info >= (3, 11):
@property
def safe_path(self) -> bool: ...
float_info: _float_info
@final
class _float_info(
structseq[float], tuple[float, int, int, float, int, int, int, int, float, int, int]
):
@property
def max(self) -> float: ... # DBL_MAX
@property
def max_exp(self) -> int: ... # DBL_MAX_EXP
@property
def max_10_exp(self) -> int: ... # DBL_MAX_10_EXP
@property
def min(self) -> float: ... # DBL_MIN
@property
def min_exp(self) -> int: ... # DBL_MIN_EXP
@property
def min_10_exp(self) -> int: ... # DBL_MIN_10_EXP
@property
def dig(self) -> int: ... # DBL_DIG
@property
def mant_dig(self) -> int: ... # DBL_MANT_DIG
@property
def epsilon(self) -> float: ... # DBL_EPSILON
@property
def radix(self) -> int: ... # FLT_RADIX
@property
def rounds(self) -> int: ... # FLT_ROUNDS
hash_info: _hash_info
@final
class _hash_info(structseq[Any | int], tuple[int, int, int, int, int, str, int, int, int]):
@property
def width(self) -> int: ...
@property
def modulus(self) -> int: ...
@property
def inf(self) -> int: ...
@property
def nan(self) -> int: ...
@property
def imag(self) -> int: ...
@property
def algorithm(self) -> str: ...
@property
def hash_bits(self) -> int: ...
@property
def seed_bits(self) -> int: ...
@property
def cutoff(self) -> int: ... # undocumented
implementation: _implementation
class _implementation:
name: str
version: _version_info
hexversion: int
cache_tag: str
# Define __getattr__, as the documentation states:
# > sys.implementation may contain additional attributes specific to the Python implementation.
# > These non-standard attributes must start with an underscore, and are not described here.
def __getattr__(self, name: str) -> Any: ...
int_info: _int_info
@final
class _int_info(structseq[int], tuple[int, int, int, int]):
@property
def bits_per_digit(self) -> int: ...
@property
def sizeof_digit(self) -> int: ...
@property
def default_max_str_digits(self) -> int: ...
@property
def str_digits_check_threshold(self) -> int: ...
@final
class _version_info(_UninstantiableStructseq, tuple[int, int, int, str, int]):
@property
def major(self) -> int: ...
@property
def minor(self) -> int: ...
@property
def micro(self) -> int: ...
@property
def releaselevel(self) -> str: ...
@property
def serial(self) -> int: ...
version_info: _version_info
def call_tracing(__func: Callable[..., _T], __args: Any) -> _T: ...
def _clear_type_cache() -> None: ...
def _current_frames() -> dict[int, FrameType]: ...
def _getframe(__depth: int = ...) -> FrameType: ...
def _debugmallocstats() -> None: ...
def __displayhook__(__value: object) -> None: ...
def __excepthook__(
__exctype: type[BaseException], __value: BaseException, __traceback: TracebackType | None
) -> None: ...
def exc_info() -> OptExcInfo: ...
if sys.version_info >= (3, 11):
def exception() -> BaseException | None: ...
def exit(__status: _ExitCode = ...) -> NoReturn: ...
def getallocatedblocks() -> int: ...
def getdefaultencoding() -> str: ...
if sys.platform != "win32":
def getdlopenflags() -> int: ...
def getfilesystemencoding() -> str: ...
def getfilesystemencodeerrors() -> str: ...
def getrefcount(__object: Any) -> int: ...
def getrecursionlimit() -> int: ...
@overload
def getsizeof(obj: object) -> int: ...
@overload
def getsizeof(obj: object, default: int) -> int: ...
def getswitchinterval() -> float: ...
def getprofile() -> ProfileFunction | None: ...
def setprofile(profilefunc: ProfileFunction | None) -> None: ...
def gettrace() -> TraceFunction | None: ...
def settrace(tracefunc: TraceFunction | None) -> None: ...
if sys.platform == "win32":
# A tuple of length 5, even though it has more than 5 attributes.
@final
class _WinVersion(_UninstantiableStructseq, tuple[int, int, int, int, str]):
@property
def major(self) -> int: ...
@property
def minor(self) -> int: ...
@property
def build(self) -> int: ...
@property
def platform(self) -> int: ...
@property
def service_pack(self) -> str: ...
@property
def service_pack_minor(self) -> int: ...
@property
def service_pack_major(self) -> int: ...
@property
def suite_mask(self) -> int: ...
@property
def product_type(self) -> int: ...
@property
def platform_version(self) -> tuple[int, int, int]: ...
def getwindowsversion() -> _WinVersion: ...
def intern(__string: str) -> str: ...
def is_finalizing() -> bool: ...
__breakpointhook__: Any # contains the original value of breakpointhook
def breakpointhook(*args: Any, **kwargs: Any) -> Any: ...
if sys.platform != "win32":
def setdlopenflags(__flags: int) -> None: ...
def setrecursionlimit(__limit: int) -> None: ...
def setswitchinterval(__interval: float) -> None: ...
def gettotalrefcount() -> int: ... # Debug builds only
if sys.version_info < (3, 9):
def getcheckinterval() -> int: ... # deprecated
def setcheckinterval(__n: int) -> None: ... # deprecated
if sys.version_info < (3, 9):
# An 11-tuple or None
def callstats() -> tuple[int, int, int, int, int, int, int, int, int, int, int] | None: ...
if sys.version_info >= (3, 8):
# Doesn't exist at runtime, but exported in the stubs so pytest etc. can annotate their code more easily.
class UnraisableHookArgs:
exc_type: type[BaseException]
exc_value: BaseException | None
exc_traceback: TracebackType | None
err_msg: str | None
object: _object | None
unraisablehook: Callable[[UnraisableHookArgs], Any]
def __unraisablehook__(__unraisable: UnraisableHookArgs) -> Any: ...
def addaudithook(hook: Callable[[str, tuple[Any, ...]], Any]) -> None: ...
def audit(__event: str, *args: Any) -> None: ...
_AsyncgenHook: TypeAlias = Callable[[AsyncGenerator[Any, Any]], None] | None
@final
class _asyncgen_hooks(structseq[_AsyncgenHook], tuple[_AsyncgenHook, _AsyncgenHook]):
@property
def firstiter(self) -> _AsyncgenHook: ...
@property
def finalizer(self) -> _AsyncgenHook: ...
def get_asyncgen_hooks() -> _asyncgen_hooks: ...
def set_asyncgen_hooks(firstiter: _AsyncgenHook = ..., finalizer: _AsyncgenHook = ...) -> None: ...
if sys.platform == "win32":
def _enablelegacywindowsfsencoding() -> None: ...
def get_coroutine_origin_tracking_depth() -> int: ...
def set_coroutine_origin_tracking_depth(depth: int) -> None: ...
if sys.version_info < (3, 8):
_CoroWrapper: TypeAlias = Callable[[Coroutine[Any, Any, Any]], Any]
def set_coroutine_wrapper(__wrapper: _CoroWrapper) -> None: ...
def get_coroutine_wrapper() -> _CoroWrapper: ...
# The following two functions were added in 3.11.0, 3.10.7, 3.9.14, 3.8.14, & 3.7.14,
# as part of the response to CVE-2020-10735
def set_int_max_str_digits(maxdigits: int) -> None: ...
def get_int_max_str_digits() -> int: ...
# MicroPython specific functions
# Copyright (c) 2023 Jos Verlinde
from typing import Optional
from _typeshed import Incomplete
def atexit(func:Optional[Callable[[],Any]]) -> Optional[Callable[[],Any]]:
"""\
Register func to be called upon termination. func must be a callable that takes no arguments,
or None to disable the call. The atexit function will return the previous value set by this function,
which is initially None.
Ports: Unix, Windows
"""
...
def print_exception(exc, file=sys.stdout, /):
"""Print exception with a traceback to a file-like object file (or sys.stdout by default)."""
...

631
.vscode/Pico-W-Stub/stdlib/types.pyi vendored Normal file
View File

@@ -0,0 +1,631 @@
import sys
from collections.abc import (
AsyncGenerator,
Awaitable,
Callable,
Coroutine,
Generator,
ItemsView,
Iterable,
Iterator,
KeysView,
MutableSequence,
ValuesView,
)
from importlib.machinery import ModuleSpec # type: ignore
# pytype crashes if types.MappingProxyType inherits from collections.abc.Mapping instead of typing.Mapping
from typing import Any, ClassVar, Generic, Mapping, Protocol, TypeVar, overload # noqa: Y027
from _typeshed import SupportsKeysAndGetItem
from typing_extensions import Literal, ParamSpec, final
__all__ = [
"FunctionType",
"LambdaType",
"CodeType",
"MappingProxyType",
"SimpleNamespace",
"GeneratorType",
"CoroutineType",
"AsyncGeneratorType",
"MethodType",
"BuiltinFunctionType",
"ModuleType",
"TracebackType",
"FrameType",
"GetSetDescriptorType",
"MemberDescriptorType",
"new_class",
"prepare_class",
"DynamicClassAttribute",
"coroutine",
"BuiltinMethodType",
"ClassMethodDescriptorType",
"MethodDescriptorType",
"MethodWrapperType",
"WrapperDescriptorType",
"resolve_bases",
]
if sys.version_info >= (3, 8):
__all__ += ["CellType"]
if sys.version_info >= (3, 9):
__all__ += ["GenericAlias"]
if sys.version_info >= (3, 10):
__all__ += ["EllipsisType", "NoneType", "NotImplementedType", "UnionType"]
# Note, all classes "defined" here require special handling.
_T1 = TypeVar("_T1")
_T2 = TypeVar("_T2")
_T_co = TypeVar("_T_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
_KT = TypeVar("_KT")
_VT_co = TypeVar("_VT_co", covariant=True)
_V_co = TypeVar("_V_co", covariant=True)
@final
class _Cell:
__hash__: ClassVar[None] # type: ignore[assignment]
cell_contents: Any
# Make sure this class definition stays roughly in line with `builtins.function`
@final
class FunctionType:
@property
def __closure__(self) -> tuple[_Cell, ...] | None: ...
__code__: CodeType
__defaults__: tuple[Any, ...] | None
__dict__: dict[str, Any]
@property
def __globals__(self) -> dict[str, Any]: ...
__name__: str
__qualname__: str
__annotations__: dict[str, Any]
__kwdefaults__: dict[str, Any]
if sys.version_info >= (3, 10):
@property
def __builtins__(self) -> dict[str, Any]: ...
__module__: str
def __init__(
self,
code: CodeType,
globals: dict[str, Any],
name: str | None = ...,
argdefs: tuple[object, ...] | None = ...,
closure: tuple[_Cell, ...] | None = ...,
) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
@overload
def __get__(self, obj: None, type: type) -> FunctionType: ...
@overload
def __get__(self, obj: object, type: type | None = ...) -> MethodType: ...
LambdaType = FunctionType
@final
class CodeType:
@property
def co_argcount(self) -> int: ...
if sys.version_info >= (3, 8):
@property
def co_posonlyargcount(self) -> int: ...
@property
def co_kwonlyargcount(self) -> int: ...
@property
def co_nlocals(self) -> int: ...
@property
def co_stacksize(self) -> int: ...
@property
def co_flags(self) -> int: ...
@property
def co_code(self) -> bytes: ...
@property
def co_consts(self) -> tuple[Any, ...]: ...
@property
def co_names(self) -> tuple[str, ...]: ...
@property
def co_varnames(self) -> tuple[str, ...]: ...
@property
def co_filename(self) -> str: ...
@property
def co_name(self) -> str: ...
@property
def co_firstlineno(self) -> int: ...
@property
def co_lnotab(self) -> bytes: ...
@property
def co_freevars(self) -> tuple[str, ...]: ...
@property
def co_cellvars(self) -> tuple[str, ...]: ...
if sys.version_info >= (3, 10):
@property
def co_linetable(self) -> bytes: ...
def co_lines(self) -> Iterator[tuple[int, int, int | None]]: ...
if sys.version_info >= (3, 11):
@property
def co_exceptiontable(self) -> bytes: ...
@property
def co_qualname(self) -> str: ...
def co_positions(
self,
) -> Iterable[tuple[int | None, int | None, int | None, int | None]]: ...
if sys.version_info >= (3, 11):
def __init__(
self,
__argcount: int,
__posonlyargcount: int,
__kwonlyargcount: int,
__nlocals: int,
__stacksize: int,
__flags: int,
__codestring: bytes,
__constants: tuple[object, ...],
__names: tuple[str, ...],
__varnames: tuple[str, ...],
__filename: str,
__name: str,
__qualname: str,
__firstlineno: int,
__linetable: bytes,
__exceptiontable: bytes,
__freevars: tuple[str, ...] = ...,
__cellvars: tuple[str, ...] = ...,
) -> None: ...
elif sys.version_info >= (3, 10):
def __init__(
self,
__argcount: int,
__posonlyargcount: int,
__kwonlyargcount: int,
__nlocals: int,
__stacksize: int,
__flags: int,
__codestring: bytes,
__constants: tuple[object, ...],
__names: tuple[str, ...],
__varnames: tuple[str, ...],
__filename: str,
__name: str,
__firstlineno: int,
__linetable: bytes,
__freevars: tuple[str, ...] = ...,
__cellvars: tuple[str, ...] = ...,
) -> None: ...
elif sys.version_info >= (3, 8):
def __init__(
self,
__argcount: int,
__posonlyargcount: int,
__kwonlyargcount: int,
__nlocals: int,
__stacksize: int,
__flags: int,
__codestring: bytes,
__constants: tuple[object, ...],
__names: tuple[str, ...],
__varnames: tuple[str, ...],
__filename: str,
__name: str,
__firstlineno: int,
__lnotab: bytes,
__freevars: tuple[str, ...] = ...,
__cellvars: tuple[str, ...] = ...,
) -> None: ...
else:
def __init__(
self,
__argcount: int,
__kwonlyargcount: int,
__nlocals: int,
__stacksize: int,
__flags: int,
__codestring: bytes,
__constants: tuple[object, ...],
__names: tuple[str, ...],
__varnames: tuple[str, ...],
__filename: str,
__name: str,
__firstlineno: int,
__lnotab: bytes,
__freevars: tuple[str, ...] = ...,
__cellvars: tuple[str, ...] = ...,
) -> None: ...
if sys.version_info >= (3, 11):
def replace(
self,
*,
co_argcount: int = ...,
co_posonlyargcount: int = ...,
co_kwonlyargcount: int = ...,
co_nlocals: int = ...,
co_stacksize: int = ...,
co_flags: int = ...,
co_firstlineno: int = ...,
co_code: bytes = ...,
co_consts: tuple[object, ...] = ...,
co_names: tuple[str, ...] = ...,
co_varnames: tuple[str, ...] = ...,
co_freevars: tuple[str, ...] = ...,
co_cellvars: tuple[str, ...] = ...,
co_filename: str = ...,
co_name: str = ...,
co_qualname: str = ...,
co_linetable: bytes = ...,
co_exceptiontable: bytes = ...,
) -> CodeType: ...
elif sys.version_info >= (3, 10):
def replace(
self,
*,
co_argcount: int = ...,
co_posonlyargcount: int = ...,
co_kwonlyargcount: int = ...,
co_nlocals: int = ...,
co_stacksize: int = ...,
co_flags: int = ...,
co_firstlineno: int = ...,
co_code: bytes = ...,
co_consts: tuple[object, ...] = ...,
co_names: tuple[str, ...] = ...,
co_varnames: tuple[str, ...] = ...,
co_freevars: tuple[str, ...] = ...,
co_cellvars: tuple[str, ...] = ...,
co_filename: str = ...,
co_name: str = ...,
co_linetable: bytes = ...,
) -> CodeType: ...
elif sys.version_info >= (3, 8):
def replace(
self,
*,
co_argcount: int = ...,
co_posonlyargcount: int = ...,
co_kwonlyargcount: int = ...,
co_nlocals: int = ...,
co_stacksize: int = ...,
co_flags: int = ...,
co_firstlineno: int = ...,
co_code: bytes = ...,
co_consts: tuple[object, ...] = ...,
co_names: tuple[str, ...] = ...,
co_varnames: tuple[str, ...] = ...,
co_freevars: tuple[str, ...] = ...,
co_cellvars: tuple[str, ...] = ...,
co_filename: str = ...,
co_name: str = ...,
co_lnotab: bytes = ...,
) -> CodeType: ...
@final
class MappingProxyType(Mapping[_KT, _VT_co], Generic[_KT, _VT_co]):
__hash__: ClassVar[None] # type: ignore[assignment]
def __init__(self, mapping: SupportsKeysAndGetItem[_KT, _VT_co]) -> None: ...
def __getitem__(self, __key: _KT) -> _VT_co: ...
def __iter__(self) -> Iterator[_KT]: ...
def __len__(self) -> int: ...
def copy(self) -> dict[_KT, _VT_co]: ...
def keys(self) -> KeysView[_KT]: ...
def values(self) -> ValuesView[_VT_co]: ...
def items(self) -> ItemsView[_KT, _VT_co]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
def __reversed__(self) -> Iterator[_KT]: ...
def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT_co | _T2]: ...
def __ror__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT_co | _T2]: ...
class SimpleNamespace:
__hash__: ClassVar[None] # type: ignore[assignment]
def __init__(self, **kwargs: Any) -> None: ...
def __getattribute__(self, __name: str) -> Any: ...
def __setattr__(self, __name: str, __value: Any) -> None: ...
def __delattr__(self, __name: str) -> None: ...
class _LoaderProtocol(Protocol):
def load_module(self, fullname: str) -> ModuleType: ...
class ModuleType:
__name__: str
__file__: str | None
@property
def __dict__(self) -> dict[str, Any]: ... # type: ignore[override]
__loader__: _LoaderProtocol | None
__package__: str | None
__path__: MutableSequence[str]
__spec__: ModuleSpec | None
def __init__(self, name: str, doc: str | None = ...) -> None: ...
# __getattr__ doesn't exist at runtime,
# but having it here in typeshed makes dynamic imports
# using `builtins.__import__` or `importlib.import_module` less painful
def __getattr__(self, name: str) -> Any: ...
@final
class GeneratorType(Generator[_T_co, _T_contra, _V_co]):
@property
def gi_yieldfrom(self) -> GeneratorType[_T_co, _T_contra, Any] | None: ...
if sys.version_info >= (3, 11):
@property
def gi_suspended(self) -> bool: ...
__name__: str
__qualname__: str
def __iter__(self) -> GeneratorType[_T_co, _T_contra, _V_co]: ...
def __next__(self) -> _T_co: ...
def send(self, __arg: _T_contra) -> _T_co: ...
@overload
def throw(
self,
__typ: type[BaseException],
__val: BaseException | object = ...,
__tb: TracebackType | None = ...,
) -> _T_co: ...
@overload
def throw(
self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
@final
class AsyncGeneratorType(AsyncGenerator[_T_co, _T_contra]):
@property
def ag_await(self) -> Awaitable[Any] | None: ...
__name__: str
__qualname__: str
def __aiter__(self) -> AsyncGeneratorType[_T_co, _T_contra]: ...
def __anext__(self) -> Coroutine[Any, Any, _T_co]: ...
def asend(self, __val: _T_contra) -> Coroutine[Any, Any, _T_co]: ...
@overload
async def athrow(
self,
__typ: type[BaseException],
__val: BaseException | object = ...,
__tb: TracebackType | None = ...,
) -> _T_co: ...
@overload
async def athrow(
self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
def aclose(self) -> Coroutine[Any, Any, None]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
@final
class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]):
__name__: str
__qualname__: str
@property
def cr_origin(self) -> tuple[tuple[str, int, str], ...] | None: ...
if sys.version_info >= (3, 11):
@property
def cr_suspended(self) -> bool: ...
def close(self) -> None: ...
def __await__(self) -> Generator[Any, None, _V_co]: ...
def send(self, __arg: _T_contra) -> _T_co: ...
@overload
def throw(
self,
__typ: type[BaseException],
__val: BaseException | object = ...,
__tb: TracebackType | None = ...,
) -> _T_co: ...
@overload
def throw(
self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
class _StaticFunctionType:
# Fictional type to correct the type of MethodType.__func__.
# FunctionType is a descriptor, so mypy follows the descriptor protocol and
# converts MethodType.__func__ back to MethodType (the return type of
# FunctionType.__get__). But this is actually a special case; MethodType is
# implemented in C and its attribute access doesn't go through
# __getattribute__.
# By wrapping FunctionType in _StaticFunctionType, we get the right result;
# similar to wrapping a function in staticmethod() at runtime to prevent it
# being bound as a method.
def __get__(self, obj: object | None, type: type | None) -> FunctionType: ...
@final
class MethodType:
@property
def __closure__(self) -> tuple[_Cell, ...] | None: ... # inherited from the added function
@property
def __defaults__(self) -> tuple[Any, ...] | None: ... # inherited from the added function
@property
def __func__(self) -> _StaticFunctionType: ...
@property
def __self__(self) -> object: ...
@property
def __name__(self) -> str: ... # inherited from the added function
@property
def __qualname__(self) -> str: ... # inherited from the added function
def __init__(self, __func: Callable[..., Any], __obj: object) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
@final
class BuiltinFunctionType:
@property
def __self__(self) -> object | ModuleType: ...
@property
def __name__(self) -> str: ...
@property
def __qualname__(self) -> str: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
BuiltinMethodType = BuiltinFunctionType
@final
class WrapperDescriptorType:
@property
def __name__(self) -> str: ...
@property
def __qualname__(self) -> str: ...
@property
def __objclass__(self) -> type: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __get__(self, __obj: Any, __type: type = ...) -> Any: ...
@final
class MethodWrapperType:
@property
def __self__(self) -> object: ...
@property
def __name__(self) -> str: ...
@property
def __qualname__(self) -> str: ...
@property
def __objclass__(self) -> type: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __eq__(self, __other: object) -> bool: ...
def __ne__(self, __other: object) -> bool: ...
@final
class MethodDescriptorType:
@property
def __name__(self) -> str: ...
@property
def __qualname__(self) -> str: ...
@property
def __objclass__(self) -> type: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __get__(self, obj: Any, type: type = ...) -> Any: ...
@final
class ClassMethodDescriptorType:
@property
def __name__(self) -> str: ...
@property
def __qualname__(self) -> str: ...
@property
def __objclass__(self) -> type: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def __get__(self, obj: Any, type: type = ...) -> Any: ...
@final
class TracebackType:
def __init__(
self, tb_next: TracebackType | None, tb_frame: FrameType, tb_lasti: int, tb_lineno: int
) -> None: ...
tb_next: TracebackType | None
# the rest are read-only even in 3.7
@property
def tb_frame(self) -> FrameType: ...
@property
def tb_lasti(self) -> int: ...
@property
def tb_lineno(self) -> int: ...
@final
class FrameType:
@property
def f_back(self) -> FrameType | None: ...
@property
def f_builtins(self) -> dict[str, Any]: ...
@property
def f_code(self) -> CodeType: ...
@property
def f_globals(self) -> dict[str, Any]: ...
@property
def f_lasti(self) -> int: ...
# see discussion in #6769: f_lineno *can* sometimes be None,
# but you should probably file a bug report with CPython if you encounter it being None in the wild.
# An `int | None` annotation here causes too many false-positive errors.
@property
def f_lineno(self) -> int | Any: ...
@property
def f_locals(self) -> dict[str, Any]: ...
f_trace: Callable[[FrameType, str, Any], Any] | None
f_trace_lines: bool
f_trace_opcodes: bool
def clear(self) -> None: ...
@final
class GetSetDescriptorType:
@property
def __name__(self) -> str: ...
@property
def __qualname__(self) -> str: ...
@property
def __objclass__(self) -> type: ...
def __get__(self, __obj: Any, __type: type = ...) -> Any: ...
def __set__(self, __instance: Any, __value: Any) -> None: ...
def __delete__(self, __obj: Any) -> None: ...
@final
class MemberDescriptorType:
@property
def __name__(self) -> str: ...
@property
def __qualname__(self) -> str: ...
@property
def __objclass__(self) -> type: ...
def __get__(self, __obj: Any, __type: type = ...) -> Any: ...
def __set__(self, __instance: Any, __value: Any) -> None: ...
def __delete__(self, __obj: Any) -> None: ...
def new_class(
name: str,
bases: Iterable[object] = ...,
kwds: dict[str, Any] | None = ...,
exec_body: Callable[[dict[str, Any]], object] | None = ...,
) -> type: ...
def resolve_bases(bases: Iterable[object]) -> tuple[Any, ...]: ...
def prepare_class(
name: str, bases: tuple[type, ...] = ..., kwds: dict[str, Any] | None = ...
) -> tuple[type, dict[str, Any], dict[str, Any]]: ...
# Actually a different type, but `property` is special and we want that too.
DynamicClassAttribute = property
_Fn = TypeVar("_Fn", bound=Callable[..., object])
_R = TypeVar("_R")
_P = ParamSpec("_P")
# it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable
# The type: ignore is due to overlapping overloads, not the use of ParamSpec
@overload
def coroutine(func: Callable[_P, Generator[_R, Any, Any]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore[misc]
@overload
def coroutine(func: _Fn) -> _Fn: ...
if sys.version_info >= (3, 8):
CellType = _Cell
if sys.version_info >= (3, 9):
class GenericAlias:
@property
def __origin__(self) -> type: ...
@property
def __args__(self) -> tuple[Any, ...]: ...
@property
def __parameters__(self) -> tuple[Any, ...]: ...
def __init__(self, origin: type, args: Any) -> None: ...
def __getitem__(self, __typeargs: Any) -> GenericAlias: ...
if sys.version_info >= (3, 11):
@property
def __unpacked__(self) -> bool: ...
@property
def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ...
# GenericAlias delegates attr access to `__origin__`
def __getattr__(self, name: str) -> Any: ...
if sys.version_info >= (3, 10):
@final
class NoneType:
def __bool__(self) -> Literal[False]: ...
EllipsisType = ellipsis # noqa: F821 from builtins
from builtins import _NotImplementedType
NotImplementedType = _NotImplementedType
@final
class UnionType:
@property
def __args__(self) -> tuple[Any, ...]: ...
def __or__(self, __obj: Any) -> UnionType: ...
def __ror__(self, __obj: Any) -> UnionType: ...

840
.vscode/Pico-W-Stub/stdlib/typing.pyi vendored Normal file
View File

@@ -0,0 +1,840 @@
import _typeshed
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
import sys
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import IdentityFunction, Incomplete, SupportsKeysAndGetItem
from abc import ABCMeta, abstractmethod
from contextlib import AbstractAsyncContextManager, AbstractContextManager
from re import Match as Match, Pattern as Pattern
from types import (
BuiltinFunctionType,
CodeType,
FrameType,
FunctionType,
MethodDescriptorType,
MethodType,
MethodWrapperType,
ModuleType,
TracebackType,
WrapperDescriptorType,
)
from typing_extensions import Never as _Never, ParamSpec as _ParamSpec, final as _final
__all__ = [
"AbstractSet",
"Any",
"AnyStr",
"AsyncContextManager",
"AsyncGenerator",
"AsyncIterable",
"AsyncIterator",
"Awaitable",
"ByteString",
"Callable",
"ChainMap",
"ClassVar",
"Collection",
"Container",
"ContextManager",
"Coroutine",
"Counter",
"DefaultDict",
"Deque",
"Dict",
"FrozenSet",
"Generator",
"Generic",
"Hashable",
"ItemsView",
"Iterable",
"Iterator",
"KeysView",
"List",
"Mapping",
"MappingView",
"MutableMapping",
"MutableSequence",
"MutableSet",
"NamedTuple",
"NewType",
"Optional",
"Reversible",
"Sequence",
"Set",
"Sized",
"SupportsAbs",
"SupportsBytes",
"SupportsComplex",
"SupportsFloat",
"SupportsInt",
"SupportsRound",
"Text",
"Tuple",
"Type",
"TypeVar",
"Union",
"ValuesView",
"TYPE_CHECKING",
"cast",
"get_type_hints",
"no_type_check",
"no_type_check_decorator",
"overload",
"ForwardRef",
"NoReturn",
"OrderedDict",
]
if sys.version_info >= (3, 8):
__all__ += [
"Final",
"Literal",
"Protocol",
"SupportsIndex",
"TypedDict",
"final",
"get_args",
"get_origin",
"runtime_checkable",
]
if sys.version_info >= (3, 9):
__all__ += ["Annotated", "BinaryIO", "IO", "Match", "Pattern", "TextIO"]
if sys.version_info >= (3, 10):
__all__ += ["Concatenate", "ParamSpec", "ParamSpecArgs", "ParamSpecKwargs", "TypeAlias", "TypeGuard", "is_typeddict"]
if sys.version_info >= (3, 11):
__all__ += [
"LiteralString",
"Never",
"NotRequired",
"Required",
"Self",
"TypeVarTuple",
"Unpack",
"assert_never",
"assert_type",
"clear_overloads",
"dataclass_transform",
"get_overloads",
"reveal_type",
]
ContextManager = AbstractContextManager
AsyncContextManager = AbstractAsyncContextManager
# This itself is only available during type checking
def type_check_only(func_or_cls: _F) -> _F: ...
Any = object()
@_final
class TypeVar:
__name__: str
__bound__: Any | None
__constraints__: tuple[Any, ...]
__covariant__: bool
__contravariant__: bool
def __init__(
self, name: str, *constraints: Any, bound: Any | None = ..., covariant: bool = ..., contravariant: bool = ...
) -> None: ...
if sys.version_info >= (3, 10):
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Incomplete) -> Incomplete: ...
# Used for an undocumented mypy feature. Does not exist at runtime.
_promote = object()
# N.B. Keep this definition in sync with typing_extensions._SpecialForm
@_final
class _SpecialForm:
def __getitem__(self, parameters: Any) -> object: ...
if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
_F = TypeVar("_F", bound=Callable[..., Any])
_P = _ParamSpec("_P")
_T = TypeVar("_T")
def overload(func: _F) -> _F: ...
# Unlike the vast majority module-level objects in stub files,
# these `_SpecialForm` objects in typing need the default value `= ...`,
# due to the fact that they are used elswhere in the same file.
# Otherwise, flake8 erroneously flags them as undefined.
# `_SpecialForm` objects in typing.py that are not used elswhere in the same file
# do not need the default value assignment.
Union: _SpecialForm = ...
Generic: _SpecialForm = ...
# Protocol is only present in 3.8 and later, but mypy needs it unconditionally
Protocol: _SpecialForm = ...
Callable: _SpecialForm = ...
Type: _SpecialForm = ...
NoReturn: _SpecialForm = ...
ClassVar: _SpecialForm = ...
Optional: _SpecialForm
Tuple: _SpecialForm
if sys.version_info >= (3, 8):
Final: _SpecialForm
def final(f: _T) -> _T: ...
Literal: _SpecialForm
# TypedDict is a (non-subscriptable) special form.
TypedDict: object
if sys.version_info >= (3, 11):
Self: _SpecialForm
Never: _SpecialForm = ...
Unpack: _SpecialForm
Required: _SpecialForm
NotRequired: _SpecialForm
LiteralString: _SpecialForm
class TypeVarTuple:
__name__: str
def __init__(self, name: str) -> None: ...
def __iter__(self) -> Any: ...
def __typing_subst__(self, arg: Never) -> Never: ...
def __typing_prepare_subst__(self, alias: Incomplete, args: Incomplete) -> Incomplete: ...
if sys.version_info >= (3, 10):
class ParamSpecArgs:
__origin__: ParamSpec
def __init__(self, origin: ParamSpec) -> None: ...
class ParamSpecKwargs:
__origin__: ParamSpec
def __init__(self, origin: ParamSpec) -> None: ...
class ParamSpec:
__name__: str
__bound__: Any | None
__covariant__: bool
__contravariant__: bool
def __init__(self, name: str, *, bound: Any | None = ..., contravariant: bool = ..., covariant: bool = ...) -> None: ...
@property
def args(self) -> ParamSpecArgs: ...
@property
def kwargs(self) -> ParamSpecKwargs: ...
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Incomplete) -> Incomplete: ...
def __typing_prepare_subst__(self, alias: Incomplete, args: Incomplete) -> Incomplete: ...
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
Concatenate: _SpecialForm
TypeAlias: _SpecialForm
TypeGuard: _SpecialForm
class NewType:
def __init__(self, name: str, tp: Any) -> None: ...
def __call__(self, x: _T) -> _T: ...
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
__supertype__: type
else:
def NewType(name: str, tp: Any) -> Any: ...
# These type variables are used by the container types.
_S = TypeVar("_S")
_KT = TypeVar("_KT") # Key type.
_VT = TypeVar("_VT") # Value type.
_T_co = TypeVar("_T_co", covariant=True) # Any type covariant containers.
_V_co = TypeVar("_V_co", covariant=True) # Any type covariant containers.
_KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
_T_contra = TypeVar("_T_contra", contravariant=True) # Ditto contravariant.
_TC = TypeVar("_TC", bound=Type[object])
def no_type_check(arg: _F) -> _F: ...
def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ... # type: ignore[misc]
# Type aliases and type constructors
class _Alias:
# Class for defining generic aliases for library types.
def __getitem__(self, typeargs: Any) -> Any: ...
List = _Alias()
Dict = _Alias()
DefaultDict = _Alias()
Set = _Alias()
FrozenSet = _Alias()
Counter = _Alias()
Deque = _Alias()
ChainMap = _Alias()
OrderedDict = _Alias()
if sys.version_info >= (3, 9):
Annotated: _SpecialForm
# Predefined type variables.
AnyStr = TypeVar("AnyStr", str, bytes) # noqa: Y001
# Technically in 3.7 this inherited from GenericMeta. But let's not reflect that, since
# type checkers tend to assume that Protocols all have the ABCMeta metaclass.
class _ProtocolMeta(ABCMeta): ...
# Abstract base classes.
def runtime_checkable(cls: _TC) -> _TC: ...
@runtime_checkable
class SupportsInt(Protocol, metaclass=ABCMeta):
@abstractmethod
def __int__(self) -> int: ...
@runtime_checkable
class SupportsFloat(Protocol, metaclass=ABCMeta):
@abstractmethod
def __float__(self) -> float: ...
@runtime_checkable
class SupportsComplex(Protocol, metaclass=ABCMeta):
@abstractmethod
def __complex__(self) -> complex: ...
@runtime_checkable
class SupportsBytes(Protocol, metaclass=ABCMeta):
@abstractmethod
def __bytes__(self) -> bytes: ...
if sys.version_info >= (3, 8):
@runtime_checkable
class SupportsIndex(Protocol, metaclass=ABCMeta):
@abstractmethod
def __index__(self) -> int: ...
@runtime_checkable
class SupportsAbs(Protocol[_T_co]):
@abstractmethod
def __abs__(self) -> _T_co: ...
@runtime_checkable
class SupportsRound(Protocol[_T_co]):
@overload
@abstractmethod
def __round__(self) -> int: ...
@overload
@abstractmethod
def __round__(self, __ndigits: int) -> _T_co: ...
@runtime_checkable
class Sized(Protocol):
@abstractmethod
def __len__(self) -> int: ...
@runtime_checkable
class Hashable(Protocol, metaclass=ABCMeta):
# TODO: This is special, in that a subclass of a hashable class may not be hashable
# (for example, list vs. object). It's not obvious how to represent this. This class
# is currently mostly useless for static checking.
@abstractmethod
def __hash__(self) -> int: ...
@runtime_checkable
class Iterable(Protocol[_T_co]):
@abstractmethod
def __iter__(self) -> Iterator[_T_co]: ...
@runtime_checkable
class Iterator(Iterable[_T_co], Protocol[_T_co]):
@abstractmethod
def __next__(self) -> _T_co: ...
def __iter__(self) -> Iterator[_T_co]: ...
@runtime_checkable
class Reversible(Iterable[_T_co], Protocol[_T_co]):
@abstractmethod
def __reversed__(self) -> Iterator[_T_co]: ...
class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
def __next__(self) -> _T_co: ...
@abstractmethod
def send(self, __value: _T_contra) -> _T_co: ...
@overload
@abstractmethod
def throw(
self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
@overload
@abstractmethod
def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
def close(self) -> None: ...
def __iter__(self) -> Generator[_T_co, _T_contra, _V_co]: ...
@property
def gi_code(self) -> CodeType: ...
@property
def gi_frame(self) -> FrameType: ...
@property
def gi_running(self) -> bool: ...
@property
def gi_yieldfrom(self) -> Generator[Any, Any, Any] | None: ...
@runtime_checkable
class Awaitable(Protocol[_T_co]):
@abstractmethod
def __await__(self) -> Generator[Any, None, _T_co]: ...
class Coroutine(Awaitable[_V_co], Generic[_T_co, _T_contra, _V_co]):
__name__: str
__qualname__: str
@property
def cr_await(self) -> Any | None: ...
@property
def cr_code(self) -> CodeType: ...
@property
def cr_frame(self) -> FrameType: ...
@property
def cr_running(self) -> bool: ...
@abstractmethod
def send(self, __value: _T_contra) -> _T_co: ...
@overload
@abstractmethod
def throw(
self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> _T_co: ...
@overload
@abstractmethod
def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ...
@abstractmethod
def close(self) -> None: ...
# NOTE: This type does not exist in typing.py or PEP 484 but mypy needs it to exist.
# The parameters correspond to Generator, but the 4th is the original type.
@type_check_only
class AwaitableGenerator(
Awaitable[_V_co], Generator[_T_co, _T_contra, _V_co], Generic[_T_co, _T_contra, _V_co, _S], metaclass=ABCMeta
): ...
@runtime_checkable
class AsyncIterable(Protocol[_T_co]):
@abstractmethod
def __aiter__(self) -> AsyncIterator[_T_co]: ...
@runtime_checkable
class AsyncIterator(AsyncIterable[_T_co], Protocol[_T_co]):
@abstractmethod
def __anext__(self) -> Awaitable[_T_co]: ...
def __aiter__(self) -> AsyncIterator[_T_co]: ...
class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]):
def __anext__(self) -> Awaitable[_T_co]: ...
@abstractmethod
def asend(self, __value: _T_contra) -> Awaitable[_T_co]: ...
@overload
@abstractmethod
def athrow(
self, __typ: Type[BaseException], __val: BaseException | object = ..., __tb: TracebackType | None = ...
) -> Awaitable[_T_co]: ...
@overload
@abstractmethod
def athrow(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> Awaitable[_T_co]: ...
def aclose(self) -> Awaitable[None]: ...
@property
def ag_await(self) -> Any: ...
@property
def ag_code(self) -> CodeType: ...
@property
def ag_frame(self) -> FrameType: ...
@property
def ag_running(self) -> bool: ...
@runtime_checkable
class Container(Protocol[_T_co]):
# This is generic more on vibes than anything else
@abstractmethod
def __contains__(self, __x: object) -> bool: ...
@runtime_checkable
class Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co]): ...
class Sequence(Collection[_T_co], Reversible[_T_co], Generic[_T_co]):
@overload
@abstractmethod
def __getitem__(self, index: int) -> _T_co: ...
@overload
@abstractmethod
def __getitem__(self, index: slice) -> Sequence[_T_co]: ...
# Mixin methods
def index(self, value: Any, start: int = ..., stop: int = ...) -> int: ...
def count(self, value: Any) -> int: ...
def __contains__(self, value: object) -> bool: ...
def __iter__(self) -> Iterator[_T_co]: ...
def __reversed__(self) -> Iterator[_T_co]: ...
class MutableSequence(Sequence[_T], Generic[_T]):
@abstractmethod
def insert(self, index: int, value: _T) -> None: ...
@overload
@abstractmethod
def __getitem__(self, index: int) -> _T: ...
@overload
@abstractmethod
def __getitem__(self, index: slice) -> MutableSequence[_T]: ...
@overload
@abstractmethod
def __setitem__(self, index: int, value: _T) -> None: ...
@overload
@abstractmethod
def __setitem__(self, index: slice, value: Iterable[_T]) -> None: ...
@overload
@abstractmethod
def __delitem__(self, index: int) -> None: ...
@overload
@abstractmethod
def __delitem__(self, index: slice) -> None: ...
# Mixin methods
def append(self, value: _T) -> None: ...
def clear(self) -> None: ...
def extend(self, values: Iterable[_T]) -> None: ...
def reverse(self) -> None: ...
def pop(self, index: int = ...) -> _T: ...
def remove(self, value: _T) -> None: ...
def __iadd__(self: _typeshed.Self, values: Iterable[_T]) -> _typeshed.Self: ...
class AbstractSet(Collection[_T_co], Generic[_T_co]):
@abstractmethod
def __contains__(self, x: object) -> bool: ...
def _hash(self) -> int: ...
# Mixin methods
def __le__(self, other: AbstractSet[Any]) -> bool: ...
def __lt__(self, other: AbstractSet[Any]) -> bool: ...
def __gt__(self, other: AbstractSet[Any]) -> bool: ...
def __ge__(self, other: AbstractSet[Any]) -> bool: ...
def __and__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
def __or__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
def __sub__(self, other: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
def __xor__(self, other: AbstractSet[_T]) -> AbstractSet[_T_co | _T]: ...
def isdisjoint(self, other: Iterable[Any]) -> bool: ...
class MutableSet(AbstractSet[_T], Generic[_T]):
@abstractmethod
def add(self, value: _T) -> None: ...
@abstractmethod
def discard(self, value: _T) -> None: ...
# Mixin methods
def clear(self) -> None: ...
def pop(self) -> _T: ...
def remove(self, value: _T) -> None: ...
def __ior__(self: _typeshed.Self, it: AbstractSet[_T]) -> _typeshed.Self: ... # type: ignore[override,misc]
def __iand__(self: _typeshed.Self, it: AbstractSet[Any]) -> _typeshed.Self: ...
def __ixor__(self: _typeshed.Self, it: AbstractSet[_T]) -> _typeshed.Self: ... # type: ignore[override,misc]
def __isub__(self: _typeshed.Self, it: AbstractSet[Any]) -> _typeshed.Self: ...
class MappingView(Sized):
def __init__(self, mapping: Mapping[Any, Any]) -> None: ... # undocumented
def __len__(self) -> int: ...
class ItemsView(MappingView, AbstractSet[tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __and__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
def __contains__(self, item: object) -> bool: ...
def __iter__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[tuple[_KT_co, _VT_co]]: ...
def __or__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __ror__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __sub__(self, other: Iterable[Any]) -> set[tuple[_KT_co, _VT_co]]: ...
def __rsub__(self, other: Iterable[_T]) -> set[_T]: ...
def __xor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
def __rxor__(self, other: Iterable[_T]) -> set[tuple[_KT_co, _VT_co] | _T]: ...
class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented
def __and__(self, other: Iterable[Any]) -> set[_KT_co]: ...
def __rand__(self, other: Iterable[_T]) -> set[_T]: ...
def __contains__(self, key: object) -> bool: ...
def __iter__(self) -> Iterator[_KT_co]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_KT_co]: ...
def __or__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
def __ror__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
def __sub__(self, other: Iterable[Any]) -> set[_KT_co]: ...
def __rsub__(self, other: Iterable[_T]) -> set[_T]: ...
def __xor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
def __rxor__(self, other: Iterable[_T]) -> set[_KT_co | _T]: ...
class ValuesView(MappingView, Collection[_VT_co], Generic[_VT_co]):
def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented
def __contains__(self, value: object) -> bool: ...
def __iter__(self) -> Iterator[_VT_co]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_VT_co]: ...
class Mapping(Collection[_KT], Generic[_KT, _VT_co]):
# TODO: We wish the key type could also be covariant, but that doesn't work,
# see discussion in https://github.com/python/typing/pull/273.
@abstractmethod
def __getitem__(self, __key: _KT) -> _VT_co: ...
# Mixin methods
@overload
def get(self, __key: _KT) -> _VT_co | None: ...
@overload
def get(self, __key: _KT, default: _VT_co | _T) -> _VT_co | _T: ...
def items(self) -> ItemsView[_KT, _VT_co]: ...
def keys(self) -> KeysView[_KT]: ...
def values(self) -> ValuesView[_VT_co]: ...
def __contains__(self, __o: object) -> bool: ...
class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):
@abstractmethod
def __setitem__(self, __key: _KT, __value: _VT) -> None: ...
@abstractmethod
def __delitem__(self, __key: _KT) -> None: ...
def clear(self) -> None: ...
@overload
def pop(self, __key: _KT) -> _VT: ...
@overload
def pop(self, __key: _KT, default: _VT | _T) -> _VT | _T: ...
def popitem(self) -> tuple[_KT, _VT]: ...
# This overload should be allowed only if the value type is compatible with None.
# Keep OrderedDict.setdefault in line with MutableMapping.setdefault, modulo positional-only differences.
@overload
def setdefault(self: MutableMapping[_KT, _T | None], __key: _KT) -> _T | None: ...
@overload
def setdefault(self, __key: _KT, __default: _VT) -> _VT: ...
# 'update' used to take a Union, but using overloading is better.
# The second overloaded type here is a bit too general, because
# Mapping[tuple[_KT, _VT], W] is a subclass of Iterable[tuple[_KT, _VT]],
# but will always have the behavior of the first overloaded type
# at runtime, leading to keys of a mix of types _KT and tuple[_KT, _VT].
# We don't currently have any way of forcing all Mappings to use
# the first overload, but by using overloading rather than a Union,
# mypy will commit to using the first overload when the argument is
# known to be a Mapping with unknown type parameters, which is closer
# to the behavior we want. See mypy issue #1430.
#
# Various mapping classes have __ior__ methods that should be kept roughly in line with .update():
# -- dict.__ior__
# -- os._Environ.__ior__
# -- collections.UserDict.__ior__
# -- collections.ChainMap.__ior__
# -- peewee.attrdict.__add__
# -- peewee.attrdict.__iadd__
# -- weakref.WeakValueDictionary.__ior__
# -- weakref.WeakKeyDictionary.__ior__
@overload
def update(self, __m: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def update(self, __m: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
@overload
def update(self, **kwargs: _VT) -> None: ...
Text = str
TYPE_CHECKING: bool
# In stubs, the arguments of the IO class are marked as positional-only.
# This differs from runtime, but better reflects the fact that in reality
# classes deriving from IO use different names for the arguments.
class IO(Iterator[AnyStr], Generic[AnyStr]):
# At runtime these are all abstract properties,
# but making them abstract in the stub is hugely disruptive, for not much gain.
# See #8726
@property
def mode(self) -> str: ...
@property
def name(self) -> str: ...
@abstractmethod
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
@abstractmethod
def fileno(self) -> int: ...
@abstractmethod
def flush(self) -> None: ...
@abstractmethod
def isatty(self) -> bool: ...
@abstractmethod
def read(self, __n: int = ...) -> AnyStr: ...
@abstractmethod
def readable(self) -> bool: ...
@abstractmethod
def readline(self, __limit: int = ...) -> AnyStr: ...
@abstractmethod
def readlines(self, __hint: int = ...) -> list[AnyStr]: ...
@abstractmethod
def seek(self, __offset: int, __whence: int = ...) -> int: ...
@abstractmethod
def seekable(self) -> bool: ...
@abstractmethod
def tell(self) -> int: ...
@abstractmethod
def truncate(self, __size: int | None = ...) -> int: ...
@abstractmethod
def writable(self) -> bool: ...
@abstractmethod
def write(self, __s: AnyStr) -> int: ...
@abstractmethod
def writelines(self, __lines: Iterable[AnyStr]) -> None: ...
@abstractmethod
def __next__(self) -> AnyStr: ...
@abstractmethod
def __iter__(self) -> Iterator[AnyStr]: ...
@abstractmethod
def __enter__(self) -> IO[AnyStr]: ...
@abstractmethod
def __exit__(
self, __t: Type[BaseException] | None, __value: BaseException | None, __traceback: TracebackType | None
) -> None: ...
class BinaryIO(IO[bytes]):
@abstractmethod
def __enter__(self) -> BinaryIO: ...
class TextIO(IO[str]):
# See comment regarding the @properties in the `IO` class
@property
def buffer(self) -> BinaryIO: ...
@property
def encoding(self) -> str: ...
@property
def errors(self) -> str | None: ...
@property
def line_buffering(self) -> int: ... # int on PyPy, bool on CPython
@property
def newlines(self) -> Any: ... # None, str or tuple
@abstractmethod
def __enter__(self) -> TextIO: ...
class ByteString(Sequence[int], metaclass=ABCMeta): ...
# Functions
_get_type_hints_obj_allowed_types = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
object
| Callable[..., Any]
| FunctionType
| BuiltinFunctionType
| MethodType
| ModuleType
| WrapperDescriptorType
| MethodWrapperType
| MethodDescriptorType
)
if sys.version_info >= (3, 9):
def get_type_hints(
obj: _get_type_hints_obj_allowed_types,
globalns: dict[str, Any] | None = ...,
localns: dict[str, Any] | None = ...,
include_extras: bool = ...,
) -> dict[str, Any]: ...
else:
def get_type_hints(
obj: _get_type_hints_obj_allowed_types, globalns: dict[str, Any] | None = ..., localns: dict[str, Any] | None = ...
) -> dict[str, Any]: ...
if sys.version_info >= (3, 8):
def get_origin(tp: Any) -> Any | None: ...
def get_args(tp: Any) -> tuple[Any, ...]: ...
@overload
def cast(typ: Type[_T], val: Any) -> _T: ...
@overload
def cast(typ: str, val: Any) -> Any: ...
@overload
def cast(typ: object, val: Any) -> Any: ...
if sys.version_info >= (3, 11):
def reveal_type(__obj: _T) -> _T: ...
def assert_never(__arg: Never) -> Never: ...
def assert_type(__val: _T, __typ: Any) -> _T: ...
def clear_overloads() -> None: ...
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...
def dataclass_transform(
*,
eq_default: bool = ...,
order_default: bool = ...,
kw_only_default: bool = ...,
field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = ...,
**kwargs: Any,
) -> IdentityFunction: ...
# Type constructors
class NamedTuple(tuple[Any, ...]):
if sys.version_info < (3, 8):
_field_types: collections.OrderedDict[str, type]
elif sys.version_info < (3, 9):
_field_types: dict[str, type]
_field_defaults: dict[str, Any]
_fields: tuple[str, ...]
_source: str
@overload
def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ...
@overload
def __init__(self, typename: str, fields: None = ..., **kwargs: Any) -> None: ...
@classmethod
def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ...
if sys.version_info >= (3, 8):
def _asdict(self) -> dict[str, Any]: ...
else:
def _asdict(self) -> collections.OrderedDict[str, Any]: ...
def _replace(self: _typeshed.Self, **kwargs: Any) -> _typeshed.Self: ...
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
# N.B. Keep this mostly in sync with typing_extensions._TypedDict/mypy_extensions._TypedDict
@type_check_only
class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
__total__: ClassVar[bool]
if sys.version_info >= (3, 9):
__required_keys__: ClassVar[frozenset[str]]
__optional_keys__: ClassVar[frozenset[str]]
def copy(self: _typeshed.Self) -> _typeshed.Self: ...
# Using Never so that only calls using mypy plugin hook that specialize the signature
# can go through.
def setdefault(self, k: _Never, default: object) -> object: ...
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: _Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
def update(self: _T, __m: _T) -> None: ...
def __delitem__(self, k: _Never) -> None: ...
def items(self) -> dict_items[str, object]: ...
def keys(self) -> dict_keys[str, object]: ...
def values(self) -> dict_values[str, object]: ...
if sys.version_info >= (3, 9):
def __or__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ...
def __ior__(self: _typeshed.Self, __value: _typeshed.Self) -> _typeshed.Self: ...
@_final
class ForwardRef:
__forward_arg__: str
__forward_code__: CodeType
__forward_evaluated__: bool
__forward_value__: Any | None
__forward_is_argument__: bool
__forward_is_class__: bool
__forward_module__: Any | None
if sys.version_info >= (3, 9):
# The module and is_class arguments were added in later Python 3.9 versions.
def __init__(self, arg: str, is_argument: bool = ..., module: Any | None = ..., *, is_class: bool = ...) -> None: ...
else:
def __init__(self, arg: str, is_argument: bool = ...) -> None: ...
if sys.version_info >= (3, 9):
def _evaluate(
self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None, recursive_guard: frozenset[str]
) -> Any | None: ...
else:
def _evaluate(self, globalns: dict[str, Any] | None, localns: dict[str, Any] | None) -> Any | None: ...
def __eq__(self, other: object) -> bool: ...
if sys.version_info >= (3, 11):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 10):
def is_typeddict(tp: object) -> bool: ...
def _type_repr(obj: object) -> str: ...

View File

@@ -0,0 +1,495 @@
import abc
import collections
import sys
import typing
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import IdentityFunction, Incomplete
from typing import ( # noqa: Y022,Y037,Y038,Y039
IO as IO,
TYPE_CHECKING as TYPE_CHECKING,
AbstractSet as AbstractSet,
Any as Any,
AnyStr as AnyStr,
AsyncContextManager as AsyncContextManager,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
BinaryIO as BinaryIO,
Callable as Callable,
ChainMap as ChainMap,
ClassVar as ClassVar,
Collection as Collection,
Container as Container,
ContextManager as ContextManager,
Coroutine as Coroutine,
Counter as Counter,
DefaultDict as DefaultDict,
Deque as Deque,
Dict as Dict,
ForwardRef as ForwardRef,
FrozenSet as FrozenSet,
Generator as Generator,
Generic as Generic,
Hashable as Hashable,
ItemsView as ItemsView,
Iterable as Iterable,
Iterator as Iterator,
KeysView as KeysView,
List as List,
Mapping as Mapping,
MappingView as MappingView,
Match as Match,
MutableMapping as MutableMapping,
MutableSequence as MutableSequence,
MutableSet as MutableSet,
NoReturn as NoReturn,
Optional as Optional,
Pattern as Pattern,
Reversible as Reversible,
Sequence as Sequence,
Set as Set,
Sized as Sized,
SupportsAbs as SupportsAbs,
SupportsBytes as SupportsBytes,
SupportsComplex as SupportsComplex,
SupportsFloat as SupportsFloat,
SupportsInt as SupportsInt,
SupportsRound as SupportsRound,
Text as Text,
TextIO as TextIO,
Tuple as Tuple,
Type as Type,
Union as Union,
ValuesView as ValuesView,
_Alias,
cast as cast,
no_type_check as no_type_check,
no_type_check_decorator as no_type_check_decorator,
overload as overload,
type_check_only,
)
if sys.version_info >= (3, 10):
from types import UnionType
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [
"Any",
"Buffer",
"ClassVar",
"Concatenate",
"Final",
"LiteralString",
"ParamSpec",
"ParamSpecArgs",
"ParamSpecKwargs",
"Self",
"Type",
"TypeVar",
"TypeVarTuple",
"Unpack",
"Awaitable",
"AsyncIterator",
"AsyncIterable",
"Coroutine",
"AsyncGenerator",
"AsyncContextManager",
"ChainMap",
"ContextManager",
"Counter",
"Deque",
"DefaultDict",
"NamedTuple",
"OrderedDict",
"TypedDict",
"SupportsIndex",
"SupportsAbs",
"SupportsRound",
"SupportsBytes",
"SupportsComplex",
"SupportsFloat",
"SupportsInt",
"Annotated",
"assert_never",
"assert_type",
"dataclass_transform",
"deprecated",
"final",
"IntVar",
"is_typeddict",
"Literal",
"NewType",
"overload",
"override",
"Protocol",
"reveal_type",
"runtime",
"runtime_checkable",
"Text",
"TypeAlias",
"TypeAliasType",
"TypeGuard",
"TYPE_CHECKING",
"Never",
"NoReturn",
"Required",
"NotRequired",
"clear_overloads",
"get_args",
"get_origin",
"get_original_bases",
"get_overloads",
"get_type_hints",
"AbstractSet",
"AnyStr",
"BinaryIO",
"Callable",
"Collection",
"Container",
"Dict",
"ForwardRef",
"FrozenSet",
"Generator",
"Generic",
"Hashable",
"IO",
"ItemsView",
"Iterable",
"Iterator",
"KeysView",
"List",
"Mapping",
"MappingView",
"Match",
"MutableMapping",
"MutableSequence",
"MutableSet",
"Optional",
"Pattern",
"Reversible",
"Sequence",
"Set",
"Sized",
"TextIO",
"Tuple",
"Union",
"ValuesView",
"cast",
"get_protocol_members",
"is_protocol",
"no_type_check",
"no_type_check_decorator",
]
_T = typing.TypeVar("_T")
_F = typing.TypeVar("_F", bound=Callable[..., Any])
_TC = typing.TypeVar("_TC", bound=type[object])
# unfortunately we have to duplicate this class definition from typing.pyi or we break pytype
class _SpecialForm:
def __getitem__(self, parameters: Any) -> object: ...
if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
# Do not import (and re-export) Protocol or runtime_checkable from
# typing module because type checkers need to be able to distinguish
# typing.Protocol and typing_extensions.Protocol so they can properly
# warn users about potential runtime exceptions when using typing.Protocol
# on older versions of Python.
Protocol: _SpecialForm
def runtime_checkable(cls: _TC) -> _TC: ...
# This alias for above is kept here for backwards compatibility.
runtime = runtime_checkable
Final: _SpecialForm
def final(f: _F) -> _F: ...
Literal: _SpecialForm
def IntVar(name: str) -> Any: ... # returns a new TypeVar
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
# N.B. Keep this mostly in sync with typing._TypedDict/mypy_extensions._TypedDict
@type_check_only
class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
__required_keys__: ClassVar[frozenset[str]]
__optional_keys__: ClassVar[frozenset[str]]
__total__: ClassVar[bool]
__orig_bases__: ClassVar[tuple[Any, ...]]
def copy(self) -> Self: ...
# Using Never so that only calls using mypy plugin hook that specialize the signature
# can go through.
def setdefault(self, k: Never, default: object) -> object: ...
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: Never, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
def update(self: _T, __m: _T) -> None: ...
def items(self) -> dict_items[str, object]: ...
def keys(self) -> dict_keys[str, object]: ...
def values(self) -> dict_values[str, object]: ...
def __delitem__(self, k: Never) -> None: ...
if sys.version_info >= (3, 9):
@overload
def __or__(self, __value: Self) -> Self: ...
@overload
def __or__(self, __value: dict[str, Any]) -> dict[str, object]: ...
@overload
def __ror__(self, __value: Self) -> Self: ...
@overload
def __ror__(self, __value: dict[str, Any]) -> dict[str, object]: ...
# supposedly incompatible definitions of `__ior__` and `__or__`:
def __ior__(self, __value: Self) -> Self: ... # type: ignore[misc]
# TypedDict is a (non-subscriptable) special form.
TypedDict: object
OrderedDict = _Alias()
def get_type_hints(
obj: Callable[..., Any],
globalns: dict[str, Any] | None = None,
localns: dict[str, Any] | None = None,
include_extras: bool = False,
) -> dict[str, Any]: ...
def get_args(tp: Any) -> tuple[Any, ...]: ...
if sys.version_info >= (3, 10):
@overload
def get_origin(tp: UnionType) -> type[UnionType]: ...
if sys.version_info >= (3, 9):
@overload
def get_origin(tp: GenericAlias) -> type: ...
@overload
def get_origin(tp: ParamSpecArgs | ParamSpecKwargs) -> ParamSpec: ...
@overload
def get_origin(tp: Any) -> Any | None: ...
Annotated: _SpecialForm
_AnnotatedAlias: Any # undocumented
@runtime_checkable
class SupportsIndex(Protocol, metaclass=abc.ABCMeta):
@abc.abstractmethod
def __index__(self) -> int: ...
# New and changed things in 3.10
if sys.version_info >= (3, 10):
from typing import (
Concatenate as Concatenate,
NewType as NewType,
ParamSpecArgs as ParamSpecArgs,
ParamSpecKwargs as ParamSpecKwargs,
TypeAlias as TypeAlias,
TypeGuard as TypeGuard,
is_typeddict as is_typeddict,
)
else:
@final
class ParamSpecArgs:
@property
def __origin__(self) -> ParamSpec: ...
def __init__(self, origin: ParamSpec) -> None: ...
@final
class ParamSpecKwargs:
@property
def __origin__(self) -> ParamSpec: ...
def __init__(self, origin: ParamSpec) -> None: ...
Concatenate: _SpecialForm
TypeAlias: _SpecialForm
TypeGuard: _SpecialForm
def is_typeddict(tp: object) -> bool: ...
class NewType:
def __init__(self, name: str, tp: Any) -> None: ...
def __call__(self, __x: _T) -> _T: ...
__supertype__: type
# New things in 3.11
# NamedTuples are not new, but the ability to create generic NamedTuples is new in 3.11
if sys.version_info >= (3, 11):
from typing import (
LiteralString as LiteralString,
NamedTuple as NamedTuple,
Never as Never,
NotRequired as NotRequired,
Required as Required,
Self as Self,
Unpack as Unpack,
assert_never as assert_never,
assert_type as assert_type,
clear_overloads as clear_overloads,
dataclass_transform as dataclass_transform,
get_overloads as get_overloads,
reveal_type as reveal_type,
)
else:
Self: _SpecialForm
Never: _SpecialForm
def reveal_type(__obj: _T) -> _T: ...
def assert_never(__arg: Never) -> Never: ...
def assert_type(__val: _T, __typ: Any) -> _T: ...
def clear_overloads() -> None: ...
def get_overloads(func: Callable[..., object]) -> Sequence[Callable[..., object]]: ...
Required: _SpecialForm
NotRequired: _SpecialForm
LiteralString: _SpecialForm
Unpack: _SpecialForm
def dataclass_transform(
*,
eq_default: bool = True,
order_default: bool = False,
kw_only_default: bool = False,
frozen_default: bool = False,
field_specifiers: tuple[type[Any] | Callable[..., Any], ...] = (),
**kwargs: object,
) -> IdentityFunction: ...
class NamedTuple(tuple[Any, ...]):
if sys.version_info < (3, 8):
_field_types: ClassVar[collections.OrderedDict[str, type]]
elif sys.version_info < (3, 9):
_field_types: ClassVar[dict[str, type]]
_field_defaults: ClassVar[dict[str, Any]]
_fields: ClassVar[tuple[str, ...]]
__orig_bases__: ClassVar[tuple[Any, ...]]
@overload
def __init__(self, typename: str, fields: Iterable[tuple[str, Any]] = ...) -> None: ...
@overload
def __init__(self, typename: str, fields: None = None, **kwargs: Any) -> None: ...
@classmethod
def _make(cls, iterable: Iterable[Any]) -> Self: ...
if sys.version_info >= (3, 8):
def _asdict(self) -> dict[str, Any]: ...
else:
def _asdict(self) -> collections.OrderedDict[str, Any]: ...
def _replace(self, **kwargs: Any) -> Self: ...
# New things in 3.xx
# The `default` parameter was added to TypeVar, ParamSpec, and TypeVarTuple (PEP 696)
# The `infer_variance` parameter was added to TypeVar in 3.12 (PEP 695)
# typing_extensions.override (PEP 698)
@final
class TypeVar:
@property
def __name__(self) -> str: ...
@property
def __bound__(self) -> Any | None: ...
@property
def __constraints__(self) -> tuple[Any, ...]: ...
@property
def __covariant__(self) -> bool: ...
@property
def __contravariant__(self) -> bool: ...
@property
def __infer_variance__(self) -> bool: ...
@property
def __default__(self) -> Any | None: ...
def __init__(
self,
name: str,
*constraints: Any,
bound: Any | None = None,
covariant: bool = False,
contravariant: bool = False,
default: Any | None = None,
infer_variance: bool = False,
) -> None: ...
if sys.version_info >= (3, 10):
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
if sys.version_info >= (3, 11):
def __typing_subst__(self, arg: Incomplete) -> Incomplete: ...
@final
class ParamSpec:
@property
def __name__(self) -> str: ...
@property
def __bound__(self) -> Any | None: ...
@property
def __covariant__(self) -> bool: ...
@property
def __contravariant__(self) -> bool: ...
@property
def __infer_variance__(self) -> bool: ...
@property
def __default__(self) -> Any | None: ...
def __init__(
self,
name: str,
*,
bound: None | type[Any] | str = None,
contravariant: bool = False,
covariant: bool = False,
default: type[Any] | str | None = None,
) -> None: ...
@property
def args(self) -> ParamSpecArgs: ...
@property
def kwargs(self) -> ParamSpecKwargs: ...
@final
class TypeVarTuple:
@property
def __name__(self) -> str: ...
@property
def __default__(self) -> Any | None: ...
def __init__(self, name: str, *, default: Any | None = None) -> None: ...
def __iter__(self) -> Any: ... # Unpack[Self]
def deprecated(__msg: str, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> Callable[[_T], _T]: ...
if sys.version_info >= (3, 12):
from collections.abc import Buffer as Buffer
from types import get_original_bases as get_original_bases
from typing import TypeAliasType as TypeAliasType, override as override
else:
def override(__arg: _F) -> _F: ...
def get_original_bases(__cls: type) -> tuple[Any, ...]: ...
@final
class TypeAliasType:
def __init__(
self, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ()
) -> None: ...
@property
def __value__(self) -> Any: ...
@property
def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ...
@property
def __parameters__(self) -> tuple[Any, ...]: ...
@property
def __name__(self) -> str: ...
# It's writable on types, but not on instances of TypeAliasType.
@property
def __module__(self) -> str | None: ... # type: ignore[override]
def __getitem__(self, parameters: Any) -> Any: ...
if sys.version_info >= (3, 10):
def __or__(self, right: Any) -> _SpecialForm: ...
def __ror__(self, left: Any) -> _SpecialForm: ...
@runtime_checkable
class Buffer(Protocol):
# Not actually a Protocol at runtime; see
# https://github.com/python/typeshed/issues/10224 for why we're defining it this way
def __buffer__(self, __flags: int) -> memoryview: ...
if sys.version_info >= (3, 13):
from typing import get_protocol_members as get_protocol_members, is_protocol as is_protocol
else:
def is_protocol(__tp: type) -> bool: ...
def get_protocol_members(__tp: type) -> frozenset[str]: ...
# PEP 705
ReadOnly: _SpecialForm