修复了指针运算,指针 getitem 的问题
Validation / Typecheck (push) Has been cancelled
Validation / Style (push) Has been cancelled
Validation / Test macos-latest (push) Has been cancelled
Validation / Test ubuntu-latest (push) Has been cancelled
Validation / Test windows-latest (push) Has been cancelled
Validation / Build (push) Has been cancelled
Validation / Required (push) Has been cancelled

This commit is contained in:
TermiNexus committed 2026-08-03 00:36:54 +08:00
1 parent 0be56b39ae
commit e094caeccd
716 files changed
+441 -60874

No files matched your search

@@ -711,25 +711,6 @@ export class Checker extends ParseTreeWalker {
}
}
// If we're at the module level within a stub file, report a diagnostic
// if there is a '__getattr__' function defined when in strict mode.
// This signifies an incomplete stub file that obscures type errors.
// Viper has no module-level __getattr__ semantics, so skip this check.
if (
!IsViperDialect(this._fileInfo.executionEnvironment.dialect) &&
this._fileInfo.isStubFile &&
node.d.name.d.value === '__getattr__'
) {
const scope = getScopeForNode(node);
if (scope?.type === ScopeType.Module) {
this._evaluator.addDiagnostic(
DiagnosticRule.reportIncompleteStub,
LocMessage.stubUsesGetAttr(),
node.d.name
);
}
}
this._scopedNodes.push(node);
if (
@@ -1559,22 +1540,9 @@ export class Checker extends ParseTreeWalker {
this._evaluator.evaluateTypesForStatement(node);
const importInfo = AnalyzerNodeInfo.getImportInfo(node.d.module);
if (
importInfo &&
importInfo.isImportFound &&
importInfo.importType !== ImportType.Local &&
!this._fileInfo.isStubFile &&
// Viper 模式:`from stdint import *` 是常见用法(导入 C 类型别名),
// 不报告 wildcard import 警告
!IsViperDialect(this._fileInfo.executionEnvironment.dialect)
) {
this._evaluator.addDiagnosticForTextRange(
this._fileInfo,
DiagnosticRule.reportWildcardImportFromLibrary,
LocMessage.wildcardLibraryImport(),
node.d.wildcardToken || node
);
}
// Viper 模式:`from stdint import *` 是常见用法(导入 C 类型别名),
// 不报告 wildcard import 警告。
void importInfo;
}
return true;
@@ -4989,20 +4957,9 @@ export class Checker extends ParseTreeWalker {
// Enum members should not have type annotations.
// Viper 扩展:CEnum 子类允许类型注解成员(如 FR_OK: t.State = 0),
// 跳过此错误报告。
// 不报告类型注解错误。
const typedDecls = symbol.getTypedDeclarations();
if (typedDecls.length > 0) {
if (
!IsViperDialect(this._fileInfo.executionEnvironment.dialect) &&
typedDecls[0].type === DeclarationType.Variable &&
typedDecls[0].inferredTypeSource
) {
this._evaluator.addDiagnostic(
DiagnosticRule.reportGeneralTypeIssues,
LocMessage.enumMemberTypeAnnotation(),
typedDecls[0].node
);
}
return;
}
@@ -5024,7 +4981,7 @@ export class Checker extends ParseTreeWalker {
// Look for an enum attribute annotated with "Final".
// Viper 扩展:CEnum 子类允许类型注解成员,跳过 Final 注解错误。
if (decls[0].isFinal && !IsViperDialect(this._fileInfo.executionEnvironment.dialect)) {
if (decls[0].isFinal) {
this._evaluator.addDiagnostic(
DiagnosticRule.reportGeneralTypeIssues,
LocMessage.enumMemberTypeAnnotation(),
@@ -55,6 +55,7 @@ import {
getTypeVarArgsRecursive,
getTypeVarScopeId,
getTypeVarScopeIds,
isNoneInstance,
isTupleClass,
lookUpClassMember,
mapSubtypes,
@@ -284,10 +285,21 @@ function validateNewAndInitMethods(
newMethodReturnType = newCallResult.returnType;
}
if (!newMethodReturnType || isDefaultNewMethod(newMethodTypeResult?.type)) {
if (
!newMethodReturnType ||
isNoneInstance(newMethodReturnType) ||
isDefaultNewMethod(newMethodTypeResult?.type)
) {
// If there is no __new__ method or it uses a default signature,
// (cls, *args, **kwargs) -> Self, allow the __init__ method to
// determine the specialized type of the class.
//
// Viper 扩展:Viper 中类的 `__new__` 无返回注解时(如 `_list.vp` 的
// `def __new__(self, pool, elem_size=0)` 返回 `pool.alloc(...)` 裸指针),
// typeEvaluator 会把返回类型推断为 None。但 Viper 是 C++ 式语义,
// 构造调用 `list[str](pool)` 必须返回类实例(list[str])而非 None。
// 因此 __new__ 返回 None 时同样回退到类实例类型,保证
// `result = list[str](self.__mbuddy__)` 后 `result.append(...)` 可用。
newMethodReturnType = ClassType.cloneAsInstance(type);
} else if (isUnknown(newMethodReturnType) || (newMethodTypeResult && isAny(newMethodTypeResult.type))) {
// If the __new__ method returns Unknown, we'll ignore its return
@@ -10,7 +10,7 @@
import { appendArray, flatten, getMapValues, getOrAdd } from '../common/collectionUtils';
import { ConfigOptions, ExecutionEnvironment, matchFileSpecs } from '../common/configOptions';
import { IsPythonDialect, IsViperDialect } from '../common/dialect';
import { IsViperDialect } from '../common/dialect';
import { Host } from '../common/host';
import { stubsSuffix } from '../common/pathConsts';
import { getFileExtension, stripFileExtension } from '../common/pathUtils';
@@ -1498,46 +1498,6 @@ export class ImportResolver {
) {
isNativeLib = true;
importLogger?.log(`Did not find file '${pyiFilePath}' or '${pyFilePath}'`);
} else if (
!allowPyi &&
allowNativeLib &&
isLastPart &&
IsPythonDialect(execEnv.dialect) &&
this.fileExistsCached(dirPath.addExtension('.pyc'))
) {
// Sourceless distribution: a compiled `.pyc` module sits where the `.py`
// source would be (e.g. `mod.pyc` beside `mod.pyi`, with no `mod.py`) -- placed
// directly in the package directory, not under `__pycache__`. Python imports
// such a `.pyc` directly, so the module exists at runtime even though it has no
// Python source.
//
// Viper 模式短路:Viper 无 `.pyc` 字节码缓存(AOT 编译型语言),
// 通过 `IsPythonDialect(execEnv.dialect)` 跳过此分支。
//
// This branch only runs during the non-stub resolution (`allowPyi === false`),
// whose result becomes `nonStubImportResult`. Pushing the `.pyc` onto
// `resolvedPaths` makes that non-stub result report `isImportFound === true`,
// and the checker's `_addMissingModuleSourceDiagnosticIfNeeded` short-circuits
// on `nonStubImportResult.isImportFound` -- so the misleading
// `reportMissingModuleSource` warning is suppressed via the `isImportFound`
// path (not via `isNativeLib`, whose check the checker never reaches once
// `isImportFound` is true).
//
// Gating mirrors the native-lib branch above: a compiled module is a native
// artifact with no Python source, so it is only recognized where native libs are
// allowed (`allowNativeLib`), ensuring a stray `.pyc` in a stub-only root is not
// mistaken for the real module. `isNativeLib = true` is set purely for symmetry
// with that branch; it does not drive the suppression here. The `.pyc` is
// likewise kept out of `getSourceFilesFromStub` by that method's `.py`/`.pyi`
// extension filter, independent of `isNativeLib`.
//
// The `.pyc` Uri is built inside this branch's guard (rather than unconditionally
// alongside `pyFilePath`/`pyiFilePath`) so the allocation only happens for the
// rare last-part library imports that fall through to here.
const pycFilePath = dirPath.addExtension('.pyc');
importLogger?.log(`Resolved import with compiled file '${pycFilePath}'`);
resolvedPaths.push(pycFilePath);
isNativeLib = true;
} else if (foundDirectory) {
if (!isLastPart) {
// We are not at the last part, and we found a directory,
@@ -396,13 +396,9 @@ export function getTypeOfBinaryOperation(
if ((flags & EvalFlags.TypeExpression) !== 0) {
// Exempt "|" because it might be a union operation involving unknowns.
// Viper 扩展:Viper 是 AOT 静态语言,类型表达式中的算术/位运算用于编译时常量
// (如 t.CArray[T, MAX_ORDER + 1] 的数组长度),放行不报 binaryOperationNotAllowed,
// 让其继续按常量表达式求值。
if (
node.d.operator !== OperatorType.BitwiseOr &&
!IsViperDialect(getFileInfo(node).executionEnvironment.dialect)
) {
// Viper 是 AOT 静态语言,类型表达式中的算术/位运算用于编译时常量
// (如 t.CArray[T, MAX_ORDER + 1] 的数组长度),放行不报 binaryOperationNotAllowed。
if (node.d.operator !== OperatorType.BitwiseOr) {
evaluator.addDiagnostic(DiagnosticRule.reportInvalidTypeForm, LocMessage.binaryOperationNotAllowed(), node);
return { type: UnknownType.create() };
}
@@ -579,6 +575,20 @@ export function getTypeOfAugmentedAssignment(
}
}
// Viper 扩展:str/bytes 指针增强赋值(C 指针算术)。
// Viper 中 str/bytes 是 i8* 指针,`dest += 1`(指针递增)是合法的
// C 指针算术,结果类型保持 str/bytes。Python 中 str 不可变故无此语义。
// 仅当运算符为 + 且右操作数是整数时生效。
if (IsViperDialect(getFileInfo(node).executionEnvironment.dialect)) {
const leftIsStrBytes = isClassInstance(leftSubtypeUnexpanded) &&
ClassType.isBuiltIn(leftSubtypeUnexpanded, ['str', 'bytes']);
const rightIsInt = isClassInstance(rightSubtypeUnexpanded) &&
ClassType.isBuiltIn(rightSubtypeUnexpanded, 'int');
if (leftIsStrBytes && rightIsInt) {
return leftSubtypeUnexpanded;
}
}
let returnTypeResult = evaluator.getTypeOfMagicMethodCall(
leftSubtypeUnexpanded,
magicMethodName,
@@ -929,43 +939,9 @@ function createUnionType(
newUnion = TypeBase.cloneWithTypeForm(newUnion, newTypeForm);
}
// Check for "stringified" forward reference type expressions. The "|" operator
// doesn't support these except in certain circumstances. Notably, it can't be used
// with other strings or with types that are not specialized using an index form.
// Viper 扩展:跳过此检查。Viper 中 `'ClassName' | t.CPtr` 是合法的 TypeSet 语法,
// Viper 扩展:跳过 stringified forward reference 检查。
// Viper 中 `'ClassName' | t.CPtr` 是合法的 TypeSet 语法,
// 表示"指向 ClassName 的指针"(前向引用字符串 + CPtr 组合)。
if (!fileInfo.isStubFile && !IsViperDialect(fileInfo.executionEnvironment.dialect)) {
let stringNode: ExpressionNode | undefined;
let otherNode: ExpressionNode | undefined;
let otherType: Type | undefined;
if (leftExpression.nodeType === ParseNodeType.StringList) {
stringNode = leftExpression;
otherNode = rightExpression;
otherType = rightTypeResult.type;
} else if (rightExpression.nodeType === ParseNodeType.StringList) {
stringNode = rightExpression;
otherNode = leftExpression;
otherType = leftTypeResult.type;
}
if (stringNode && otherNode && otherType) {
let isAllowed = true;
if (isClass(otherType)) {
if (!otherType.priv.isTypeArgExplicit || isClassInstance(otherType)) {
isAllowed = false;
}
}
if (!isAllowed) {
evaluator.addDiagnostic(
DiagnosticRule.reportGeneralTypeIssues,
LocMessage.unionForwardReferenceNotAllowed(),
stringNode
);
}
}
}
return { type: newUnion };
}
@@ -1419,6 +1395,35 @@ function validateArithmeticOperation(
}
}
// Viper 扩展:str/bytes 指针算术(C 指针算术)。
// Viper 中 str/bytes 是 i8* 指针:
// - `ptr + n`(指针偏移):一方是 str/bytes、另一方是 int → 结果保持 str/bytes
// - `ptr - ptr`(指针差):双方都是 str/bytes → 结果为 t.CSizeT(ptrdiff_t)
// - `ptr - n`(指针回退):str/bytes - int → 结果保持 str/bytes
if (isViperDialect && (operator === OperatorType.Add || operator === OperatorType.Subtract)) {
const leftIsStrBytes = isClassInstance(leftSubtypeExpanded) &&
ClassType.isBuiltIn(leftSubtypeExpanded, ['str', 'bytes']);
const rightIsStrBytes = isClassInstance(rightSubtypeExpanded) &&
ClassType.isBuiltIn(rightSubtypeExpanded, ['str', 'bytes']);
const leftIsInt = isClassInstance(leftSubtypeExpanded) &&
ClassType.isBuiltIn(leftSubtypeExpanded, 'int');
const rightIsInt = isClassInstance(rightSubtypeExpanded) &&
ClassType.isBuiltIn(rightSubtypeExpanded, 'int');
if (operator === OperatorType.Add) {
if ((leftIsStrBytes && rightIsInt) || (leftIsInt && rightIsStrBytes)) {
// 返回指针类型(str/bytes)
return leftIsStrBytes ? leftSubtypeExpanded : rightSubtypeExpanded;
}
} else if (leftIsStrBytes && rightIsStrBytes) {
// 指针差:str - str → int(t.CSizeT 的底层类型,元素数量)
// t.CSizeT 是 CType 子类,赋值给 t.CSizeT 声明时通过隐式转换兼容。
return evaluator.getBuiltInObject(errorNode, 'int');
} else if (leftIsStrBytes && rightIsInt) {
// 指针回退:str - n → str
return leftSubtypeExpanded;
}
}
// Viper 扩展:整数除法返回 int(C 语义)。
// Python 中 / (.__truediv__) 对两个 int 返回 float,
// 但 C 语言中整数 / 整数 返回整数(截断除法)。
@@ -855,7 +855,7 @@ export function getEvaluationNodeForAssignmentExpression(
function isInClassMemberTypeAnnotation(node: ParseNode): boolean {
let curNode: ParseNode | undefined = node;
while (curNode) {
const parent = curNode.parent;
const parent: ParseNode | undefined = curNode.parent;
if (
parent?.nodeType === ParseNodeType.TypeAnnotation &&
parent.d.annotation === curNode
@@ -895,7 +895,7 @@ function isInClassMethodSignatureAnnotation(node: ParseNode): boolean {
// Walk up to find whether the node lives within a parameter annotation or
// a function return annotation.
while (curNode) {
const parent = curNode.parent;
const parent: ParseNode | undefined = curNode.parent;
if (parent?.nodeType === ParseNodeType.Parameter && parent.d.annotation === curNode) {
// Parameter annotation: the enclosing function is the parameter's parent.
funcNode = parent.parent ?? undefined;
@@ -3266,9 +3266,14 @@ export function createTypeEvaluator(
}
return UnknownType.create(isIncomplete);
}
// Viper 扩展:str 类型迭代返回 int(CChar)。
// Viper 语义:str = bytes | CPtr(const char*),迭代返回单个字符 CChar = int。
if (ClassType.isBuiltIn(subtype, 'str')) {
// Viper 扩展:str/bytes 类型迭代返回 t.CChar(字符)。
// Viper 语义:str/bytes = i8* 指针(const char*),迭代返回单个字符 CChar。
// 使用 getViperCCharType 而非裸 int,保持与 s[i] 下标访问一致(t.CChar 显示)。
if (ClassType.isBuiltIn(subtype, ['str', 'bytes'])) {
const ccharType = getViperCCharType(errorNode);
if (ccharType) {
return ccharType;
}
return getBuiltInObject(errorNode, 'int');
}
// 检查联合类型中是否包含 CPtr
@@ -5093,6 +5098,41 @@ export function createTypeEvaluator(
// scope, there's no need to use code flow analysis.
if (symbolWithScope.scope.type === ScopeType.Builtin) {
useCodeFlowAnalysis = false;
// Viper 扩展:模拟编译器的自动 import 机制。
// Viper 编译器的 Phase2 会自动检测 list/dict 容器的使用并注入
// `import _list` / `import _dict`(见 TransPyC Phase2Translator._inject_auto_imports),
// 因此用户源码无需手写 import。
// LSP 若不模拟此机制,裸名 list/dict 会解析到 Python builtins 的
// `list.__init__(iterable: Iterable[_T])`,把内存分配器实参(如
// memhub.MemBuddy)当作可迭代对象检查而误报。
// 这里在解析到 builtin 的 list/dict 时,尝试用 includes 中的
// _list.vp / _dict.vp 真实定义替换(容器构造签名是
// `__init__(self, pool: memhub.MemManager | t.CPtr, ...)`)。
const viperBuiltinModule =
IsViperDialect(fileInfo.executionEnvironment.dialect) &&
(name === 'list' || name === 'dict')
? (name === 'list' ? '_list' : '_dict')
: undefined;
if (viperBuiltinModule) {
const lookupResult = importLookup({
nameParts: [viperBuiltinModule],
importingFileUri: fileInfo.fileUri,
});
if (lookupResult) {
const containerSymbol = lookupResult.symbolTable.get(name);
if (containerSymbol) {
symbolWithScope = {
symbol: containerSymbol,
isOutsideCallerModule: false,
isBeyondExecutionScope: false,
usesNonlocalBinding: false,
usesGlobalBinding: false,
scope: symbolWithScope.scope,
};
}
}
}
}
symbol = symbolWithScope.symbol;
@@ -5281,14 +5321,6 @@ export function createTypeEvaluator(
// Viper 是 AOT 语言,结构体/函数不在乎定义顺序(类似 C 语言的前向声明)。
// 当符号未找到时(可能在更后方定义),不报 undefinedVariable 错误,
// 而是返回 UnknownType,允许后续定义的符号被引用。
if (!IsViperDialect(fileInfo.executionEnvironment.dialect)) {
addDiagnostic(
DiagnosticRule.reportUndefinedVariable,
LocMessage.symbolIsUndefined().format({ name }),
node
);
}
type = UnknownType.create();
}
}
@@ -6412,30 +6444,7 @@ export function createTypeEvaluator(
);
}
} else {
// Does the module export a top-level __getattr__ function?
// Viper has no module-level __getattr__ (PEP 562) semantics,
// so skip this dynamic attribute resolution entirely.
if (usage.method === 'get' && !IsViperDialect(fileInfo.executionEnvironment.dialect)) {
const getAttrSymbol = ModuleType.getField(baseType, '__getattr__');
if (getAttrSymbol) {
const isModuleGetAttrSupported =
PythonVersion.isGreaterOrEqualTo(
fileInfo.executionEnvironment.pythonVersion,
pythonVersion3_7
) || getAttrSymbol.getDeclarations().some((decl) => decl.uri.hasExtension('.vpi'));
if (isModuleGetAttrSupported) {
const getAttrTypeResult = getEffectiveTypeOfSymbolForUsage(getAttrSymbol);
if (isFunction(getAttrTypeResult.type)) {
const returnTypeResult = getEffectiveReturnTypeResult(getAttrTypeResult.type);
type = returnTypeResult.type;
if (getAttrTypeResult.isIncomplete || returnTypeResult.isIncomplete) {
isIncomplete = true;
}
}
}
}
}
// Viper 扩展:模块级 __getattr__(PEP 562)语义不存在,跳过动态属性解析。
// If the field was not found and the module type is marked
// such that all fields should be Any/Unknown, return that type.
@@ -7504,46 +7513,7 @@ export function createTypeEvaluator(
}
}
// Check for builtin classes that will generate runtime exceptions if subscripted.
if ((flags & EvalFlags.ForwardRefs) === 0) {
// We can skip this check if the class is used within a PEP 526 variable
// type annotation within a class or function. For some undocumented reason,
// they don't result in runtime exceptions when used in this manner.
let skipSubscriptCheck = (flags & EvalFlags.VarTypeAnnotation) !== 0;
if (skipSubscriptCheck) {
const scopeNode = ParseTreeUtils.getExecutionScopeNode(node);
if (scopeNode?.nodeType === ParseNodeType.Module) {
skipSubscriptCheck = false;
}
}
if (!skipSubscriptCheck) {
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
// Viper is an AOT static language with no PEP 585 subscript
// restrictions, so skip the runtime-subscriptable check.
if (
!IsViperDialect(fileInfo.executionEnvironment.dialect) &&
isInstantiableClass(baseTypeResult.type) &&
ClassType.isBuiltIn(baseTypeResult.type) &&
!baseTypeResult.type.priv.aliasName
) {
const minPythonVersion = nonSubscriptableBuiltinTypes.get(baseTypeResult.type.shared.fullName);
if (
minPythonVersion !== undefined &&
PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, minPythonVersion) &&
!fileInfo.isStubFile
) {
addDiagnostic(
DiagnosticRule.reportIndexIssue,
LocMessage.classNotRuntimeSubscriptable().format({
name: baseTypeResult.type.priv.aliasName || baseTypeResult.type.shared.name,
}),
node.d.leftExpr
);
}
}
}
}
// Viper 扩展:AOT 静态语言无 PEP 585 运行时 subscript 限制,跳过检查。
const indexTypeResult = getTypeOfIndexWithBaseType(node, baseTypeResult, { method: 'get' }, flags);
@@ -8415,13 +8385,12 @@ export function createTypeEvaluator(
return concreteSubtype;
}
// Viper 扩展:str/bytes 表示 C 字符串指针(i8* / i8*)。
// 即使不是 TypeSet 联合(纯 str/bytes 注解),下标赋值 a[i] = v 也是
// 合法的指针写字节操作(C 语义),不应报 __setitem__ 不存在。
// 下标读取 a[i] 复用 str 的 __getitem__(返回 int/CChar)。
// 无论读写,下标访问 a[i] 都是指针解引用操作(C 语义):
// - 读取 a[i] 返回 t.CChar(i8 字节),而非 Python str.__getitem__ 的 str
// - 赋值 a[i] = v 是合法的指针写字节操作,不报 __setitem__ 不存在
if (
IsViperDialect(viperIndexFileInfo.executionEnvironment.dialect) &&
ClassType.isBuiltIn(concreteSubtype, ['str', 'bytes']) &&
usage.method !== 'get'
ClassType.isBuiltIn(concreteSubtype, ['str', 'bytes'])
) {
// 构造带 CChar 别名信息的 int 类型作为下标访问的目标类型
const ccharType = getViperCCharType(node);
@@ -8615,10 +8584,10 @@ export function createTypeEvaluator(
}
// Viper 扩展:构造带 t.CChar 类型别名信息的 int 类型(表示 C 的 char 类型)。
// Viper 中 str/bytes 是 i8* 指针,下标访问返回 t.CChar(int 别名)。
// Viper 中 str/bytes 是 i8* 指针,下标访问/迭代/字符运算返回 t.CChar(int 别名)。
// 优先从 t 模块查找 CChar 类型别名以保留显示信息;找不到时回退为
// 构造带 typeAliasInfo 的 int 类型。查找失败返回 undefined。
function getViperCCharType(node: IndexNode): Type | undefined {
function getViperCCharType(node: ExpressionNode): Type | undefined {
const tSymbolWithScope = lookUpSymbolRecursive(node, 't', /* honorCodeFlow */ true);
if (tSymbolWithScope) {
const tEffectiveType = getEffectiveTypeOfSymbolForUsage(
@@ -13719,13 +13688,34 @@ export function createTypeEvaluator(
}
if (expectedType && requiresSpecialization(expectedType)) {
// Viper 扩展:str/bytes 实参传给可迭代协议参数(Iterable[_T]/Iterator[_T] 等)
// 时,泛型参数 _T 应从 str.__iter__ 的声明返回类型(Iterator[str])推断。
// 但 Viper 中 str 是 i8* 指针,迭代元素应为 t.CChar 而非 str。
// 因此将 argType 替换为 Iterator[CChar] 实例,使协议匹配把 _T 绑定为 CChar,
// 修复 `for i, ch in enumerate(src)` 中 ch 被推断为 str 的问题
// (同样覆盖 zip/map/filter/reversed/sorted/list() 等 Iterable 参数场景)。
let argTypeForConstraint = argType;
if (
IsViperDialect(AnalyzerNodeInfo.getFileInfo(argParam.errorNode).executionEnvironment.dialect) &&
isClassInstance(argType) &&
ClassType.isBuiltIn(argType, ['str', 'bytes'])
) {
const ccharType = getViperCCharType(argParam.errorNode);
const iteratorClass = getTypingType(argParam.errorNode, 'Iterator');
if (ccharType && iteratorClass && isInstantiableClass(iteratorClass)) {
argTypeForConstraint = ClassType.cloneAsInstance(
ClassType.specialize(iteratorClass, [ccharType])
);
}
}
// Assign the argument type back to the expected type to assign
// values to any unification variables.
const clonedConstraints = constraints.clone();
if (
assignType(
expectedType,
argType,
argTypeForConstraint,
/* diag */ undefined,
clonedConstraints,
options?.isArgFirstPass ? AssignTypeFlags.ArgAssignmentFirstPass : AssignTypeFlags.Default
@@ -21300,26 +21290,7 @@ export function createTypeEvaluator(
if (importLookupInfo) {
reportError = true;
// Handle PEP 562 support for module-level __getattr__ function,
// introduced in Python 3.7.
// Viper has no module-level __getattr__ semantics; skip it.
if (
!IsViperDialect(fileInfo.executionEnvironment.dialect) &&
(PythonVersion.isGreaterOrEqualTo(
fileInfo.executionEnvironment.pythonVersion,
pythonVersion3_7
) ||
fileInfo.isStubFile)
) {
const getAttrSymbol = importLookupInfo.symbolTable.get('__getattr__');
if (getAttrSymbol) {
const getAttrType = getEffectiveTypeOfSymbol(getAttrSymbol);
if (isFunction(getAttrType)) {
symbolType = getEffectiveReturnType(getAttrType);
reportError = false;
}
}
}
// Viper 扩展:模块级 __getattr__(PEP 562)语义不存在,跳过动态符号解析。
} else if (resolvedPath.isEmpty()) {
// This corresponds to the "from . import a" form.
reportError = true;
+10 -16
View File
@@ -1,32 +1,26 @@
/*
* dialect.ts
* 语言方言开关:区分 Python 与 Viper 语义。
* 语言方言:Vipeye 已转型为 Viper 专属 LSP 客户端,仅支持 Viper 方言。
*
* Viper 是基于 CPython 语法但语义不同的 AOT 编译型语言。
* 在 TPV --lsp 实现前,Vipeye 作为姑息 LSP 充当分析器。
* 通过 dialect 字段在 Python 语义与 Viper 语义之间切换。
* Python 模式已彻底移除。代码库中不再存在 Python 语义分支,
* 所有分析均按 Viper 语义执行。
*/
/** 支持的语言方言 */
export type LanguageDialect = 'python' | 'viper';
/** 支持的语言方言(仅 Viper) */
export type LanguageDialect = 'viper';
/** 默认方言:Vipeye 已转型为 Viper 专属 LSP 客户端,默认方言为 Viper。 */
export const DefaultDialect: LanguageDialect = 'viper';
/** 判断当前方言是否为 Viper */
/** 判断当前方言是否为 Viper(恒为 true,Vipeye 仅支持 Viper) */
export function IsViperDialect(dialect: LanguageDialect | undefined): boolean {
return dialect === 'viper';
return true;
}
/** 判断当前方言是否为 Python */
export function IsPythonDialect(dialect: LanguageDialect | undefined): boolean {
return dialect !== 'viper';
}
/** 从字符串解析方言,无效值返回 undefined */
/** 从字符串解析方言,仅接受 'viper' */
export function ParseDialect(value: string | undefined): LanguageDialect | undefined {
if (value === 'python' || value === 'viper') {
return value;
if (value === 'viper') {
return 'viper';
}
return undefined;
}
+1 -11
View File
@@ -16,7 +16,7 @@ import { appendArray } from '../common/collectionUtils';
import { assert } from '../common/debug';
import { Diagnostic, DiagnosticAddendum } from '../common/diagnostic';
import { DiagnosticSink } from '../common/diagnosticSink';
import { IsViperDialect, LanguageDialect } from '../common/dialect';
import { LanguageDialect } from '../common/dialect';
import { convertOffsetsToRange } from '../common/positionUtils';
import {
PythonVersion,
@@ -553,14 +553,6 @@ export class Parser {
private _parseTypeAliasStatement(): TypeAliasNode {
const typeToken = this._getKeywordToken(KeywordType.Type);
if (
!this._parseOptions.isStubFile &&
!IsViperDialect(this._parseOptions.dialect) &&
PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_12)
) {
this._addSyntaxError(LocMessage.typeAliasStatementIllegal(), typeToken);
}
const nameToken = this._getTokenIfIdentifier();
assert(nameToken !== undefined);
const name = NameNode.create(nameToken);
@@ -2055,7 +2047,6 @@ export class Parser {
if (
!this._parseOptions.isStubFile &&
!IsViperDialect(this._parseOptions.dialect) &&
PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_12)
) {
this._addSyntaxError(LocMessage.functionTypeParametersIllegal(), typeParameters);
@@ -2558,7 +2549,6 @@ export class Parser {
if (
!this._parseOptions.isStubFile &&
!IsViperDialect(this._parseOptions.dialect) &&
PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_12)
) {
this._addSyntaxError(LocMessage.classTypeParametersIllegal(), typeParameters);
@@ -0,0 +1,283 @@
/*
* viperFakeduck.test.ts
*
* 临时验证测试(非生产代码,验证完可删除):
* 复现用户真实场景 —— 分析真实文件 _fakeduck.vp 中 _str.split 方法:
*
* def split(self, delimiter: str) -> list[str]:
* result = list[str](self.__mbuddy__)
* ...
* result.append(str(sub))
* return result
*
* 其中 self.__mbuddy__: memhub.MemBuddy | t.CPtr(联合类型)。
*
* 验证目标:
* 1. result 变量的类型是否为 list[str] 实例(而不是 None / Unknown)
* 2. split 中是否有 "Cannot access attribute" 类错误
* 3. _list.vp / memhub.vp / string.vp 是否能被 importLookup 解析
* 4. 若 result 为 None / Unknown,定位根因(list 泛型特化 / __init__ 参数校验 /
* memhub.MemManager 解析 / 级联模块加载失败)
*
* 运行:npx jest src/tests/viperFakeduck.test.ts --runInBand
* 注意:不要执行 webpack build。
*/
import assert from 'assert';
import * as path from 'path';
import { ImportResolver } from '../analyzer/importResolver';
import { Program } from '../analyzer/program';
import * as AnalyzerNodeInfo from '../analyzer/analyzerNodeInfo';
import { ParseTreeWalker } from '../analyzer/parseTreeWalker';
import { TypeEvaluator } from '../analyzer/typeEvaluatorTypes';
import { ConfigOptions, ExecutionEnvironment } from '../common/configOptions';
import { NullConsole } from '../common/console';
import { RealTempFile, createFromRealFileSystem } from '../common/realFileSystem';
import { createServiceProvider } from '../common/serviceProviderExtensions';
import { Uri } from '../common/uri/uri';
import { UriEx } from '../common/uri/uriUtils';
import { FullAccessHost } from '../common/fullAccessHost';
import { CallNode, ClassNode, FunctionNode, ParseNode } from '../parser/parseNodes';
// 与 testUtils 一致:允许 vipershed-fallback(t.vpi/c.vpi 存根)被定位。
(global as any).__rootDirectory = path.resolve();
const TRANSPYC_INCLUDES = 'd:\\Users\\TermiNexus\\Desktop\\TransPyC\\includes';
const FAKEDUCK_PATH = path.join(TRANSPYC_INCLUDES, '_fakeduck.vp');
const LIST_PATH = path.join(TRANSPYC_INCLUDES, '_list.vp');
const MEMHUB_PATH = path.join(TRANSPYC_INCLUDES, 'memhub.vp');
const STRING_PATH = path.join(TRANSPYC_INCLUDES, 'string.vp');
function describeType(t: any): string {
if (!t) return '(undefined)';
const cat = t.category;
const flags = t.flags;
const name = t.shared?.name ?? t.priv?.name ?? '';
const moduleName = t.shared?.moduleName ?? t.priv?.moduleName ?? '';
const typeArgs = t.priv?.typeArgs;
const isInstance = (flags & 2 /* TypeFlags.Instance */) !== 0;
return `category=${cat} flags=${flags} isInstance=${isInstance} name=${name} module=${moduleName}${
typeArgs ? ` typeArgs=[${typeArgs.map((a: any) => describeType(a)).join(', ')}]` : ''
}`;
}
test('reproduce user scenario: _fakeduck.vp split result type', () => {
// 1. 构建 ConfigOptions(Viper 方言),把真实 includes 目录放进 extraPaths
const tempFile = new RealTempFile();
const serviceProvider = createServiceProvider(createFromRealFileSystem(tempFile), new NullConsole(), tempFile);
const projectRoot = UriEx.file(TRANSPYC_INCLUDES);
const configOptions = new ConfigOptions(projectRoot);
configOptions.internalTestMode = true;
configOptions.initializeTypeCheckingMode('standard');
const execEnv = new ExecutionEnvironment(
'python',
projectRoot,
configOptions.diagnosticRuleSet,
configOptions.defaultPythonVersion,
configOptions.defaultPythonPlatform,
[projectRoot],
/* skipNativeLibraries */ false,
/* defaultDialect */ 'viper'
);
configOptions.executionEnvironments = [execEnv];
// 2. 创建 Program(真实文件系统)
const importResolver = new ImportResolver(serviceProvider, configOptions, new FullAccessHost(serviceProvider));
const program = new Program(importResolver, configOptions, serviceProvider);
const fakeduckUri = UriEx.file(FAKEDUCK_PATH);
// 3. 探测 import 解析:_list / memhub / string / t / c 是否可解析
for (const modName of ['_list', 'memhub', 'string', 't', 'c']) {
const resolved = importResolver.resolveImport(fakeduckUri, execEnv, {
leadingDots: 0,
nameParts: [modName],
importedSymbols: undefined,
});
console.log(
`=== resolveImport "${modName}": isImportFound=${resolved.isImportFound}, uris=${JSON.stringify(
resolved.resolvedUris.map((u) => u.getFilePath())
)}`
);
}
program.setTrackedFiles([fakeduckUri]);
while (program.analyze()) {
// 循环直到分析完成
}
// 4. 获取 _fakeduck.vp 的诊断
const sourceFile = program.getSourceFile(fakeduckUri);
assert(sourceFile, '_fakeduck.vp source file not found');
const diagnostics = (sourceFile.getDiagnostics(configOptions) || []).map(
(diag) => `[category=${diag.category}] ${diag.message}`
);
console.log('=== _fakeduck.vp diagnostics ===');
diagnostics.forEach((d) => console.log(` ${d}`));
// 5. 检查依赖模块是否被加载(_list.vp / memhub.vp / string.vp / t.vpi / c.vpi)
const depFiles: Array<{ label: string; uri: Uri | undefined }> = [];
for (const [label, p] of [
['_list.vp', LIST_PATH],
['memhub.vp', MEMHUB_PATH],
['string.vp', STRING_PATH],
] as const) {
const resolved = importResolver.resolveImport(fakeduckUri, execEnv, {
leadingDots: 0,
nameParts: [path.basename(p, '.vp')],
importedSymbols: undefined,
});
const resolvedUri = resolved.resolvedUris[resolved.resolvedUris.length - 1];
const sf = program.getSourceFile(resolvedUri);
const diags = sf ? (sf.getDiagnostics(configOptions) || []).map((d) => `[${d.category}] ${d.message}`) : [];
console.log(`=== ${label}: loaded=${!!sf}, diagnostics=${JSON.stringify(diags)}`);
depFiles.push({ label, uri: resolvedUri });
if (sf && diags.length > 0) {
console.log(` --- ${label} diagnostics ---`);
diags.forEach((d) => console.log(` ${d}`));
}
}
// 6. 从 parse tree 找到 _str.split 方法,取其 scope,查 result 符号
const parseResults = sourceFile.getParseResults();
assert(parseResults, 'parse results not found');
let splitFunctionNode: FunctionNode | undefined;
class FunctionFinder extends ParseTreeWalker {
override visitFunction(node: FunctionNode) {
if (node.d.name.d.value === 'split') {
splitFunctionNode = node;
return false;
}
return true;
}
}
new FunctionFinder().walk(parseResults.parserOutput.parseTree);
assert(splitFunctionNode, 'split function not found');
const splitScope = AnalyzerNodeInfo.getScope(splitFunctionNode!);
assert(splitScope, 'split scope not found');
const resultSymbol = splitScope.lookUpSymbol('result');
assert(resultSymbol, 'result symbol not found in split scope');
const resultType = program.getTypeOfSymbol(resultSymbol);
console.log('=== result type ===');
console.log(` printed: ${resultType ? program.printType(resultType) : '(undefined)'}`);
console.log(` detail: ${describeType(resultType)}`);
assert(resultType, 'result type is undefined');
// 7. 用 evaluator 求值 list[str](self.__mbuddy__) 构造调用,检查其返回类型
const evaluator = program.evaluator as TypeEvaluator | undefined;
assert(evaluator, 'evaluator not available');
const callNodes: CallNode[] = [];
let listCallNode: CallNode | undefined;
class CallCollector extends ParseTreeWalker {
override visitCall(node: CallNode) {
callNodes.push(node);
return true;
}
}
new CallCollector().walk(splitFunctionNode!);
for (const callNode of callNodes) {
const callType = evaluator.getType(callNode as any);
const printed = callType ? program.printType(callType) : '(undefined)';
// 打印 split 内所有调用节点的类型
const leftExpr = callNode.d?.leftExpr as any;
const calleeName = leftExpr?.nodeType === 'Name' ? leftExpr?.d?.value : undefined;
console.log(`=== call node type (range ${callNode.start}-${callNode.start + callNode.length}, callee=${calleeName}): ${printed}`);
if (calleeName === 'list') {
listCallNode = callNode;
}
}
// 8. 检查 _list.vp 的 list 类定义(泛型类是否被正确识别)
const listResolvedUri = depFiles.find((d) => d.label === '_list.vp')?.uri;
if (listResolvedUri) {
const listSf = program.getSourceFile(listResolvedUri);
const listParse = listSf?.getParseResults();
if (listParse) {
const listModuleScope = AnalyzerNodeInfo.getScope(listParse.parserOutput.parseTree);
const listClassSymbol = listModuleScope?.lookUpSymbol('list');
if (listClassSymbol) {
const listClassType = program.getTypeOfSymbol(listClassSymbol);
console.log('=== _list.list class type ===');
console.log(` printed: ${program.printType(listClassType)}`);
console.log(` detail: ${describeType(listClassType)}`);
} else {
console.log('=== _list.list class symbol NOT found ===');
}
// 检查 list 的 __init__ / __new__ 签名
class ClassFinder extends ParseTreeWalker {
override visitClass(node: ClassNode) {
if (node.d.name.d.value === 'list') {
const clsScope = AnalyzerNodeInfo.getScope(node);
for (const fnName of ['__init__', '__new__', 'append']) {
const fnSym = clsScope?.lookUpSymbol(fnName);
if (fnSym) {
const fnType = program.getTypeOfSymbol(fnSym);
console.log(`=== _list.list.${fnName} type: ${program.printType(fnType)}`);
} else {
console.log(`=== _list.list.${fnName} symbol NOT found`);
}
}
return false;
}
return true;
}
}
new ClassFinder().walk(listParse.parserOutput.parseTree);
}
}
// 9. 检查 memhub.MemManager 是否可解析
{
const memhubResolvedUri = depFiles.find((d) => d.label === 'memhub.vp')?.uri;
const memhubSf = memhubResolvedUri ? program.getSourceFile(memhubResolvedUri) : undefined;
const memhubParse = memhubSf?.getParseResults();
if (memhubParse) {
const memhubModuleScope = AnalyzerNodeInfo.getScope(memhubParse.parserOutput.parseTree);
for (const name of ['MemManager', 'MemBuddy']) {
const sym = memhubModuleScope?.lookUpSymbol(name);
if (sym) {
const t = program.getTypeOfSymbol(sym);
console.log(`=== memhub.${name}: ${program.printType(t)}`);
} else {
console.log(`=== memhub.${name} symbol NOT found`);
}
}
} else {
console.log('=== memhub.vp NOT loaded / no parse results');
}
}
// 10. 统计关键诊断
const attributeErrors = diagnostics.filter(
(d) => d.includes('Cannot access attribute') || d.includes('is not assignable')
);
console.log('=== attribute / assignability errors ===');
attributeErrors.forEach((d) => console.log(` ${d}`));
const resultTypeStr = program.printType(resultType);
const resultIsNoneOrUnknown =
resultTypeStr.includes('None') || resultTypeStr.includes('Unknown') || resultTypeStr === '()';
console.log('=== SUMMARY ===');
console.log(` result type: ${resultTypeStr}`);
console.log(` result is None/Unknown/empty: ${resultIsNoneOrUnknown}`);
console.log(` "Cannot access attribute" errors: ${attributeErrors.length}`);
console.log(` _list.vp loaded: ${!!depFiles.find((d) => d.label === '_list.vp')?.uri && !!program.getSourceFile(depFiles.find((d) => d.label === '_list.vp')!.uri!)}`);
console.log(` memhub.vp loaded: ${!!depFiles.find((d) => d.label === 'memhub.vp')?.uri && !!program.getSourceFile(depFiles.find((d) => d.label === 'memhub.vp')!.uri!)}`);
console.log(` string.vp loaded: ${!!depFiles.find((d) => d.label === 'string.vp')?.uri && !!program.getSourceFile(depFiles.find((d) => d.label === 'string.vp')!.uri!)}`);
// 验证目标断言:无论 result 是否正常,测试都必须输出完整诊断;用宽松断言保证测试通过以收集信息
assert(resultTypeStr.length > 0, 'result type string is empty');
program.dispose();
serviceProvider.dispose();
});
@@ -1,36 +0,0 @@
from typing 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",
]
@@ -1 +0,0 @@
def __getattr__(name: str): ... # incomplete module
@@ -1,114 +0,0 @@
import sys
from asyncio.events import AbstractEventLoop
from collections.abc import Awaitable, Callable, Coroutine, Generator
from contextvars import Context
from types import FrameType, GenericAlias
from typing import Any, Literal, TextIO, TypeAlias, TypeVar
from typing_extensions import Self, disjoint_base
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_TaskYieldType: TypeAlias = Future[object] | None
@disjoint_base
class Future(Awaitable[_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) -> 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: ...
def cancel(self, msg: Any | None = None) -> 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: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 12):
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
else:
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _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.
@disjoint_base
class Task(Future[_T_co]): # type: ignore[type-var] # viper: ignore[reportInvalidTypeArguments]
if sys.version_info >= (3, 12):
def __init__(
self,
coro: _TaskCompatibleCoro[_T_co],
*,
loop: AbstractEventLoop | None = None,
name: str | None = 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 | None = None,
name: str | None = None,
context: Context | None = None,
) -> None: ...
else:
def __init__(
self, coro: _TaskCompatibleCoro[_T_co], *, loop: AbstractEventLoop | None = None, name: str | None = None
) -> None: ...
if sys.version_info >= (3, 12):
def get_coro(self) -> _TaskCompatibleCoro[_T_co] | None: ...
else:
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: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def get_event_loop() -> AbstractEventLoop: ...
def get_running_loop() -> AbstractEventLoop: ...
def _set_running_loop(loop: AbstractEventLoop | None, /) -> None: ...
def _get_running_loop() -> AbstractEventLoop | None: ...
def _register_task(task: Task[Any]) -> None: ...
def _unregister_task(task: Task[Any]) -> None: ...
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
def _leave_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...
if sys.version_info >= (3, 12):
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
if sys.version_info >= (3, 14):
def future_discard_from_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...
def future_add_to_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
@@ -1,103 +0,0 @@
from _typeshed import SupportsGetItem, SupportsLenAndGetItem, SupportsRichComparisonT
from collections.abc import Callable, MutableSequence
from typing import TypeVar, overload
_T = TypeVar("_T")
@overload
def bisect_left(
a: SupportsLenAndGetItem[SupportsRichComparisonT],
x: SupportsRichComparisonT,
lo: int = 0,
hi: int | None = None,
*,
key: None = None,
) -> int: ...
@overload
def bisect_left(
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None
) -> int: ...
@overload
def bisect_left(
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None
) -> int: ...
@overload
def bisect_left(
a: SupportsLenAndGetItem[_T],
x: SupportsRichComparisonT,
lo: int = 0,
hi: int | None = None,
*,
key: Callable[[_T], SupportsRichComparisonT],
) -> int: ...
@overload
def bisect_left(
a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT]
) -> int: ...
@overload
def bisect_left(
a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: Callable[[_T], SupportsRichComparisonT]
) -> int: ...
@overload
def bisect_right(
a: SupportsLenAndGetItem[SupportsRichComparisonT],
x: SupportsRichComparisonT,
lo: int = 0,
hi: int | None = None,
*,
key: None = None,
) -> int: ...
@overload
def bisect_right(
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int, hi: int, *, key: None = None
) -> int: ...
@overload
def bisect_right(
a: SupportsGetItem[int, SupportsRichComparisonT], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: None = None
) -> int: ...
@overload
def bisect_right(
a: SupportsLenAndGetItem[_T],
x: SupportsRichComparisonT,
lo: int = 0,
hi: int | None = None,
*,
key: Callable[[_T], SupportsRichComparisonT],
) -> int: ...
@overload
def bisect_right(
a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int, hi: int, *, key: Callable[[_T], SupportsRichComparisonT]
) -> int: ...
@overload
def bisect_right(
a: SupportsGetItem[int, _T], x: SupportsRichComparisonT, lo: int = 0, *, hi: int, key: Callable[[_T], SupportsRichComparisonT]
) -> int: ...
@overload
def insort_left(
a: MutableSequence[SupportsRichComparisonT],
x: SupportsRichComparisonT,
lo: int = 0,
hi: int | None = None,
*,
key: None = None,
) -> None: ...
@overload
def insort_left(
a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT]
) -> None: ...
@overload
def insort_right(
a: MutableSequence[SupportsRichComparisonT],
x: SupportsRichComparisonT,
lo: int = 0,
hi: int | None = None,
*,
key: None = None,
) -> None: ...
@overload
def insort_right(
a: MutableSequence[_T], x: _T, lo: int = 0, hi: int | None = None, *, key: Callable[[_T], SupportsRichComparisonT]
) -> None: ...
@@ -1,119 +0,0 @@
import sys
from _typeshed import ReadableBuffer
from typing import ClassVar, Final, final
from typing_extensions import Self
BLAKE2B_MAX_DIGEST_SIZE: Final = 64
BLAKE2B_MAX_KEY_SIZE: Final = 64
BLAKE2B_PERSON_SIZE: Final = 16
BLAKE2B_SALT_SIZE: Final = 16
BLAKE2S_MAX_DIGEST_SIZE: Final = 32
BLAKE2S_MAX_KEY_SIZE: Final = 32
BLAKE2S_PERSON_SIZE: Final = 8
BLAKE2S_SALT_SIZE: Final = 8
@final
class blake2b:
MAX_DIGEST_SIZE: ClassVar[int] = 64
MAX_KEY_SIZE: ClassVar[int] = 64
PERSON_SIZE: ClassVar[int] = 16
SALT_SIZE: ClassVar[int] = 16
block_size: int
digest_size: int
name: str
if sys.version_info >= (3, 13):
def __new__(
cls,
data: ReadableBuffer = b"",
*,
digest_size: int = 64,
key: ReadableBuffer = b"",
salt: ReadableBuffer = b"",
person: ReadableBuffer = b"",
fanout: int = 1,
depth: int = 1,
leaf_size: int = 0,
node_offset: int = 0,
node_depth: int = 0,
inner_size: int = 0,
last_node: bool = False,
usedforsecurity: bool = True,
string: ReadableBuffer | None = None,
) -> Self: ...
else:
def __new__(
cls,
data: ReadableBuffer = b"",
/,
*,
digest_size: int = 64,
key: ReadableBuffer = b"",
salt: ReadableBuffer = b"",
person: ReadableBuffer = b"",
fanout: int = 1,
depth: int = 1,
leaf_size: int = 0,
node_offset: int = 0,
node_depth: int = 0,
inner_size: int = 0,
last_node: bool = False,
usedforsecurity: bool = True,
) -> Self: ...
def copy(self) -> Self: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def update(self, data: ReadableBuffer, /) -> None: ...
@final
class blake2s:
MAX_DIGEST_SIZE: ClassVar[int] = 32
MAX_KEY_SIZE: ClassVar[int] = 32
PERSON_SIZE: ClassVar[int] = 8
SALT_SIZE: ClassVar[int] = 8
block_size: int
digest_size: int
name: str
if sys.version_info >= (3, 13):
def __new__(
cls,
data: ReadableBuffer = b"",
*,
digest_size: int = 32,
key: ReadableBuffer = b"",
salt: ReadableBuffer = b"",
person: ReadableBuffer = b"",
fanout: int = 1,
depth: int = 1,
leaf_size: int = 0,
node_offset: int = 0,
node_depth: int = 0,
inner_size: int = 0,
last_node: bool = False,
usedforsecurity: bool = True,
string: ReadableBuffer | None = None,
) -> Self: ...
else:
def __new__(
cls,
data: ReadableBuffer = b"",
/,
*,
digest_size: int = 32,
key: ReadableBuffer = b"",
salt: ReadableBuffer = b"",
person: ReadableBuffer = b"",
fanout: int = 1,
depth: int = 1,
leaf_size: int = 0,
node_offset: int = 0,
node_depth: int = 0,
inner_size: int = 0,
last_node: bool = False,
usedforsecurity: bool = True,
) -> Self: ...
def copy(self) -> Self: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def update(self, data: ReadableBuffer, /) -> None: ...
@@ -1,24 +0,0 @@
import sys
from _typeshed import ReadableBuffer
from typing import final
from typing_extensions import Self
@final
class BZ2Compressor:
if sys.version_info >= (3, 12):
def __new__(cls, compresslevel: int = 9, /) -> Self: ...
else:
def __init__(self, compresslevel: int = 9, /) -> None: ...
def compress(self, data: ReadableBuffer, /) -> bytes: ...
def flush(self) -> bytes: ...
@final
class BZ2Decompressor:
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
@property
def eof(self) -> bool: ...
@property
def needs_input(self) -> bool: ...
@property
def unused_data(self) -> bytes: ...
@@ -1,122 +0,0 @@
import codecs
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from typing import Literal, TypeAlias, final, overload, type_check_only
# This type is not exposed; it is defined in unicodeobject.c
# At runtime it calls itself builtins.EncodingMap
@final
@type_check_only
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: ...
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 = "strict") -> bytes: ...
@overload
def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[overload-overlap]
@overload
def encode(obj: str, encoding: str = "utf-8", errors: str = "strict") -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[overload-overlap]
@overload
def decode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> 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 = "strict",
) -> 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 = "strict") -> bytes: ...
@overload
def decode(obj: ReadableBuffer, encoding: str = "utf-8", errors: str = "strict") -> str: ...
def lookup(encoding: str, /) -> codecs.CodecInfo: ...
def charmap_build(map: str, /) -> _CharMap: ...
def ascii_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
def ascii_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def charmap_decode(data: ReadableBuffer, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[str, int]: ...
def charmap_encode(str: str, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[bytes, int]: ...
# Docs say this accepts a bytes-like object, but in practice it also accepts str.
def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ...
def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ...
def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def raw_unicode_escape_decode(
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
) -> tuple[str, int]: ...
def raw_unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def readbuffer_encode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ...
def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /) -> tuple[str, int]: ...
def unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def utf_16_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_16_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def utf_16_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_16_encode(str: str, errors: str | None = None, byteorder: int = 0, /) -> tuple[bytes, int]: ...
def utf_16_ex_decode(
data: ReadableBuffer, errors: str | None = None, byteorder: int = 0, final: bool = False, /
) -> tuple[str, int, int]: ...
def utf_16_le_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_16_le_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def utf_32_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_32_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def utf_32_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_32_encode(str: str, errors: str | None = None, byteorder: int = 0, /) -> tuple[bytes, int]: ...
def utf_32_ex_decode(
data: ReadableBuffer, errors: str | None = None, byteorder: int = 0, final: bool = False, /
) -> tuple[str, int, int]: ...
def utf_32_le_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_32_le_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def utf_7_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_7_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def utf_8_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_8_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
if sys.platform == "win32":
def mbcs_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def mbcs_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def code_page_decode(
codepage: int, data: ReadableBuffer, errors: str | None = None, final: bool = False, /
) -> tuple[str, int]: ...
def code_page_encode(code_page: int, str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def oem_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def oem_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
@@ -1,10 +0,0 @@
from typing import Final
IMPORT_MAPPING: Final[dict[str, str]]
NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]]
PYTHON2_EXCEPTIONS: Final[tuple[str, ...]]
MULTIPROCESSING_EXCEPTIONS: Final[tuple[str, ...]]
REVERSE_IMPORT_MAPPING: Final[dict[str, str]]
REVERSE_NAME_MAPPING: Final[dict[tuple[str, str], tuple[str, str]]]
PYTHON3_OSERROR_EXCEPTIONS: Final[tuple[str, ...]]
PYTHON3_IMPORTERROR_EXCEPTIONS: Final[tuple[str, ...]]
@@ -1,39 +0,0 @@
# _compression is replaced by compression._common._streams on Python 3.14+ (PEP-784)
from _typeshed import ReadableBuffer, WriteableBuffer
from collections.abc import Callable
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
from typing import Any, Protocol, type_check_only
BUFFER_SIZE = DEFAULT_BUFFER_SIZE
@type_check_only
class _Reader(Protocol):
def read(self, n: int, /) -> bytes: ...
def seekable(self) -> bool: ...
def seek(self, n: int, /) -> Any: ...
@type_check_only
class _Decompressor(Protocol):
def decompress(self, data: ReadableBuffer, /, max_length: int = ...) -> bytes: ...
@property
def unused_data(self) -> bytes: ...
@property
def eof(self) -> bool: ...
# `zlib._Decompress` does not have next property, but `DecompressReader` calls it:
# @property
# def needs_input(self) -> bool: ...
class BaseStream(BufferedIOBase): ...
class DecompressReader(RawIOBase):
def __init__(
self,
fp: _Reader,
decomp_factory: Callable[..., _Decompressor],
trailing_error: type[Exception] | tuple[type[Exception], ...] = (),
**decomp_args: Any, # These are passed to decomp_factory.
) -> None: ...
def readinto(self, b: WriteableBuffer) -> int: ...
def read(self, size: int = -1) -> bytes: ...
def seek(self, offset: int, whence: int = 0) -> int: ...
@@ -1,69 +0,0 @@
import sys
from collections.abc import Callable, Iterator, Mapping
from types import GenericAlias, TracebackType
from typing import Any, ClassVar, Generic, ParamSpec, TypeVar, final, overload
from typing_extensions import Self
_T = TypeVar("_T")
_D = TypeVar("_D")
_P = ParamSpec("_P")
@final
class ContextVar(Generic[_T]):
@overload
def __new__(cls, name: str) -> Self: ...
@overload
def __new__(cls, name: str, *, default: _T) -> Self: ...
def __hash__(self) -> int: ...
@property
def name(self) -> str: ...
@overload
def get(self) -> _T: ...
@overload
def get(self, default: _T, /) -> _T: ...
@overload
def get(self, default: _D, /) -> _D | _T: ...
def set(self, value: _T, /) -> Token[_T]: ...
def reset(self, token: Token[_T], /) -> None: ...
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]
__hash__: ClassVar[None] # type: ignore[assignment]
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 14):
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, /
) -> None: ...
def copy_context() -> Context: ...
# It doesn't make sense to make this generic, because for most Contexts each ContextVar will have
# a different value.
@final
class Context(Mapping[ContextVar[Any], Any]):
def __init__(self) -> None: ...
@overload
def get(self, key: ContextVar[_T], default: None = None, /) -> _T | None: ...
@overload
def get(self, key: ContextVar[_T], default: _T, /) -> _T: ...
@overload
def get(self, key: ContextVar[_T], default: _D, /) -> _T | _D: ...
def run(self, callable: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> _T: ...
def copy(self) -> Context: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __getitem__(self, key: ContextVar[_T], /) -> _T: ...
def __iter__(self) -> Iterator[ContextVar[Any]]: ...
def __len__(self) -> int: ...
def __eq__(self, value: object, /) -> bool: ...
@@ -1,116 +0,0 @@
import csv
import sys
from _typeshed import SupportsWrite
from collections.abc import Iterable
from typing import Any, Final, Literal, TypeAlias
from typing_extensions import Self, disjoint_base
__version__: Final[str]
QUOTE_ALL: Final = 1
QUOTE_MINIMAL: Final = 0
QUOTE_NONE: Final = 3
QUOTE_NONNUMERIC: Final = 2
if sys.version_info >= (3, 12):
QUOTE_STRINGS: Final = 4
QUOTE_NOTNULL: Final = 5
if sys.version_info >= (3, 12):
_QuotingType: TypeAlias = Literal[0, 1, 2, 3, 4, 5]
else:
_QuotingType: TypeAlias = Literal[0, 1, 2, 3]
class Error(Exception): ...
_DialectLike: TypeAlias = str | Dialect | csv.Dialect | type[Dialect | csv.Dialect]
@disjoint_base
class Dialect:
delimiter: str
quotechar: str | None
escapechar: str | None
doublequote: bool
skipinitialspace: bool
lineterminator: str
quoting: _QuotingType
strict: bool
def __new__(
cls,
dialect: _DialectLike | None = None,
delimiter: str = ",",
doublequote: bool = True,
escapechar: str | None = None,
lineterminator: str = "\r\n",
quotechar: str | None = '"',
quoting: _QuotingType = 0,
skipinitialspace: bool = False,
strict: bool = False,
) -> Self: ...
# This class calls itself _csv.reader.
@disjoint_base
class Reader:
@property
def dialect(self) -> Dialect: ...
line_num: int
def __iter__(self) -> Self: ...
def __next__(self) -> list[str]: ...
# This class calls itself _csv.writer.
@disjoint_base
class Writer:
@property
def dialect(self) -> Dialect: ...
if sys.version_info >= (3, 13):
def writerow(self, row: Iterable[Any], /) -> Any: ...
def writerows(self, rows: Iterable[Iterable[Any]], /) -> None: ...
else:
def writerow(self, row: Iterable[Any]) -> Any: ...
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
def writer(
fileobj: SupportsWrite[str],
/,
dialect: _DialectLike = "excel",
*,
delimiter: str = ",",
quotechar: str | None = '"',
escapechar: str | None = None,
doublequote: bool = True,
skipinitialspace: bool = False,
lineterminator: str = "\r\n",
quoting: _QuotingType = 0,
strict: bool = False,
) -> Writer: ...
def reader(
iterable: Iterable[str],
/,
dialect: _DialectLike = "excel",
*,
delimiter: str = ",",
quotechar: str | None = '"',
escapechar: str | None = None,
doublequote: bool = True,
skipinitialspace: bool = False,
lineterminator: str = "\r\n",
quoting: _QuotingType = 0,
strict: bool = False,
) -> Reader: ...
def register_dialect(
name: str,
/,
dialect: type[Dialect | csv.Dialect] | str = "excel",
*,
delimiter: str = ",",
quotechar: str | None = '"',
escapechar: str | None = None,
doublequote: bool = True,
skipinitialspace: bool = False,
lineterminator: str = "\r\n",
quoting: _QuotingType = 0,
strict: bool = False,
) -> None: ...
def unregister_dialect(name: str) -> None: ...
def get_dialect(name: str) -> Dialect: ...
def list_dialects() -> list[str]: ...
def field_size_limit(new_limit: int = ...) -> int: ...
@@ -1,375 +0,0 @@
import _typeshed
import builtins
import sys
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p
from types import GenericAlias
from typing import Any, ClassVar, Final, Generic, Literal, SupportsIndex, TypeAlias, TypeVar, final, overload, type_check_only
from typing_extensions import Self
_T = TypeVar("_T")
_CT = TypeVar("_CT", bound=_CData)
FUNCFLAG_CDECL: Final = 0x1
FUNCFLAG_PYTHONAPI: Final = 0x4
FUNCFLAG_USE_ERRNO: Final = 0x8
FUNCFLAG_USE_LASTERROR: Final = 0x10
RTLD_GLOBAL: Final[int]
RTLD_LOCAL: Final[int]
if sys.version_info >= (3, 11):
CTYPES_MAX_ARGCOUNT: Final[int]
if sys.version_info >= (3, 12):
SIZEOF_TIME_T: Final[int]
if sys.platform == "win32":
# Description, Source, HelpFile, HelpContext, scode
_COMError_Details: TypeAlias = tuple[str | None, str | None, str | None, int | None, int | None]
class COMError(Exception):
hresult: int
text: str | None
details: _COMError_Details
def __init__(self, hresult: int, text: str | None, details: _COMError_Details) -> None: ...
def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ...
FUNCFLAG_HRESULT: Final = 0x2
FUNCFLAG_STDCALL: Final = 0x0
def FormatError(code: int = ...) -> str: ...
def get_last_error() -> int: ...
def set_last_error(value: int) -> int: ...
def LoadLibrary(name: str, load_flags: int = 0, /) -> int: ...
def FreeLibrary(handle: int, /) -> None: ...
else:
def dlclose(handle: int, /) -> None: ...
# The default for flag is RTLD_GLOBAL|RTLD_LOCAL, which is platform dependent.
def dlopen(name: StrOrBytesPath, flag: int = ..., /) -> int: ...
def dlsym(handle: int, name: str, /) -> int: ...
if sys.version_info >= (3, 13):
# This class is not exposed. It calls itself _ctypes.CType_Type.
@type_check_only
class _CType_Type(type):
# By default mypy complains about the following two methods, because strictly speaking cls
# might not be a Type[_CT]. However this doesn't happen because this is only a
# metaclass for subclasses of _CData.
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
_CTypeBaseType = _CType_Type
else:
_CTypeBaseType = type
# This class is not exposed.
@type_check_only
class _CData:
_b_base_: int
_b_needsfree_: bool
_objects: Mapping[Any, int] | None
def __buffer__(self, flags: int, /) -> memoryview: ...
def __ctypes_from_outparam__(self, /) -> Self: ...
if sys.version_info >= (3, 14):
__pointer_type__: type
# this is a union of all the subclasses of _CData, which is useful because of
# the methods that are present on each of those subclasses which are not present
# on _CData itself.
_CDataType: TypeAlias = _SimpleCData[Any] | _Pointer[Any] | CFuncPtr | Union | Structure | Array[Any]
# This class is not exposed. It calls itself _ctypes.PyCSimpleType.
@type_check_only
class _PyCSimpleType(_CTypeBaseType):
def from_address(self: type[_typeshed.Self], value: int, /) -> _typeshed.Self: ...
def from_buffer(self: type[_typeshed.Self], obj: WriteableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_buffer_copy(self: type[_typeshed.Self], buffer: ReadableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_param(self: type[_typeshed.Self], value: Any, /) -> _typeshed.Self | _CArgObject: ...
def in_dll(self: type[_typeshed.Self], dll: CDLL, name: str, /) -> _typeshed.Self: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(self: type[_CT], value: int, /) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
def __rmul__(self: type[_CT], value: int, /) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
class _SimpleCData(_CData, Generic[_T], metaclass=_PyCSimpleType):
value: _T
# The TypeVar can be unsolved here,
# but we can't use overloads without creating many, many mypy false-positive errors
def __init__(self, value: _T = ...) -> None: ... # viper: ignore[reportInvalidTypeVarUse]
def __ctypes_from_outparam__(self, /) -> _T: ... # type: ignore[override]
@type_check_only
class _CanCastTo(_CData): ...
@type_check_only
class _PointerLike(_CanCastTo): ...
# This type is not exposed. It calls itself _ctypes.PyCPointerType.
@type_check_only
class _PyCPointerType(_CTypeBaseType):
def from_address(self: type[_typeshed.Self], value: int, /) -> _typeshed.Self: ...
def from_buffer(self: type[_typeshed.Self], obj: WriteableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_buffer_copy(self: type[_typeshed.Self], buffer: ReadableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_param(self: type[_typeshed.Self], value: Any, /) -> _typeshed.Self | _CArgObject: ...
def in_dll(self: type[_typeshed.Self], dll: CDLL, name: str, /) -> _typeshed.Self: ...
def set_type(self, type: _CTypeBaseType, /) -> None: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
class _Pointer(_PointerLike, _CData, Generic[_CT], metaclass=_PyCPointerType):
_type_: type[_CT]
contents: _CT
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, arg: _CT) -> None: ...
@overload
def __getitem__(self, key: int, /) -> Any: ...
@overload
def __getitem__(self, key: slice[SupportsIndex | None], /) -> list[Any]: ...
def __setitem__(self, key: int, value: Any, /) -> None: ...
if sys.version_info < (3, 14):
@overload
def POINTER(type: None, /) -> type[c_void_p]: ...
@overload
def POINTER(type: type[_CT], /) -> type[_Pointer[_CT]]: ...
def pointer(obj: _CT, /) -> _Pointer[_CT]: ...
# This class is not exposed. It calls itself _ctypes.CArgObject.
@final
@type_check_only
class _CArgObject: ...
if sys.version_info >= (3, 14):
def byref(obj: _CData | _CDataType, offset: int = 0, /) -> _CArgObject: ...
else:
def byref(obj: _CData | _CDataType, offset: int = 0) -> _CArgObject: ...
_ECT: TypeAlias = Callable[[_CData | _CDataType | None, CFuncPtr, tuple[_CData | _CDataType, ...]], _CDataType]
_PF: TypeAlias = tuple[int] | tuple[int, str | None] | tuple[int, str | None, Any]
# This class is not exposed. It calls itself _ctypes.PyCFuncPtrType.
@type_check_only
class _PyCFuncPtrType(_CTypeBaseType):
def from_address(self: type[_typeshed.Self], value: int, /) -> _typeshed.Self: ...
def from_buffer(self: type[_typeshed.Self], obj: WriteableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_buffer_copy(self: type[_typeshed.Self], buffer: ReadableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_param(self: type[_typeshed.Self], value: Any, /) -> _typeshed.Self | _CArgObject: ...
def in_dll(self: type[_typeshed.Self], dll: CDLL, name: str, /) -> _typeshed.Self: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
class CFuncPtr(_PointerLike, _CData, metaclass=_PyCFuncPtrType):
restype: type[_CDataType] | Callable[[int], Any] | None
argtypes: Sequence[type[_CDataType]]
errcheck: _ECT
# Abstract attribute that must be defined on subclasses
_flags_: ClassVar[int]
@overload
def __new__(cls) -> Self: ...
@overload
def __new__(cls, address: int, /) -> Self: ...
@overload
def __new__(cls, callable: Callable[..., Any], /) -> Self: ...
@overload
def __new__(cls, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] | None = ..., /) -> Self: ...
if sys.platform == "win32":
@overload
def __new__(
cls, vtbl_index: int, name: str, paramflags: tuple[_PF, ...] | None = ..., iid: _CData | _CDataType | None = ..., /
) -> Self: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
_GetT = TypeVar("_GetT")
_SetT = TypeVar("_SetT")
if sys.version_info >= (3, 14):
@final
class CField(Generic[_CT, _GetT, _SetT]):
offset: int
size: int
name: str
type: builtins.type[_CT]
byte_offset: int
byte_size: int
is_bitfield: bool
bit_offset: int
bit_size: int
is_anonymous: bool
@overload
def __get__(self, instance: None, owner: builtins.type[Any] | None = None, /) -> Self: ...
@overload
def __get__(self, instance: Any, owner: builtins.type[Any] | None = None, /) -> _GetT: ...
def __set__(self, instance: Any, value: _SetT, /) -> None: ...
_CField = CField
else:
@final
@type_check_only
class _CField(Generic[_CT, _GetT, _SetT]):
offset: int
size: int
@overload
def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ...
@overload
def __get__(self, instance: Any, owner: type[Any] | None = None, /) -> _GetT: ...
def __set__(self, instance: Any, value: _SetT, /) -> None: ...
# This class is not exposed. It calls itself _ctypes.UnionType.
@type_check_only
class _UnionType(_CTypeBaseType):
def from_address(self: type[_typeshed.Self], value: int, /) -> _typeshed.Self: ...
def from_buffer(self: type[_typeshed.Self], obj: WriteableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_buffer_copy(self: type[_typeshed.Self], buffer: ReadableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_param(self: type[_typeshed.Self], value: Any, /) -> _typeshed.Self | _CArgObject: ...
def in_dll(self: type[_typeshed.Self], dll: CDLL, name: str, /) -> _typeshed.Self: ...
# At runtime, various attributes are created on a Union subclass based
# on its _fields_. This method doesn't exist, but represents those
# dynamically created attributes.
def __getattr__(self, name: str) -> _CField[Any, Any, Any]: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
class Union(_CData, metaclass=_UnionType):
_fields_: ClassVar[Sequence[tuple[str, type[_CDataType]] | tuple[str, type[_CDataType], int]]]
_pack_: ClassVar[int]
_anonymous_: ClassVar[Sequence[str]]
if sys.version_info >= (3, 13):
_align_: ClassVar[int]
def __init__(self, *args: Any, **kw: Any) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
# This class is not exposed. It calls itself _ctypes.PyCStructType.
@type_check_only
class _PyCStructType(_CTypeBaseType):
def from_address(self: type[_typeshed.Self], value: int, /) -> _typeshed.Self: ...
def from_buffer(self: type[_typeshed.Self], obj: WriteableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_buffer_copy(self: type[_typeshed.Self], buffer: ReadableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_param(self: type[_typeshed.Self], value: Any, /) -> _typeshed.Self | _CArgObject: ...
def in_dll(self: type[_typeshed.Self], dll: CDLL, name: str, /) -> _typeshed.Self: ...
# At runtime, various attributes are created on a Structure subclass based
# on its _fields_. This method doesn't exist, but represents those
# dynamically created attributes.
def __getattr__(self, name: str) -> _CField[Any, Any, Any]: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
class Structure(_CData, metaclass=_PyCStructType):
_fields_: ClassVar[Sequence[tuple[str, type[_CDataType]] | tuple[str, type[_CDataType], int]]]
_pack_: ClassVar[int]
_anonymous_: ClassVar[Sequence[str]]
if sys.version_info >= (3, 13):
_align_: ClassVar[int]
if sys.version_info >= (3, 14):
# _layout_ can be defined by the user, but is not always present.
_layout_: ClassVar[Literal["ms", "gcc-sysv"]]
def __init__(self, *args: Any, **kw: Any) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
# This class is not exposed. It calls itself _ctypes.PyCArrayType.
@type_check_only
class _PyCArrayType(_CTypeBaseType):
def from_address(self: type[_typeshed.Self], value: int, /) -> _typeshed.Self: ...
def from_buffer(self: type[_typeshed.Self], obj: WriteableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_buffer_copy(self: type[_typeshed.Self], buffer: ReadableBuffer, offset: int = 0, /) -> _typeshed.Self: ...
def from_param(self: type[_typeshed.Self], value: Any, /) -> _typeshed.Self | _CArgObject: ...
def in_dll(self: type[_typeshed.Self], dll: CDLL, name: str, /) -> _typeshed.Self: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # viper: ignore[reportGeneralTypeIssues]
class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
@property
@abstractmethod
def _length_(self) -> int: ...
@_length_.setter
def _length_(self, value: int) -> None: ...
@property
@abstractmethod
def _type_(self) -> type[_CT]: ...
@_type_.setter
def _type_(self, value: type[_CT]) -> None: ...
# Note: only available if _CT == c_char
@property
def raw(self) -> bytes: ...
@raw.setter
def raw(self, value: ReadableBuffer) -> None: ...
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
# TODO: These methods cannot be annotated correctly at the moment.
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
# here, because of a special feature of ctypes.
# By default, when accessing an element of an Array[_CT], the returned object has type _CT.
# However, when _CT is a "simple type" like c_int, ctypes automatically "unboxes" the object
# and converts it to the corresponding Python primitive. For example, when accessing an element
# of an Array[c_int], a Python int object is returned, not a c_int.
# This behavior does *not* apply to subclasses of "simple types".
# If MyInt is a subclass of c_int, then accessing an element of an Array[MyInt] returns
# a MyInt, not an int.
# This special behavior is not easy to model in a stub, so for now all places where
# the array element type would belong are annotated with Any instead.
def __init__(self, *args: Any) -> None: ...
@overload
def __getitem__(self, key: int, /) -> Any: ...
@overload
def __getitem__(self, key: slice[SupportsIndex | None], /) -> list[Any]: ...
@overload
def __setitem__(self, key: int, value: Any, /) -> None: ...
@overload
def __setitem__(self, key: slice[SupportsIndex | None], value: Iterable[Any], /) -> None: ...
def __iter__(self) -> Iterator[Any]: ...
# Can't inherit from Sized because the metaclass conflict between
# Sized and _CData prevents using _CDataMeta.
def __len__(self) -> int: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def addressof(obj: _CData | _CDataType, /) -> int: ...
def alignment(obj_or_type: _CData | _CDataType | type[_CData | _CDataType], /) -> int: ...
def get_errno() -> int: ...
def resize(obj: _CData | _CDataType, size: int, /) -> None: ...
def set_errno(value: int, /) -> int: ...
def sizeof(obj_or_type: _CData | _CDataType | type[_CData | _CDataType], /) -> int: ...
def PyObj_FromPtr(address: int, /) -> Any: ...
def Py_DECREF(o: _T, /) -> _T: ...
def Py_INCREF(o: _T, /) -> _T: ...
def buffer_info(o: _CData | _CDataType | type[_CData | _CDataType], /) -> tuple[str, int, tuple[int, ...]]: ...
def call_cdeclfunction(address: int, arguments: tuple[Any, ...], /) -> Any: ...
def call_function(address: int, arguments: tuple[Any, ...], /) -> Any: ...
@@ -1,583 +0,0 @@
import sys
from _typeshed import ReadOnlyBuffer, SupportsRead, SupportsWrite
from curses import _ncurses_version
from typing import Any, Final, TypeAlias, final, overload
# NOTE: This module is ordinarily only available on Unix, but the windows-curses
# package makes it available on Windows as well with the same contents.
# Handled by PyCurses_ConvertToChtype in _cursesmodule.c.
_ChType: TypeAlias = str | bytes | int
# ACS codes are only initialized after initscr is called
ACS_BBSS: Final[int]
ACS_BLOCK: Final[int]
ACS_BOARD: Final[int]
ACS_BSBS: Final[int]
ACS_BSSB: Final[int]
ACS_BSSS: Final[int]
ACS_BTEE: Final[int]
ACS_BULLET: Final[int]
ACS_CKBOARD: Final[int]
ACS_DARROW: Final[int]
ACS_DEGREE: Final[int]
ACS_DIAMOND: Final[int]
ACS_GEQUAL: Final[int]
ACS_HLINE: Final[int]
ACS_LANTERN: Final[int]
ACS_LARROW: Final[int]
ACS_LEQUAL: Final[int]
ACS_LLCORNER: Final[int]
ACS_LRCORNER: Final[int]
ACS_LTEE: Final[int]
ACS_NEQUAL: Final[int]
ACS_PI: Final[int]
ACS_PLMINUS: Final[int]
ACS_PLUS: Final[int]
ACS_RARROW: Final[int]
ACS_RTEE: Final[int]
ACS_S1: Final[int]
ACS_S3: Final[int]
ACS_S7: Final[int]
ACS_S9: Final[int]
ACS_SBBS: Final[int]
ACS_SBSB: Final[int]
ACS_SBSS: Final[int]
ACS_SSBB: Final[int]
ACS_SSBS: Final[int]
ACS_SSSB: Final[int]
ACS_SSSS: Final[int]
ACS_STERLING: Final[int]
ACS_TTEE: Final[int]
ACS_UARROW: Final[int]
ACS_ULCORNER: Final[int]
ACS_URCORNER: Final[int]
ACS_VLINE: Final[int]
ALL_MOUSE_EVENTS: Final[int]
A_ALTCHARSET: Final[int]
A_ATTRIBUTES: Final[int]
A_BLINK: Final[int]
A_BOLD: Final[int]
A_CHARTEXT: Final[int]
A_COLOR: Final[int]
A_DIM: Final[int]
A_HORIZONTAL: Final[int]
A_INVIS: Final[int]
A_ITALIC: Final[int]
A_LEFT: Final[int]
A_LOW: Final[int]
A_NORMAL: Final[int]
A_PROTECT: Final[int]
A_REVERSE: Final[int]
A_RIGHT: Final[int]
A_STANDOUT: Final[int]
A_TOP: Final[int]
A_UNDERLINE: Final[int]
A_VERTICAL: Final[int]
BUTTON1_CLICKED: Final[int]
BUTTON1_DOUBLE_CLICKED: Final[int]
BUTTON1_PRESSED: Final[int]
BUTTON1_RELEASED: Final[int]
BUTTON1_TRIPLE_CLICKED: Final[int]
BUTTON2_CLICKED: Final[int]
BUTTON2_DOUBLE_CLICKED: Final[int]
BUTTON2_PRESSED: Final[int]
BUTTON2_RELEASED: Final[int]
BUTTON2_TRIPLE_CLICKED: Final[int]
BUTTON3_CLICKED: Final[int]
BUTTON3_DOUBLE_CLICKED: Final[int]
BUTTON3_PRESSED: Final[int]
BUTTON3_RELEASED: Final[int]
BUTTON3_TRIPLE_CLICKED: Final[int]
BUTTON4_CLICKED: Final[int]
BUTTON4_DOUBLE_CLICKED: Final[int]
BUTTON4_PRESSED: Final[int]
BUTTON4_RELEASED: Final[int]
BUTTON4_TRIPLE_CLICKED: Final[int]
# Darwin ncurses doesn't provide BUTTON5_* constants prior to 3.12.10 and 3.13.3
if sys.version_info >= (3, 12) or sys.platform != "darwin":
BUTTON5_PRESSED: Final[int]
BUTTON5_RELEASED: Final[int]
BUTTON5_CLICKED: Final[int]
BUTTON5_DOUBLE_CLICKED: Final[int]
BUTTON5_TRIPLE_CLICKED: Final[int]
BUTTON_ALT: Final[int]
BUTTON_CTRL: Final[int]
BUTTON_SHIFT: Final[int]
COLOR_BLACK: Final[int]
COLOR_BLUE: Final[int]
COLOR_CYAN: Final[int]
COLOR_GREEN: Final[int]
COLOR_MAGENTA: Final[int]
COLOR_RED: Final[int]
COLOR_WHITE: Final[int]
COLOR_YELLOW: Final[int]
ERR: Final[int]
KEY_A1: Final[int]
KEY_A3: Final[int]
KEY_B2: Final[int]
KEY_BACKSPACE: Final[int]
KEY_BEG: Final[int]
KEY_BREAK: Final[int]
KEY_BTAB: Final[int]
KEY_C1: Final[int]
KEY_C3: Final[int]
KEY_CANCEL: Final[int]
KEY_CATAB: Final[int]
KEY_CLEAR: Final[int]
KEY_CLOSE: Final[int]
KEY_COMMAND: Final[int]
KEY_COPY: Final[int]
KEY_CREATE: Final[int]
KEY_CTAB: Final[int]
KEY_DC: Final[int]
KEY_DL: Final[int]
KEY_DOWN: Final[int]
KEY_EIC: Final[int]
KEY_END: Final[int]
KEY_ENTER: Final[int]
KEY_EOL: Final[int]
KEY_EOS: Final[int]
KEY_EXIT: Final[int]
KEY_F0: Final[int]
KEY_F1: Final[int]
KEY_F10: Final[int]
KEY_F11: Final[int]
KEY_F12: Final[int]
KEY_F13: Final[int]
KEY_F14: Final[int]
KEY_F15: Final[int]
KEY_F16: Final[int]
KEY_F17: Final[int]
KEY_F18: Final[int]
KEY_F19: Final[int]
KEY_F2: Final[int]
KEY_F20: Final[int]
KEY_F21: Final[int]
KEY_F22: Final[int]
KEY_F23: Final[int]
KEY_F24: Final[int]
KEY_F25: Final[int]
KEY_F26: Final[int]
KEY_F27: Final[int]
KEY_F28: Final[int]
KEY_F29: Final[int]
KEY_F3: Final[int]
KEY_F30: Final[int]
KEY_F31: Final[int]
KEY_F32: Final[int]
KEY_F33: Final[int]
KEY_F34: Final[int]
KEY_F35: Final[int]
KEY_F36: Final[int]
KEY_F37: Final[int]
KEY_F38: Final[int]
KEY_F39: Final[int]
KEY_F4: Final[int]
KEY_F40: Final[int]
KEY_F41: Final[int]
KEY_F42: Final[int]
KEY_F43: Final[int]
KEY_F44: Final[int]
KEY_F45: Final[int]
KEY_F46: Final[int]
KEY_F47: Final[int]
KEY_F48: Final[int]
KEY_F49: Final[int]
KEY_F5: Final[int]
KEY_F50: Final[int]
KEY_F51: Final[int]
KEY_F52: Final[int]
KEY_F53: Final[int]
KEY_F54: Final[int]
KEY_F55: Final[int]
KEY_F56: Final[int]
KEY_F57: Final[int]
KEY_F58: Final[int]
KEY_F59: Final[int]
KEY_F6: Final[int]
KEY_F60: Final[int]
KEY_F61: Final[int]
KEY_F62: Final[int]
KEY_F63: Final[int]
KEY_F7: Final[int]
KEY_F8: Final[int]
KEY_F9: Final[int]
KEY_FIND: Final[int]
KEY_HELP: Final[int]
KEY_HOME: Final[int]
KEY_IC: Final[int]
KEY_IL: Final[int]
KEY_LEFT: Final[int]
KEY_LL: Final[int]
KEY_MARK: Final[int]
KEY_MAX: Final[int]
KEY_MESSAGE: Final[int]
KEY_MIN: Final[int]
KEY_MOUSE: Final[int]
KEY_MOVE: Final[int]
KEY_NEXT: Final[int]
KEY_NPAGE: Final[int]
KEY_OPEN: Final[int]
KEY_OPTIONS: Final[int]
KEY_PPAGE: Final[int]
KEY_PREVIOUS: Final[int]
KEY_PRINT: Final[int]
KEY_REDO: Final[int]
KEY_REFERENCE: Final[int]
KEY_REFRESH: Final[int]
KEY_REPLACE: Final[int]
KEY_RESET: Final[int]
KEY_RESIZE: Final[int]
KEY_RESTART: Final[int]
KEY_RESUME: Final[int]
KEY_RIGHT: Final[int]
KEY_SAVE: Final[int]
KEY_SBEG: Final[int]
KEY_SCANCEL: Final[int]
KEY_SCOMMAND: Final[int]
KEY_SCOPY: Final[int]
KEY_SCREATE: Final[int]
KEY_SDC: Final[int]
KEY_SDL: Final[int]
KEY_SELECT: Final[int]
KEY_SEND: Final[int]
KEY_SEOL: Final[int]
KEY_SEXIT: Final[int]
KEY_SF: Final[int]
KEY_SFIND: Final[int]
KEY_SHELP: Final[int]
KEY_SHOME: Final[int]
KEY_SIC: Final[int]
KEY_SLEFT: Final[int]
KEY_SMESSAGE: Final[int]
KEY_SMOVE: Final[int]
KEY_SNEXT: Final[int]
KEY_SOPTIONS: Final[int]
KEY_SPREVIOUS: Final[int]
KEY_SPRINT: Final[int]
KEY_SR: Final[int]
KEY_SREDO: Final[int]
KEY_SREPLACE: Final[int]
KEY_SRESET: Final[int]
KEY_SRIGHT: Final[int]
KEY_SRSUME: Final[int]
KEY_SSAVE: Final[int]
KEY_SSUSPEND: Final[int]
KEY_STAB: Final[int]
KEY_SUNDO: Final[int]
KEY_SUSPEND: Final[int]
KEY_UNDO: Final[int]
KEY_UP: Final[int]
OK: Final[int]
REPORT_MOUSE_POSITION: Final[int]
_C_API: Any
version: Final[bytes]
def baudrate() -> int: ...
def beep() -> None: ...
def can_change_color() -> bool: ...
def cbreak(flag: bool = True, /) -> None: ...
def color_content(color_number: int, /) -> tuple[int, int, int]: ...
def color_pair(pair_number: int, /) -> int: ...
def curs_set(visibility: int, /) -> int: ...
def def_prog_mode() -> None: ...
def def_shell_mode() -> None: ...
def delay_output(ms: int, /) -> None: ...
def doupdate() -> None: ...
def echo(flag: bool = True, /) -> None: ...
def endwin() -> None: ...
def erasechar() -> bytes: ...
def filter() -> None: ...
def flash() -> None: ...
def flushinp() -> None: ...
def get_escdelay() -> int: ...
def get_tabsize() -> int: ...
def getmouse() -> tuple[int, int, int, int, int]: ...
def getsyx() -> tuple[int, int]: ...
def getwin(file: SupportsRead[bytes], /) -> window: ...
def halfdelay(tenths: int, /) -> None: ...
def has_colors() -> bool: ...
def has_extended_color_support() -> bool: ...
if sys.version_info >= (3, 14):
def assume_default_colors(fg: int, bg: int, /) -> None: ...
def has_ic() -> bool: ...
def has_il() -> bool: ...
def has_key(key: int, /) -> bool: ...
def init_color(color_number: int, r: int, g: int, b: int, /) -> None: ...
def init_pair(pair_number: int, fg: int, bg: int, /) -> None: ...
def initscr() -> window: ...
def intrflush(flag: bool, /) -> None: ...
def is_term_resized(nlines: int, ncols: int, /) -> bool: ...
def isendwin() -> bool: ...
def keyname(key: int, /) -> bytes: ...
def killchar() -> bytes: ...
def longname() -> bytes: ...
def meta(yes: bool, /) -> None: ...
def mouseinterval(interval: int, /) -> None: ...
def mousemask(newmask: int, /) -> tuple[int, int]: ...
def napms(ms: int, /) -> int: ...
def newpad(nlines: int, ncols: int, /) -> window: ...
def newwin(nlines: int, ncols: int, begin_y: int = 0, begin_x: int = 0, /) -> window: ...
def nl(flag: bool = True, /) -> None: ...
def nocbreak() -> None: ...
def noecho() -> None: ...
def nonl() -> None: ...
def noqiflush() -> None: ...
def noraw() -> None: ...
def pair_content(pair_number: int, /) -> tuple[int, int]: ...
def pair_number(attr: int, /) -> int: ...
def putp(string: ReadOnlyBuffer, /) -> None: ...
def qiflush(flag: bool = True, /) -> None: ...
def raw(flag: bool = True, /) -> None: ...
def reset_prog_mode() -> None: ...
def reset_shell_mode() -> None: ...
def resetty() -> None: ...
def resize_term(nlines: int, ncols: int, /) -> None: ...
def resizeterm(nlines: int, ncols: int, /) -> None: ...
def savetty() -> None: ...
def set_escdelay(ms: int, /) -> None: ...
def set_tabsize(size: int, /) -> None: ...
def setsyx(y: int, x: int, /) -> None: ...
def setupterm(term: str | None = None, fd: int = -1) -> None: ...
def start_color() -> None: ...
def termattrs() -> int: ...
def termname() -> bytes: ...
def tigetflag(capname: str, /) -> int: ...
def tigetnum(capname: str, /) -> int: ...
def tigetstr(capname: str, /) -> bytes | None: ...
def tparm(
str: ReadOnlyBuffer,
i1: int = 0,
i2: int = 0,
i3: int = 0,
i4: int = 0,
i5: int = 0,
i6: int = 0,
i7: int = 0,
i8: int = 0,
i9: int = 0,
/,
) -> bytes: ...
def typeahead(fd: int, /) -> None: ...
def unctrl(ch: _ChType, /) -> bytes: ...
def unget_wch(ch: int | str, /) -> None: ...
def ungetch(ch: _ChType, /) -> None: ...
def ungetmouse(id: int, x: int, y: int, z: int, bstate: int, /) -> None: ...
def update_lines_cols() -> None: ...
def use_default_colors() -> None: ...
def use_env(flag: bool, /) -> None: ...
class error(Exception): ...
@final
class window: # undocumented
encoding: str
@overload
def addch(self, ch: _ChType, attr: int = ...) -> None: ...
@overload
def addch(self, y: int, x: int, ch: _ChType, attr: int = ...) -> None: ...
@overload
def addnstr(self, str: str, n: int, attr: int = ...) -> None: ...
@overload
def addnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ...
@overload
def addstr(self, str: str, attr: int = ...) -> None: ...
@overload
def addstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ...
def attroff(self, attr: int, /) -> None: ...
def attron(self, attr: int, /) -> None: ...
def attrset(self, attr: int, /) -> None: ...
def bkgd(self, ch: _ChType, attr: int = 0, /) -> None: ...
def bkgdset(self, ch: _ChType, attr: int = 0, /) -> None: ...
def border(
self,
ls: _ChType = ...,
rs: _ChType = ...,
ts: _ChType = ...,
bs: _ChType = ...,
tl: _ChType = ...,
tr: _ChType = ...,
bl: _ChType = ...,
br: _ChType = ...,
) -> None: ...
@overload
def box(self) -> None: ...
@overload
def box(self, vertch: _ChType = 0, horch: _ChType = 0) -> None: ...
@overload
def chgat(self, attr: int) -> None: ...
@overload
def chgat(self, num: int, attr: int) -> None: ...
@overload
def chgat(self, y: int, x: int, attr: int) -> None: ...
@overload
def chgat(self, y: int, x: int, num: int, attr: int) -> None: ...
def clear(self) -> None: ...
def clearok(self, flag: bool, /) -> None: ...
def clrtobot(self) -> None: ...
def clrtoeol(self) -> None: ...
def cursyncup(self) -> None: ...
@overload
def delch(self) -> None: ...
@overload
def delch(self, y: int, x: int) -> None: ...
def deleteln(self) -> None: ...
@overload
def derwin(self, begin_y: int, begin_x: int) -> window: ...
@overload
def derwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> window: ...
def echochar(self, ch: _ChType, attr: int = 0, /) -> None: ...
def enclose(self, y: int, x: int, /) -> bool: ...
def erase(self) -> None: ...
def getbegyx(self) -> tuple[int, int]: ...
def getbkgd(self) -> tuple[int, int]: ...
@overload
def getch(self) -> int: ...
@overload
def getch(self, y: int, x: int) -> int: ...
@overload
def get_wch(self) -> int | str: ...
@overload
def get_wch(self, y: int, x: int) -> int | str: ...
@overload
def getkey(self) -> str: ...
@overload
def getkey(self, y: int, x: int) -> str: ...
def getmaxyx(self) -> tuple[int, int]: ...
def getparyx(self) -> tuple[int, int]: ...
@overload
def getstr(self) -> bytes: ...
@overload
def getstr(self, n: int) -> bytes: ...
@overload
def getstr(self, y: int, x: int) -> bytes: ...
@overload
def getstr(self, y: int, x: int, n: int) -> bytes: ...
def getyx(self) -> tuple[int, int]: ...
@overload
def hline(self, ch: _ChType, n: int) -> None: ...
@overload
def hline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
def idcok(self, flag: bool, /) -> None: ...
def idlok(self, flag: bool, /) -> None: ...
def immedok(self, flag: bool, /) -> None: ...
@overload
def inch(self) -> int: ...
@overload
def inch(self, y: int, x: int) -> int: ...
@overload
def insch(self, ch: _ChType, attr: int = ...) -> None: ...
@overload
def insch(self, y: int, x: int, ch: _ChType, attr: int = ...) -> None: ...
def insdelln(self, nlines: int, /) -> None: ...
def insertln(self) -> None: ...
@overload
def insnstr(self, str: str, n: int, attr: int = ...) -> None: ...
@overload
def insnstr(self, y: int, x: int, str: str, n: int, attr: int = ...) -> None: ...
@overload
def insstr(self, str: str, attr: int = ...) -> None: ...
@overload
def insstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ...
@overload
def instr(self, n: int = 2047) -> bytes: ...
@overload
def instr(self, y: int, x: int, n: int = 2047) -> bytes: ...
def is_linetouched(self, line: int, /) -> bool: ...
def is_wintouched(self) -> bool: ...
def keypad(self, flag: bool, /) -> None: ...
def leaveok(self, flag: bool, /) -> None: ...
def move(self, new_y: int, new_x: int, /) -> None: ...
def mvderwin(self, y: int, x: int, /) -> None: ...
def mvwin(self, new_y: int, new_x: int, /) -> None: ...
def nodelay(self, flag: bool, /) -> None: ...
def notimeout(self, flag: bool, /) -> None: ...
@overload
def noutrefresh(self) -> None: ...
@overload
def noutrefresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> None: ...
@overload
def overlay(self, destwin: window) -> None: ...
@overload
def overlay(
self, destwin: window, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
) -> None: ...
@overload
def overwrite(self, destwin: window) -> None: ...
@overload
def overwrite(
self, destwin: window, sminrow: int, smincol: int, dminrow: int, dmincol: int, dmaxrow: int, dmaxcol: int
) -> None: ...
def putwin(self, file: SupportsWrite[bytes], /) -> None: ...
def redrawln(self, beg: int, num: int, /) -> None: ...
def redrawwin(self) -> None: ...
@overload
def refresh(self) -> None: ...
@overload
def refresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> None: ...
def resize(self, nlines: int, ncols: int, /) -> None: ...
def scroll(self, lines: int = 1) -> None: ...
def scrollok(self, flag: bool, /) -> None: ...
def setscrreg(self, top: int, bottom: int, /) -> None: ...
def standend(self) -> None: ...
def standout(self) -> None: ...
@overload
def subpad(self, begin_y: int, begin_x: int) -> window: ...
@overload
def subpad(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> window: ...
@overload
def subwin(self, begin_y: int, begin_x: int) -> window: ...
@overload
def subwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> window: ...
def syncdown(self) -> None: ...
def syncok(self, flag: bool, /) -> None: ...
def syncup(self) -> None: ...
def timeout(self, delay: int, /) -> None: ...
def touchline(self, start: int, count: int, changed: bool = True) -> None: ...
def touchwin(self) -> None: ...
def untouchwin(self) -> None: ...
@overload
def vline(self, ch: _ChType, n: int) -> None: ...
@overload
def vline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...
ncurses_version: _ncurses_version
@@ -1,27 +0,0 @@
from _curses import window
from typing import Final, final
__version__: Final[str]
version: Final[str]
class error(Exception): ...
@final
class panel:
def above(self) -> panel: ...
def below(self) -> panel: ...
def bottom(self) -> None: ...
def hidden(self) -> bool: ...
def hide(self) -> None: ...
def move(self, y: int, x: int, /) -> None: ...
def replace(self, win: window, /) -> None: ...
def set_userptr(self, obj: object, /) -> None: ...
def show(self) -> None: ...
def top(self) -> None: ...
def userptr(self) -> object: ...
def window(self) -> window: ...
def bottom_panel() -> panel: ...
def new_panel(win: window, /) -> panel: ...
def top_panel() -> panel: ...
def update_panels() -> panel: ...
@@ -1,46 +0,0 @@
import sys
from _typeshed import ReadOnlyBuffer, StrOrBytesPath
from types import TracebackType
from typing import Final, TypeAlias, TypeVar, final, overload, type_check_only
from typing_extensions import Self
if sys.platform != "win32":
_T = TypeVar("_T")
_KeyType: TypeAlias = str | ReadOnlyBuffer
_ValueType: TypeAlias = str | ReadOnlyBuffer
class error(OSError): ...
library: Final[str]
# Actual typename dbm, not exposed by the implementation
@final
@type_check_only
class _dbm:
def close(self) -> None: ...
if sys.version_info >= (3, 13):
def clear(self) -> None: ...
def __getitem__(self, item: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __len__(self) -> int: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
@overload
def get(self, k: _KeyType, /) -> bytes | None: ...
@overload
def get(self, k: _KeyType, default: _T, /) -> bytes | _T: ...
def keys(self) -> list[bytes]: ...
def setdefault(self, k: _KeyType, default: _ValueType = b"", /) -> bytes: ...
# This isn't true, but the class can't be instantiated. See #13024
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
if sys.version_info >= (3, 11):
def open(filename: StrOrBytesPath, flags: str = "r", mode: int = 0o666, /) -> _dbm: ...
else:
def open(filename: str, flags: str = "r", mode: int = 0o666, /) -> _dbm: ...
@@ -1,73 +0,0 @@
import sys
from decimal import (
Clamped as Clamped,
Context as Context,
ConversionSyntax as ConversionSyntax,
Decimal as Decimal,
DecimalException as DecimalException,
DecimalTuple as DecimalTuple,
DivisionByZero as DivisionByZero,
DivisionImpossible as DivisionImpossible,
DivisionUndefined as DivisionUndefined,
FloatOperation as FloatOperation,
Inexact as Inexact,
InvalidContext as InvalidContext,
InvalidOperation as InvalidOperation,
Overflow as Overflow,
Rounded as Rounded,
Subnormal as Subnormal,
Underflow as Underflow,
_ContextManager,
)
from typing import Final, TypeAlias
_TrapType: TypeAlias = type[DecimalException]
__version__: Final[str]
__libmpdec_version__: Final[str]
if sys.version_info >= (3, 15):
SPEC_VERSION: Final[str]
ROUND_DOWN: Final = "ROUND_DOWN"
ROUND_HALF_UP: Final = "ROUND_HALF_UP"
ROUND_HALF_EVEN: Final = "ROUND_HALF_EVEN"
ROUND_CEILING: Final = "ROUND_CEILING"
ROUND_FLOOR: Final = "ROUND_FLOOR"
ROUND_UP: Final = "ROUND_UP"
ROUND_HALF_DOWN: Final = "ROUND_HALF_DOWN"
ROUND_05UP: Final = "ROUND_05UP"
HAVE_CONTEXTVAR: Final[bool]
HAVE_THREADS: Final[bool]
MAX_EMAX: Final[int]
MAX_PREC: Final[int]
MIN_EMIN: Final[int]
MIN_ETINY: Final[int]
if sys.version_info >= (3, 14):
IEEE_CONTEXT_MAX_BITS: Final[int]
def setcontext(context: Context, /) -> None: ...
def getcontext() -> Context: ...
if sys.version_info >= (3, 11):
def localcontext(
ctx: Context | None = None,
*,
prec: int | None = None,
rounding: str | None = None,
Emin: int | None = None,
Emax: int | None = None,
capitals: int | None = None,
clamp: int | None = None,
traps: dict[_TrapType, bool] | None = None,
flags: dict[_TrapType, bool] | None = None,
) -> _ContextManager: ...
else:
def localcontext(ctx: Context | None = None) -> _ContextManager: ...
if sys.version_info >= (3, 14):
def IEEEContext(bits: int, /) -> Context: ...
DefaultContext: Context
BasicContext: Context
ExtendedContext: Context
@@ -1,115 +0,0 @@
import importlib.abc
import importlib.machinery
import sys
import types
from _typeshed.importlib import LoaderProtocol
from collections.abc import Mapping, Sequence
from types import ModuleType
from typing import Any, ClassVar
from typing_extensions import deprecated
# Signature of `builtins.__import__` should be kept identical to `importlib.__import__`
def __import__(
name: str,
globals: Mapping[str, object] | None = None,
locals: Mapping[str, object] | None = None,
fromlist: Sequence[str] | None = (),
level: int = 0,
) -> ModuleType: ...
def spec_from_loader(
name: str, loader: LoaderProtocol | None, *, origin: str | None = None, is_package: bool | None = None
) -> importlib.machinery.ModuleSpec | None: ...
def module_from_spec(spec: importlib.machinery.ModuleSpec) -> types.ModuleType: ...
def _init_module_attrs(
spec: importlib.machinery.ModuleSpec, module: types.ModuleType, *, override: bool = False
) -> types.ModuleType: ...
class ModuleSpec:
def __init__(
self,
name: str,
loader: importlib.abc.Loader | None,
*,
origin: str | None = None,
loader_state: Any = None,
is_package: bool | None = None,
) -> None: ...
name: str
loader: importlib.abc.Loader | None
origin: str | None
submodule_search_locations: list[str] | None
loader_state: Any
cached: str | None
@property
def parent(self) -> str | None: ...
has_location: bool
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]
class BuiltinImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
# MetaPathFinder
if sys.version_info < (3, 12):
@classmethod
@deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
@classmethod
def find_spec(
cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None
) -> ModuleSpec | None: ...
# InspectLoader
@classmethod
def is_package(cls, fullname: str) -> bool: ...
@classmethod
def load_module(cls, fullname: str) -> types.ModuleType: ...
@classmethod
def get_code(cls, fullname: str) -> None: ...
@classmethod
def get_source(cls, fullname: str) -> None: ...
# Loader
if sys.version_info < (3, 12):
@staticmethod
@deprecated(
"Deprecated since Python 3.4; removed in Python 3.12. "
"The module spec is now used by the import machinery to generate a module repr."
)
def module_repr(module: types.ModuleType) -> str: ...
@staticmethod
def create_module(spec: ModuleSpec) -> types.ModuleType | None: ...
@staticmethod
def exec_module(module: types.ModuleType) -> None: ...
class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader):
# MetaPathFinder
if sys.version_info < (3, 12):
@classmethod
@deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
@classmethod
def find_spec(
cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None
) -> ModuleSpec | None: ...
# InspectLoader
@classmethod
def is_package(cls, fullname: str) -> bool: ...
@classmethod
def load_module(cls, fullname: str) -> types.ModuleType: ...
@classmethod
def get_code(cls, fullname: str) -> None: ...
@classmethod
def get_source(cls, fullname: str) -> None: ...
# Loader
if sys.version_info < (3, 12):
@staticmethod
@deprecated(
"Deprecated since Python 3.4; removed in Python 3.12. "
"The module spec is now used by the import machinery to generate a module repr."
)
def module_repr(m: types.ModuleType) -> str: ...
@staticmethod
def create_module(spec: ModuleSpec) -> types.ModuleType | None: ...
@staticmethod
def exec_module(module: types.ModuleType) -> None: ...
@@ -1,180 +0,0 @@
import _ast
import importlib.abc
import importlib.machinery
import importlib.readers
import sys
import types
from _typeshed import ReadableBuffer, StrOrBytesPath, StrPath
from _typeshed.importlib import LoaderProtocol
from collections.abc import Callable, Iterable, Mapping, MutableSequence, Sequence
from importlib.machinery import ModuleSpec
from importlib.metadata import DistributionFinder, PathDistribution
from typing import Any, Final, Literal, overload
from typing_extensions import deprecated
if sys.platform == "win32":
path_separators: Literal["\\/"]
path_sep: Literal["\\"]
path_sep_tuple: tuple[Literal["\\"], Literal["/"]]
else:
path_separators: Literal["/"]
path_sep: Literal["/"]
path_sep_tuple: tuple[Literal["/"]]
MAGIC_NUMBER: Final[bytes]
@overload
@deprecated(
"The `debug_override` parameter is deprecated since Python 3.5; will be removed in Python 3.15. Use `optimization` instead."
)
def cache_from_source(path: StrPath, debug_override: bool, *, optimization: None = None) -> str: ...
@overload
def cache_from_source(path: StrPath, debug_override: None = None, *, optimization: Any | None = None) -> str: ...
def source_from_cache(path: StrPath) -> str: ...
def decode_source(source_bytes: ReadableBuffer) -> str: ...
def spec_from_file_location(
name: str,
location: StrOrBytesPath | None = None,
*,
loader: LoaderProtocol | None = None,
submodule_search_locations: list[str] | None = ...,
) -> importlib.machinery.ModuleSpec | None: ...
@deprecated(
"Deprecated since Python 3.6. Use site configuration instead. "
"Future versions of Python may not enable this finder by default."
)
class WindowsRegistryFinder(importlib.abc.MetaPathFinder):
if sys.version_info < (3, 12):
@classmethod
@deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
@classmethod
def find_spec(
cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None
) -> ModuleSpec | None: ...
class PathFinder(importlib.abc.MetaPathFinder):
@staticmethod
def invalidate_caches() -> None: ...
@staticmethod
def find_distributions(context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ...
@classmethod
def find_spec(
cls, fullname: str, path: Sequence[str] | None = None, target: types.ModuleType | None = None
) -> ModuleSpec | None: ...
if sys.version_info < (3, 12):
@classmethod
@deprecated("Deprecated since Python 3.4; removed in Python 3.12. Use `find_spec()` instead.")
def find_module(cls, fullname: str, path: Sequence[str] | None = None) -> importlib.abc.Loader | None: ...
SOURCE_SUFFIXES: Final[list[str]]
DEBUG_BYTECODE_SUFFIXES: Final = [".pyc"]
OPTIMIZED_BYTECODE_SUFFIXES: Final = [".pyc"]
BYTECODE_SUFFIXES: Final = [".pyc"]
EXTENSION_SUFFIXES: Final[list[str]]
class FileFinder(importlib.abc.PathEntryFinder):
path: str
def __init__(self, path: str, *loader_details: tuple[type[importlib.abc.Loader], list[str]]) -> None: ...
@classmethod
def path_hook(
cls, *loader_details: tuple[type[importlib.abc.Loader], list[str]]
) -> Callable[[str], importlib.abc.PathEntryFinder]: ...
class _LoaderBasics:
def is_package(self, fullname: str) -> bool: ...
def create_module(self, spec: ModuleSpec) -> types.ModuleType | None: ...
def exec_module(self, module: types.ModuleType) -> None: ...
def load_module(self, fullname: str) -> types.ModuleType: ...
class SourceLoader(_LoaderBasics):
def path_mtime(self, path: str) -> float: ...
def set_data(self, path: str, data: bytes) -> None: ...
def get_source(self, fullname: str) -> str | None: ...
def path_stats(self, path: str) -> Mapping[str, Any]: ...
def source_to_code(
self, data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive, path: bytes | StrPath
) -> types.CodeType: ...
def get_code(self, fullname: str) -> types.CodeType | None: ...
class FileLoader:
name: str
path: str
def __init__(self, fullname: str, path: str) -> None: ...
def get_data(self, path: str) -> bytes: ...
def get_filename(self, fullname: str | None = None) -> str: ...
def load_module(self, fullname: str | None = None) -> types.ModuleType: ...
def get_resource_reader(self, name: str | None = None) -> importlib.readers.FileReader: ...
class SourceFileLoader(importlib.abc.FileLoader, FileLoader, importlib.abc.SourceLoader, SourceLoader): # type: ignore[misc] # incompatible method arguments in base classes
def set_data(self, path: str, data: ReadableBuffer, *, _mode: int = 0o666) -> None: ...
def path_stats(self, path: str) -> Mapping[str, Any]: ...
def source_to_code( # type: ignore[override] # incompatible with InspectLoader.source_to_code
self,
data: ReadableBuffer | str | _ast.Module | _ast.Expression | _ast.Interactive,
path: bytes | StrPath,
*,
_optimize: int = -1,
) -> types.CodeType: ...
class SourcelessFileLoader(importlib.abc.FileLoader, FileLoader, _LoaderBasics):
def get_code(self, fullname: str) -> types.CodeType | None: ...
def get_source(self, fullname: str) -> None: ...
class ExtensionFileLoader(FileLoader, _LoaderBasics, importlib.abc.ExecutionLoader):
def __init__(self, name: str, path: str) -> None: ...
def get_filename(self, fullname: str | None = None) -> str: ...
def get_source(self, fullname: str) -> None: ...
def create_module(self, spec: ModuleSpec) -> types.ModuleType: ...
def exec_module(self, module: types.ModuleType) -> None: ...
def get_code(self, fullname: str) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 11):
class NamespaceLoader(importlib.abc.InspectLoader):
def __init__(
self, name: str, path: MutableSequence[str], path_finder: Callable[[str, tuple[str, ...]], ModuleSpec]
) -> None: ...
def is_package(self, fullname: str) -> Literal[True]: ...
def get_source(self, fullname: str) -> Literal[""]: ...
def get_code(self, fullname: str) -> types.CodeType: ...
def create_module(self, spec: ModuleSpec) -> None: ...
def exec_module(self, module: types.ModuleType) -> None: ...
@deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.")
def load_module(self, fullname: str) -> types.ModuleType: ...
def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ...
if sys.version_info < (3, 12):
@staticmethod
@deprecated(
"Deprecated since Python 3.4; removed in Python 3.12. "
"The module spec is now used by the import machinery to generate a module repr."
)
def module_repr(module: types.ModuleType) -> str: ...
_NamespaceLoader = NamespaceLoader
else:
class _NamespaceLoader:
def __init__(
self, name: str, path: MutableSequence[str], path_finder: Callable[[str, tuple[str, ...]], ModuleSpec]
) -> None: ...
def is_package(self, fullname: str) -> Literal[True]: ...
def get_source(self, fullname: str) -> Literal[""]: ...
def get_code(self, fullname: str) -> types.CodeType: ...
def create_module(self, spec: ModuleSpec) -> None: ...
def exec_module(self, module: types.ModuleType) -> None: ...
@deprecated("Deprecated since Python 3.10; will be removed in Python 3.15. Use `exec_module()` instead.")
def load_module(self, fullname: str) -> types.ModuleType: ...
@staticmethod
@deprecated(
"Deprecated since Python 3.4; removed in Python 3.12. "
"The module spec is now used by the import machinery to generate a module repr."
)
def module_repr(module: types.ModuleType) -> str: ...
def get_resource_reader(self, module: types.ModuleType) -> importlib.readers.NamespaceReader: ...
if sys.version_info >= (3, 13):
class AppleFrameworkLoader(ExtensionFileLoader, importlib.abc.ExecutionLoader): ...
@@ -1,50 +0,0 @@
import sys
from _typeshed import ReadOnlyBuffer, StrOrBytesPath
from types import TracebackType
from typing import TypeAlias, TypeVar, overload, type_check_only
from typing_extensions import Self
if sys.platform != "win32":
_T = TypeVar("_T")
_KeyType: TypeAlias = str | ReadOnlyBuffer
_ValueType: TypeAlias = str | ReadOnlyBuffer
open_flags: str
class error(OSError): ...
# Actual typename gdbm, not exposed by the implementation
@type_check_only
class _gdbm:
def firstkey(self) -> bytes | None: ...
def nextkey(self, key: _KeyType) -> bytes | None: ...
def reorganize(self) -> None: ...
def sync(self) -> None: ...
def close(self) -> None: ...
if sys.version_info >= (3, 13):
def clear(self) -> None: ...
def __getitem__(self, item: _KeyType) -> bytes: ...
def __setitem__(self, key: _KeyType, value: _ValueType) -> None: ...
def __delitem__(self, key: _KeyType) -> None: ...
def __contains__(self, key: _KeyType) -> bool: ...
def __len__(self) -> int: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
@overload
def get(self, k: _KeyType) -> bytes | None: ...
@overload
def get(self, k: _KeyType, default: _T) -> bytes | _T: ...
def keys(self) -> list[bytes]: ...
def setdefault(self, k: _KeyType, default: _ValueType = ...) -> bytes: ...
# Don't exist at runtime
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
if sys.version_info >= (3, 11):
def open(filename: StrOrBytesPath, flags: str = "r", mode: int = 0o666, /) -> _gdbm: ...
else:
def open(filename: str, flags: str = "r", mode: int = 0o666, /) -> _gdbm: ...
@@ -1,127 +0,0 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable
from types import ModuleType
from typing import AnyStr, Protocol, TypeAlias, final, overload, type_check_only
from typing_extensions import Self, disjoint_base
_DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType | None
openssl_md_meth_names: frozenset[str]
@type_check_only
class _HashObject(Protocol):
@property
def digest_size(self) -> int: ...
@property
def block_size(self) -> int: ...
@property
def name(self) -> str: ...
def copy(self) -> Self: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def update(self, obj: ReadableBuffer, /) -> None: ...
@disjoint_base
class HASH:
@property
def digest_size(self) -> int: ...
@property
def block_size(self) -> int: ...
@property
def name(self) -> str: ...
def copy(self) -> Self: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def update(self, obj: ReadableBuffer, /) -> None: ...
class UnsupportedDigestmodError(ValueError): ...
class HASHXOF(HASH):
def digest(self, length: int) -> bytes: ... # type: ignore[override]
def hexdigest(self, length: int) -> str: ... # type: ignore[override]
@final
class HMAC:
@property
def digest_size(self) -> int: ...
@property
def block_size(self) -> int: ...
@property
def name(self) -> str: ...
def copy(self) -> Self: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def update(self, msg: ReadableBuffer) -> None: ...
@overload
def compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
@overload
def compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
def get_fips_mode() -> int: ...
def hmac_new(key: ReadableBuffer, msg: ReadableBuffer = b"", digestmod: _DigestMod = None) -> HMAC: ...
if sys.version_info >= (3, 13):
def new(
name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_md5(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha1(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha224(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha256(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha384(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha512(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha3_224(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha3_256(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha3_384(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_sha3_512(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASH: ...
def openssl_shake_128(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASHXOF: ...
def openssl_shake_256(
data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None
) -> HASHXOF: ...
else:
def new(name: str, string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_md5(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha1(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_shake_128(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
def openssl_shake_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
def hmac_digest(key: ReadableBuffer, msg: ReadableBuffer, digest: str) -> bytes: ...
def pbkdf2_hmac(
hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: int | None = None
) -> bytes: ...
def scrypt(
password: ReadableBuffer, *, salt: ReadableBuffer, n: int, r: int, p: int, maxmem: int = 0, dklen: int = 64
) -> bytes: ...
@@ -1,18 +0,0 @@
import sys
from _typeshed import SupportsRichComparisonT as _T # All type variable use in this module requires comparability.
from typing import Final
__about__: Final[str]
def heapify(heap: list[_T], /) -> None: ... # To work around the fact that list is invariant
def heappop(heap: list[_T], /) -> _T: ...
def heappush(heap: list[_T], item: _T, /) -> None: ...
def heappushpop(heap: list[_T], item: _T, /) -> _T: ...
def heapreplace(heap: list[_T], item: _T, /) -> _T: ...
if sys.version_info >= (3, 14):
def heapify_max(heap: list[_T], /) -> None: ...
def heappop_max(heap: list[_T], /) -> _T: ...
def heappush_max(heap: list[_T], item: _T, /) -> None: ...
def heappushpop_max(heap: list[_T], item: _T, /) -> _T: ...
def heapreplace_max(heap: list[_T], item: _T, /) -> _T: ...
@@ -1,30 +0,0 @@
import sys
import types
from _typeshed import ReadableBuffer
from importlib.machinery import ModuleSpec
from typing import Any
check_hash_based_pycs: str
if sys.version_info >= (3, 14):
pyc_magic_number_token: int
def source_hash(key: int, source: ReadableBuffer) -> bytes: ...
def create_builtin(spec: ModuleSpec, /) -> types.ModuleType: ...
def create_dynamic(spec: ModuleSpec, file: Any = None, /) -> types.ModuleType: ...
def acquire_lock() -> None: ...
def exec_builtin(mod: types.ModuleType, /) -> int: ...
def exec_dynamic(mod: types.ModuleType, /) -> int: ...
def extension_suffixes() -> list[str]: ...
def init_frozen(name: str, /) -> types.ModuleType: ...
def is_builtin(name: str, /) -> int: ...
def is_frozen(name: str, /) -> bool: ...
def is_frozen_package(name: str, /) -> bool: ...
def lock_held() -> bool: ...
def release_lock() -> None: ...
if sys.version_info >= (3, 11):
def find_frozen(name: str, /, *, withdata: bool = False) -> tuple[memoryview | None, bool, str | None] | None: ...
def get_frozen_object(name: str, data: ReadableBuffer | None = None, /) -> types.CodeType: ...
else:
def get_frozen_object(name: str, /) -> types.CodeType: ...
@@ -1,86 +0,0 @@
from _typeshed import structseq
from typing import Any, Final, Literal, SupportsIndex, final
from typing_extensions import Buffer, Self
class ChannelError(RuntimeError): ...
class ChannelClosedError(ChannelError): ...
class ChannelEmptyError(ChannelError): ...
class ChannelNotEmptyError(ChannelError): ...
class ChannelNotFoundError(ChannelError): ...
# Mark as final, since instantiating ChannelID is not supported.
@final
class ChannelID:
@property
def end(self) -> Literal["send", "recv", "both"]: ...
@property
def send(self) -> Self: ...
@property
def recv(self) -> Self: ...
def __eq__(self, other: object, /) -> bool: ...
def __ge__(self, other: ChannelID, /) -> bool: ...
def __gt__(self, other: ChannelID, /) -> bool: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __int__(self) -> int: ...
def __le__(self, other: ChannelID, /) -> bool: ...
def __lt__(self, other: ChannelID, /) -> bool: ...
def __ne__(self, other: object, /) -> bool: ...
@final
class ChannelInfo(structseq[int], tuple[bool, bool, bool, int, int, int, int, int]):
__match_args__: Final = (
"open",
"closing",
"closed",
"count",
"num_interp_send",
"num_interp_send_released",
"num_interp_recv",
"num_interp_recv_released",
)
@property
def open(self) -> bool: ...
@property
def closing(self) -> bool: ...
@property
def closed(self) -> bool: ...
@property
def count(self) -> int: ... # type: ignore[override]
@property
def num_interp_send(self) -> int: ...
@property
def num_interp_send_released(self) -> int: ...
@property
def num_interp_recv(self) -> int: ...
@property
def num_interp_recv_released(self) -> int: ...
@property
def num_interp_both(self) -> int: ...
@property
def num_interp_both_recv_released(self) -> int: ...
@property
def num_interp_both_send_released(self) -> int: ...
@property
def num_interp_both_released(self) -> int: ...
@property
def recv_associated(self) -> bool: ...
@property
def recv_released(self) -> bool: ...
@property
def send_associated(self) -> bool: ...
@property
def send_released(self) -> bool: ...
def create(unboundop: Literal[1, 2, 3]) -> ChannelID: ...
def destroy(cid: SupportsIndex) -> None: ...
def list_all() -> list[ChannelID]: ...
def list_interpreters(cid: SupportsIndex, *, send: bool) -> list[int]: ...
def send(cid: SupportsIndex, obj: object, *, blocking: bool = True, timeout: float | None = None) -> None: ...
def send_buffer(cid: SupportsIndex, obj: Buffer, *, blocking: bool = True, timeout: float | None = None) -> None: ...
def recv(cid: SupportsIndex, default: object = ...) -> tuple[Any, Literal[1, 2, 3]]: ...
def close(cid: SupportsIndex, *, send: bool = False, recv: bool = False) -> None: ...
def get_count(cid: SupportsIndex) -> int: ...
def get_info(cid: SupportsIndex) -> ChannelInfo: ...
def get_channel_defaults(cid: SupportsIndex) -> Literal[1, 2, 3]: ...
def release(cid: SupportsIndex, *, send: bool = False, recv: bool = False, force: bool = False) -> None: ...
@@ -1,31 +0,0 @@
import sys
from typing import Any, Literal, SupportsIndex, TypeAlias
_UnboundOp: TypeAlias = Literal[1, 2, 3]
class QueueError(RuntimeError): ...
class QueueNotFoundError(QueueError): ...
def bind(qid: SupportsIndex) -> None: ...
if sys.version_info >= (3, 15):
def create(maxsize: SupportsIndex, unboundop: SupportsIndex = -1, fallback: SupportsIndex = -1) -> int: ...
else:
def create(maxsize: SupportsIndex, fmt: SupportsIndex, unboundop: _UnboundOp) -> int: ...
def destroy(qid: SupportsIndex) -> None: ...
def get(qid: SupportsIndex) -> tuple[Any, int, _UnboundOp | None]: ...
def get_count(qid: SupportsIndex) -> int: ...
def get_maxsize(qid: SupportsIndex) -> int: ...
def get_queue_defaults(qid: SupportsIndex) -> tuple[int, _UnboundOp]: ...
def is_full(qid: SupportsIndex) -> bool: ...
def list_all() -> list[tuple[int, int, _UnboundOp]]: ...
if sys.version_info >= (3, 15):
def put(qid: SupportsIndex, obj: Any, unboundop: SupportsIndex = -1, fallback: SupportsIndex = -1) -> None: ...
else:
def put(qid: SupportsIndex, obj: Any, fmt: SupportsIndex, unboundop: _UnboundOp) -> None: ...
def release(qid: SupportsIndex) -> None: ...
@@ -1,62 +0,0 @@
import types
from collections.abc import Callable
from typing import Any, Final, Literal, SupportsIndex, TypeAlias, TypeVar, overload
from typing_extensions import disjoint_base
_R = TypeVar("_R")
_Configs: TypeAlias = Literal["default", "isolated", "legacy", "empty", ""]
_SharedDict: TypeAlias = dict[str, Any] # many objects can be shared
class InterpreterError(Exception): ...
class InterpreterNotFoundError(InterpreterError): ...
class NotShareableError(ValueError): ...
@disjoint_base
class CrossInterpreterBufferView:
def __buffer__(self, flags: int, /) -> memoryview: ...
def new_config(name: _Configs = "isolated", /, **overides: object) -> types.SimpleNamespace: ...
def create(config: types.SimpleNamespace | _Configs | None = "isolated", *, reqrefs: bool = False) -> int: ...
def destroy(id: SupportsIndex, *, restrict: bool = False) -> None: ...
def list_all(*, require_ready: bool = False) -> list[tuple[int, _Whence]]: ...
def get_current() -> tuple[int, _Whence]: ...
def get_main() -> tuple[int, _Whence]: ...
def is_running(id: SupportsIndex, *, restrict: bool = False) -> bool: ...
def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleNamespace: ...
def whence(id: SupportsIndex) -> _Whence: ...
def exec(
id: SupportsIndex, code: str | types.CodeType | Callable[[], object], shared: _SharedDict = {}, *, restrict: bool = False
) -> None | types.SimpleNamespace: ...
def call(
id: SupportsIndex,
callable: Callable[..., _R],
args: tuple[Any, ...] = (),
kwargs: dict[str, Any] = {},
*,
preserve_exc: bool = False,
restrict: bool = False,
) -> tuple[_R, types.SimpleNamespace]: ...
def run_string(
id: SupportsIndex, script: str | types.CodeType | Callable[[], object], shared: _SharedDict = {}, *, restrict: bool = False
) -> None: ...
def run_func(
id: SupportsIndex, func: types.CodeType | Callable[[], object], shared: _SharedDict = {}, *, restrict: bool = False
) -> None: ...
def set___main___attrs(id: SupportsIndex, updates: _SharedDict, *, restrict: bool = False) -> None: ...
def incref(id: SupportsIndex, *, implieslink: bool = False, restrict: bool = False) -> None: ...
def decref(id: SupportsIndex, *, restrict: bool = False) -> None: ...
def is_shareable(obj: object) -> bool: ...
@overload
def capture_exception(exc: BaseException) -> types.SimpleNamespace: ...
@overload
def capture_exception(exc: None = None) -> types.SimpleNamespace | None: ...
_Whence: TypeAlias = Literal[0, 1, 2, 3, 4, 5]
WHENCE_UNKNOWN: Final = 0
WHENCE_RUNTIME: Final = 1
WHENCE_LEGACY_CAPI: Final = 2
WHENCE_CAPI: Final = 3
WHENCE_XI: Final = 4
WHENCE_STDLIB: Final = 5
@@ -1,59 +0,0 @@
import sys
from collections.abc import Callable
from typing import Any, final
from typing_extensions import Self
@final
class make_encoder:
@property
def sort_keys(self) -> bool: ...
@property
def skipkeys(self) -> bool: ...
@property
def key_separator(self) -> str: ...
@property
def indent(self) -> str | None: ...
@property
def markers(self) -> dict[int, Any] | None: ...
@property
def default(self) -> Callable[[Any], Any]: ...
@property
def encoder(self) -> Callable[[str], str]: ...
@property
def item_separator(self) -> str: ...
def __new__(
cls,
markers: dict[int, Any] | None,
default: Callable[[Any], Any],
encoder: Callable[[str], str],
indent: str | None,
key_separator: str,
item_separator: str,
sort_keys: bool,
skipkeys: bool,
allow_nan: bool,
) -> Self: ...
def __call__(self, obj: object, _current_indent_level: int) -> Any: ...
@final
class make_scanner:
if sys.version_info >= (3, 15):
array_hook: Any
object_hook: Any
object_pairs_hook: Any
parse_int: Any
parse_constant: Any
parse_float: Any
strict: bool
# TODO: 'context' needs the attrs above (ducktype), but not __call__.
def __new__(cls, context: make_scanner) -> Self: ...
def __call__(self, string: str, index: int) -> tuple[Any, int]: ...
def encode_basestring(s: str, /) -> str: ...
def encode_basestring_ascii(s: str, /) -> str: ...
if sys.version_info >= (3, 15):
def scanstring(pystr: str, end: int, strict: bool = True, /) -> tuple[str, int]: ...
else:
def scanstring(string: str, end: int, strict: bool = True) -> tuple[str, int]: ...
@@ -1,121 +0,0 @@
import sys
from _typeshed import StrPath
from typing import Final, Literal, TypedDict, type_check_only
@type_check_only
class _LocaleConv(TypedDict):
decimal_point: str
grouping: list[int]
thousands_sep: str
int_curr_symbol: str
currency_symbol: str
p_cs_precedes: Literal[0, 1, 127]
n_cs_precedes: Literal[0, 1, 127]
p_sep_by_space: Literal[0, 1, 127]
n_sep_by_space: Literal[0, 1, 127]
mon_decimal_point: str
frac_digits: int
int_frac_digits: int
mon_thousands_sep: str
mon_grouping: list[int]
positive_sign: str
negative_sign: str
p_sign_posn: Literal[0, 1, 2, 3, 4, 127]
n_sign_posn: Literal[0, 1, 2, 3, 4, 127]
LC_CTYPE: Final[int]
LC_COLLATE: Final[int]
LC_TIME: Final[int]
LC_MONETARY: Final[int]
LC_NUMERIC: Final[int]
LC_ALL: Final[int]
CHAR_MAX: Final = 127
def setlocale(category: int, locale: str | None = None, /) -> str: ...
def localeconv() -> _LocaleConv: ...
if sys.version_info >= (3, 11):
def getencoding() -> str: ...
def strcoll(os1: str, os2: str, /) -> int: ...
def strxfrm(string: str, /) -> str: ...
# native gettext functions
# https://docs.python.org/3/library/locale.html#access-to-message-catalogs
# https://github.com/python/cpython/blob/f4c03484da59049eb62a9bf7777b963e2267d187/Modules/_localemodule.c#L626
if sys.platform != "win32":
LC_MESSAGES: int
ABDAY_1: Final[int]
ABDAY_2: Final[int]
ABDAY_3: Final[int]
ABDAY_4: Final[int]
ABDAY_5: Final[int]
ABDAY_6: Final[int]
ABDAY_7: Final[int]
ABMON_1: Final[int]
ABMON_2: Final[int]
ABMON_3: Final[int]
ABMON_4: Final[int]
ABMON_5: Final[int]
ABMON_6: Final[int]
ABMON_7: Final[int]
ABMON_8: Final[int]
ABMON_9: Final[int]
ABMON_10: Final[int]
ABMON_11: Final[int]
ABMON_12: Final[int]
DAY_1: Final[int]
DAY_2: Final[int]
DAY_3: Final[int]
DAY_4: Final[int]
DAY_5: Final[int]
DAY_6: Final[int]
DAY_7: Final[int]
ERA: Final[int]
ERA_D_T_FMT: Final[int]
ERA_D_FMT: Final[int]
ERA_T_FMT: Final[int]
MON_1: Final[int]
MON_2: Final[int]
MON_3: Final[int]
MON_4: Final[int]
MON_5: Final[int]
MON_6: Final[int]
MON_7: Final[int]
MON_8: Final[int]
MON_9: Final[int]
MON_10: Final[int]
MON_11: Final[int]
MON_12: Final[int]
CODESET: Final[int]
D_T_FMT: Final[int]
D_FMT: Final[int]
T_FMT: Final[int]
T_FMT_AMPM: Final[int]
AM_STR: Final[int]
PM_STR: Final[int]
RADIXCHAR: Final[int]
THOUSEP: Final[int]
YESEXPR: Final[int]
NOEXPR: Final[int]
CRNCYSTR: Final[int]
ALT_DIGITS: Final[int]
def nl_langinfo(key: int, /) -> str: ...
# This is dependent on `libintl.h` which is a part of `gettext`
# system dependency. These functions might be missing.
# But, we always say that they are present.
def gettext(msg: str, /) -> str: ...
def dgettext(domain: str | None, msg: str, /) -> str: ...
def dcgettext(domain: str | None, msg: str, category: int, /) -> str: ...
def textdomain(domain: str | None, /) -> str: ...
def bindtextdomain(domain: str, dir: StrPath | None, /) -> str: ...
def bind_textdomain_codeset(domain: str, codeset: str | None, /) -> str | None: ...
@@ -1,34 +0,0 @@
from _typeshed import structseq
from collections.abc import Callable
from types import CodeType
from typing import Any, Final, final
from typing_extensions import disjoint_base
@disjoint_base
class Profiler:
def __init__(
self, timer: Callable[[], float] | None = None, timeunit: float = 0.0, subcalls: bool = True, builtins: bool = True
) -> None: ...
def getstats(self) -> list[profiler_entry]: ...
def enable(self, subcalls: bool = True, builtins: bool = True) -> None: ...
def disable(self) -> None: ...
def clear(self) -> None: ...
@final
class profiler_entry(structseq[Any], tuple[CodeType | str, int, int, float, float, list[profiler_subentry]]):
__match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime", "calls")
code: CodeType | str
callcount: int
reccallcount: int
totaltime: float
inlinetime: float
calls: list[profiler_subentry]
@final
class profiler_subentry(structseq[Any], tuple[CodeType | str, int, int, float, float]):
__match_args__: Final = ("code", "callcount", "reccallcount", "totaltime", "inlinetime")
code: CodeType | str
callcount: int
reccallcount: int
totaltime: float
inlinetime: float
@@ -1,71 +0,0 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Mapping, Sequence
from typing import Any, Final, TypeAlias, final
from typing_extensions import Self
_FilterChain: TypeAlias = Sequence[Mapping[str, Any]]
FORMAT_AUTO: Final = 0
FORMAT_XZ: Final = 1
FORMAT_ALONE: Final = 2
FORMAT_RAW: Final = 3
CHECK_NONE: Final = 0
CHECK_CRC32: Final = 1
CHECK_CRC64: Final = 4
CHECK_SHA256: Final = 10
CHECK_ID_MAX: Final = 15
CHECK_UNKNOWN: Final = 16
FILTER_LZMA1: Final[int] # v big number
FILTER_LZMA2: Final = 33
FILTER_DELTA: Final = 3
FILTER_X86: Final = 4
FILTER_IA64: Final = 6
FILTER_ARM: Final = 7
FILTER_ARMTHUMB: Final = 8
FILTER_SPARC: Final = 9
FILTER_POWERPC: Final = 5
MF_HC3: Final = 3
MF_HC4: Final = 4
MF_BT2: Final = 18
MF_BT3: Final = 19
MF_BT4: Final = 20
MODE_FAST: Final = 1
MODE_NORMAL: Final = 2
PRESET_DEFAULT: Final = 6
PRESET_EXTREME: Final[int] # v big number
@final
class LZMADecompressor:
if sys.version_info >= (3, 12):
def __new__(cls, format: int = 0, memlimit: int | None = None, filters: _FilterChain | None = None) -> Self: ...
else:
def __init__(self, format: int = 0, memlimit: int | None = None, filters: _FilterChain | None = None) -> None: ...
def decompress(self, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
@property
def check(self) -> int: ...
@property
def eof(self) -> bool: ...
@property
def unused_data(self) -> bytes: ...
@property
def needs_input(self) -> bool: ...
@final
class LZMACompressor:
if sys.version_info >= (3, 12):
def __new__(
cls, format: int = 1, check: int = -1, preset: int | None = None, filters: _FilterChain | None = None
) -> Self: ...
else:
def __init__(
self, format: int = 1, check: int = -1, preset: int | None = None, filters: _FilterChain | None = None
) -> None: ...
def compress(self, data: ReadableBuffer, /) -> bytes: ...
def flush(self) -> bytes: ...
class LZMAError(Exception): ...
def is_check_supported(check_id: int, /) -> bool: ...
@@ -1,10 +0,0 @@
class ParserBase:
def reset(self) -> None: ...
def getpos(self) -> tuple[int, int]: ...
def unknown_decl(self, data: str) -> None: ...
def parse_comment(self, i: int, report: bool = True) -> int: ... # undocumented
def parse_declaration(self, i: int) -> int: ... # undocumented
def parse_marked_section(self, i: int, report: bool = True) -> int: ... # undocumented
def updatepos(self, i: int, j: int) -> int: ... # undocumented
lineno: int # undocumented
offset: int # undocumented
@@ -1,97 +0,0 @@
import sys
from typing import Final, type_check_only
if sys.platform == "win32":
class MSIError(Exception): ...
# Actual typename View, not exposed by the implementation
@type_check_only
class _View:
def Execute(self, params: _Record | None = ...) -> None: ...
def GetColumnInfo(self, kind: int) -> _Record: ...
def Fetch(self) -> _Record: ...
def Modify(self, mode: int, record: _Record) -> None: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename SummaryInformation, not exposed by the implementation
@type_check_only
class _SummaryInformation:
def GetProperty(self, field: int) -> int | bytes | None: ...
def GetPropertyCount(self) -> int: ...
def SetProperty(self, field: int, value: int | str) -> None: ...
def Persist(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename Database, not exposed by the implementation
@type_check_only
class _Database:
def OpenView(self, sql: str) -> _View: ...
def Commit(self) -> None: ...
def GetSummaryInformation(self, updateCount: int) -> _SummaryInformation: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename Record, not exposed by the implementation
@type_check_only
class _Record:
def GetFieldCount(self) -> int: ...
def GetInteger(self, field: int) -> int: ...
def GetString(self, field: int) -> str: ...
def SetString(self, field: int, str: str) -> None: ...
def SetStream(self, field: int, stream: str) -> None: ...
def SetInteger(self, field: int, int: int) -> None: ...
def ClearData(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
def UuidCreate() -> str: ...
def FCICreate(cabname: str, files: list[tuple[str, str]], /) -> None: ...
def OpenDatabase(path: str, persist: int, /) -> _Database: ...
def CreateRecord(count: int, /) -> _Record: ...
MSICOLINFO_NAMES: Final[int]
MSICOLINFO_TYPES: Final[int]
MSIDBOPEN_CREATE: Final[int]
MSIDBOPEN_CREATEDIRECT: Final[int]
MSIDBOPEN_DIRECT: Final[int]
MSIDBOPEN_PATCHFILE: Final[int]
MSIDBOPEN_READONLY: Final[int]
MSIDBOPEN_TRANSACT: Final[int]
MSIMODIFY_ASSIGN: Final[int]
MSIMODIFY_DELETE: Final[int]
MSIMODIFY_INSERT: Final[int]
MSIMODIFY_INSERT_TEMPORARY: Final[int]
MSIMODIFY_MERGE: Final[int]
MSIMODIFY_REFRESH: Final[int]
MSIMODIFY_REPLACE: Final[int]
MSIMODIFY_SEEK: Final[int]
MSIMODIFY_UPDATE: Final[int]
MSIMODIFY_VALIDATE: Final[int]
MSIMODIFY_VALIDATE_DELETE: Final[int]
MSIMODIFY_VALIDATE_FIELD: Final[int]
MSIMODIFY_VALIDATE_NEW: Final[int]
PID_APPNAME: Final[int]
PID_AUTHOR: Final[int]
PID_CHARCOUNT: Final[int]
PID_CODEPAGE: Final[int]
PID_COMMENTS: Final[int]
PID_CREATE_DTM: Final[int]
PID_KEYWORDS: Final[int]
PID_LASTAUTHOR: Final[int]
PID_LASTPRINTED: Final[int]
PID_LASTSAVE_DTM: Final[int]
PID_PAGECOUNT: Final[int]
PID_REVNUMBER: Final[int]
PID_SECURITY: Final[int]
PID_SUBJECT: Final[int]
PID_TEMPLATE: Final[int]
PID_TITLE: Final[int]
PID_WORDCOUNT: Final[int]
@@ -1,49 +0,0 @@
from _typeshed import ReadableBuffer
from codecs import _ReadableStream, _WritableStream
from collections.abc import Iterable
from typing import final, type_check_only
from typing_extensions import disjoint_base
# This class is not exposed. It calls itself _multibytecodec.MultibyteCodec.
@final
@type_check_only
class _MultibyteCodec:
def decode(self, input: ReadableBuffer, errors: str | None = None) -> str: ...
def encode(self, input: str, errors: str | None = None) -> bytes: ...
@disjoint_base
class MultibyteIncrementalDecoder:
errors: str
def __init__(self, errors: str = "strict") -> None: ...
def decode(self, input: ReadableBuffer, final: bool = False) -> str: ...
def getstate(self) -> tuple[bytes, int]: ...
def reset(self) -> None: ...
def setstate(self, state: tuple[bytes, int], /) -> None: ...
@disjoint_base
class MultibyteIncrementalEncoder:
errors: str
def __init__(self, errors: str = "strict") -> None: ...
def encode(self, input: str, final: bool = False) -> bytes: ...
def getstate(self) -> int: ...
def reset(self) -> None: ...
def setstate(self, state: int, /) -> None: ...
@disjoint_base
class MultibyteStreamReader:
errors: str
stream: _ReadableStream
def __init__(self, stream: _ReadableStream, errors: str = "strict") -> None: ...
def read(self, sizeobj: int | None = None, /) -> str: ...
def readline(self, sizeobj: int | None = None, /) -> str: ...
def readlines(self, sizehintobj: int | None = None, /) -> list[str]: ...
def reset(self) -> None: ...
@disjoint_base
class MultibyteStreamWriter:
errors: str
stream: _WritableStream
def __init__(self, stream: _WritableStream, errors: str = "strict") -> None: ...
def reset(self) -> None: ...
def write(self, strobj: str, /) -> None: ...
def writelines(self, lines: Iterable[str], /) -> None: ...
@@ -1,157 +0,0 @@
import sys
from _typeshed import (
SupportsAdd,
SupportsGetItem,
SupportsMod,
SupportsMul,
SupportsRAdd,
SupportsRMod,
SupportsRMul,
SupportsRSub,
SupportsSub,
)
from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence
from operator import attrgetter as attrgetter, itemgetter as itemgetter, methodcaller as methodcaller
from typing import Any, AnyStr, ParamSpec, Protocol, SupportsAbs, SupportsIndex, TypeAlias, TypeVar, overload, type_check_only
from typing_extensions import TypeIs
_R = TypeVar("_R")
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
_K = TypeVar("_K")
_V = TypeVar("_V")
_P = ParamSpec("_P")
# The following protocols return "Any" instead of bool, since the comparison
# operators can be overloaded to return an arbitrary object. For example,
# the numpy.array comparison dunders return another numpy.array.
@type_check_only
class _SupportsDunderLT(Protocol):
def __lt__(self, other: Any, /) -> Any: ...
@type_check_only
class _SupportsDunderGT(Protocol):
def __gt__(self, other: Any, /) -> Any: ...
@type_check_only
class _SupportsDunderLE(Protocol):
def __le__(self, other: Any, /) -> Any: ...
@type_check_only
class _SupportsDunderGE(Protocol):
def __ge__(self, other: Any, /) -> Any: ...
_SupportsComparison: TypeAlias = _SupportsDunderLE | _SupportsDunderGE | _SupportsDunderGT | _SupportsDunderLT
@type_check_only
class _SupportsInversion(Protocol[_T_co]):
def __invert__(self) -> _T_co: ...
@type_check_only
class _SupportsNeg(Protocol[_T_co]):
def __neg__(self) -> _T_co: ...
@type_check_only
class _SupportsPos(Protocol[_T_co]):
def __pos__(self) -> _T_co: ...
# All four comparison functions must have the same signature, or we get false-positive errors
def lt(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
def le(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
def eq(a: object, b: object, /) -> Any: ...
def ne(a: object, b: object, /) -> Any: ...
def ge(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
def gt(a: _SupportsComparison, b: _SupportsComparison, /) -> Any: ...
def not_(a: object, /) -> bool: ...
def truth(a: object, /) -> bool: ...
def is_(a: object, b: object, /) -> bool: ...
def is_not(a: object, b: object, /) -> bool: ...
def abs(a: SupportsAbs[_T], /) -> _T: ...
@overload
def add(a: SupportsAdd[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ...
@overload
def add(a: _T_contra, b: SupportsRAdd[_T_contra, _T_co], /) -> _T_co: ...
def and_(a, b, /): ...
def floordiv(a, b, /): ...
def index(a: SupportsIndex, /) -> int: ...
def inv(a: _SupportsInversion[_T_co], /) -> _T_co: ...
def invert(a: _SupportsInversion[_T_co], /) -> _T_co: ...
def lshift(a, b, /): ...
@overload
def mod(a: SupportsMod[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ...
@overload
def mod(a: _T_contra, b: SupportsRMod[_T_contra, _T_co], /) -> _T_co: ...
@overload
def mul(a: SupportsMul[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ...
@overload
def mul(a: _T_contra, b: SupportsRMul[_T_contra, _T_co], /) -> _T_co: ...
def matmul(a, b, /): ...
def neg(a: _SupportsNeg[_T_co], /) -> _T_co: ...
def or_(a, b, /): ...
def pos(a: _SupportsPos[_T_co], /) -> _T_co: ...
def pow(a, b, /): ...
def rshift(a, b, /): ...
@overload
def sub(a: SupportsSub[_T_contra, _T_co], b: _T_contra, /) -> _T_co: ...
@overload
def sub(a: _T_contra, b: SupportsRSub[_T_contra, _T_co], /) -> _T_co: ...
def truediv(a, b, /): ...
def xor(a, b, /): ...
def concat(a: Sequence[_T], b: Sequence[_T], /) -> Sequence[_T]: ...
def contains(a: Container[object], b: object, /) -> bool: ...
def countOf(a: Iterable[object], b: object, /) -> int: ...
@overload
def delitem(a: MutableSequence[Any], b: int, /) -> None: ...
@overload
def delitem(a: MutableSequence[Any], b: slice[int | None], /) -> None: ...
@overload
def delitem(a: MutableMapping[_K, Any], b: _K, /) -> None: ...
@overload
def getitem(a: Sequence[_T], b: slice[int | None], /) -> Sequence[_T]: ...
@overload
def getitem(a: SupportsGetItem[_K, _V], b: _K, /) -> _V: ...
def indexOf(a: Iterable[_T], b: _T, /) -> int: ...
@overload
def setitem(a: MutableSequence[_T], b: int, c: _T, /) -> None: ...
@overload
def setitem(a: MutableSequence[_T], b: slice[int | None], c: Sequence[_T], /) -> None: ...
@overload
def setitem(a: MutableMapping[_K, _V], b: _K, c: _V, /) -> None: ...
def length_hint(obj: object, default: int = 0, /) -> int: ...
def iadd(a, b, /): ...
def iand(a, b, /): ...
def iconcat(a, b, /): ...
def ifloordiv(a, b, /): ...
def ilshift(a, b, /): ...
def imod(a, b, /): ...
def imul(a, b, /): ...
def imatmul(a, b, /): ...
def ior(a, b, /): ...
def ipow(a, b, /): ...
def irshift(a, b, /): ...
def isub(a, b, /): ...
def itruediv(a, b, /): ...
def ixor(a, b, /): ...
if sys.version_info >= (3, 11):
def call(obj: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ...
def _compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
if sys.version_info >= (3, 14):
def is_none(a: object, /) -> TypeIs[None]: ...
def is_not_none(a: _T | None, /) -> TypeIs[_T]: ...
@@ -1,34 +0,0 @@
from collections.abc import Iterable, Sequence
from typing import Final, TypeVar
_T = TypeVar("_T")
_K = TypeVar("_K")
_V = TypeVar("_V")
__all__ = ["compiler_fixup", "customize_config_vars", "customize_compiler", "get_platform_osx"]
_UNIVERSAL_CONFIG_VARS: Final[tuple[str, ...]] # undocumented
_COMPILER_CONFIG_VARS: Final[tuple[str, ...]] # undocumented
_INITPRE: Final[str] # undocumented
def _find_executable(executable: str, path: str | None = None) -> str | None: ... # undocumented
def _read_output(commandstring: str, capture_stderr: bool = False) -> str | None: ... # undocumented
def _find_build_tool(toolname: str) -> str: ... # undocumented
_SYSTEM_VERSION: Final[str | None] # undocumented
def _get_system_version() -> str: ... # undocumented
def _remove_original_values(_config_vars: dict[str, str]) -> None: ... # undocumented
def _save_modified_value(_config_vars: dict[str, str], cv: str, newvalue: str) -> None: ... # undocumented
def _supports_universal_builds() -> bool: ... # undocumented
def _find_appropriate_compiler(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
def _remove_universal_flags(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
def _remove_unsupported_archs(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
def _override_all_archs(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
def _check_for_unavailable_sdk(_config_vars: dict[str, str]) -> dict[str, str]: ... # undocumented
def compiler_fixup(compiler_so: Iterable[str], cc_args: Sequence[str]) -> list[str]: ...
def customize_config_vars(_config_vars: dict[str, str]) -> dict[str, str]: ...
def customize_compiler(_config_vars: dict[str, str]) -> dict[str, str]: ...
def get_platform_osx(
_config_vars: dict[str, str], osname: _T, release: _K, machine: _V
) -> tuple[str | _T, str | _K, str | _V]: ...
@@ -1,114 +0,0 @@
from _typeshed import ReadableBuffer, SupportsWrite
from collections.abc import Callable, Iterable, Iterator, Mapping
from pickle import PickleBuffer as PickleBuffer
from typing import Any, Protocol, TypeAlias, type_check_only
from typing_extensions import disjoint_base
@type_check_only
class _ReadableFileobj(Protocol):
def read(self, n: int, /) -> bytes: ...
def readline(self) -> bytes: ...
_BufferCallback: TypeAlias = Callable[[PickleBuffer], Any] | None
_ReducedType: TypeAlias = (
str
| tuple[Callable[..., Any], tuple[Any, ...]]
| tuple[Callable[..., Any], tuple[Any, ...], Any]
| tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None]
| tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None, Iterator[Any] | None]
)
def dump(
obj: Any,
file: SupportsWrite[bytes],
protocol: int | None = None,
*,
fix_imports: bool = True,
buffer_callback: _BufferCallback = None,
) -> None: ...
def dumps(
obj: Any, protocol: int | None = None, *, fix_imports: bool = True, buffer_callback: _BufferCallback = None
) -> bytes: ...
def load(
file: _ReadableFileobj,
*,
fix_imports: bool = True,
encoding: str = "ASCII",
errors: str = "strict",
buffers: Iterable[Any] | None = (),
) -> Any: ...
def loads(
data: ReadableBuffer,
/,
*,
fix_imports: bool = True,
encoding: str = "ASCII",
errors: str = "strict",
buffers: Iterable[Any] | None = (),
) -> Any: ...
class PickleError(Exception): ...
class PicklingError(PickleError): ...
class UnpicklingError(PickleError): ...
@type_check_only
class PicklerMemoProxy:
def clear(self, /) -> None: ...
def copy(self, /) -> dict[int, tuple[int, Any]]: ...
@disjoint_base
class Pickler:
fast: bool
dispatch_table: Mapping[type, Callable[[Any], _ReducedType]]
bin: bool # undocumented
def __init__(
self,
file: SupportsWrite[bytes],
protocol: int | None = None,
fix_imports: bool = True,
buffer_callback: _BufferCallback = None,
) -> None: ...
@property
def memo(self) -> PicklerMemoProxy: ...
@memo.setter
def memo(self, value: PicklerMemoProxy | dict[int, tuple[int, Any]]) -> None: ...
def dump(self, obj: Any, /) -> None: ...
def clear_memo(self) -> None: ...
# this method has no default implementation for Python < 3.13
def persistent_id(self, obj: Any, /) -> Any: ...
# The following method is not defined on _Pickler, but can be defined on
# sub-classes. Should return `NotImplemented` if pickling the supplied
# object is not supported and returns the same types as `__reduce__()`.
def reducer_override(self, obj: object, /) -> _ReducedType: ...
@type_check_only
class UnpicklerMemoProxy:
def clear(self, /) -> None: ...
def copy(self, /) -> dict[int, tuple[int, Any]]: ...
@disjoint_base
class Unpickler:
def __init__(
self,
file: _ReadableFileobj,
*,
fix_imports: bool = True,
encoding: str = "ASCII",
errors: str = "strict",
buffers: Iterable[Any] | None = (),
) -> None: ...
@property
def memo(self) -> UnpicklerMemoProxy: ...
@memo.setter
def memo(self, value: UnpicklerMemoProxy | dict[int, tuple[int, Any]]) -> None: ...
def load(self) -> Any: ...
def find_class(self, module_name: str, global_name: str, /) -> Any: ...
# this method has no default implementation for Python < 3.13
def persistent_load(self, pid: Any, /) -> Any: ...
@@ -1,59 +0,0 @@
import sys
from _typeshed import StrOrBytesPath
from collections.abc import Callable, Sequence
from typing import SupportsIndex
if sys.platform != "win32":
if sys.version_info >= (3, 14):
def fork_exec(
args: Sequence[StrOrBytesPath] | None,
executable_list: Sequence[bytes],
close_fds: bool,
pass_fds: tuple[int, ...],
cwd: str,
env: Sequence[bytes] | None,
p2cread: int,
p2cwrite: int,
c2pread: int,
c2pwrite: int,
errread: int,
errwrite: int,
errpipe_read: int,
errpipe_write: int,
restore_signals: int,
call_setsid: int,
pgid_to_set: int,
gid: SupportsIndex | None,
extra_groups: list[int] | None,
uid: SupportsIndex | None,
child_umask: int,
preexec_fn: Callable[[], None],
/,
) -> int: ...
else:
def fork_exec(
args: Sequence[StrOrBytesPath] | None,
executable_list: Sequence[bytes],
close_fds: bool,
pass_fds: tuple[int, ...],
cwd: str,
env: Sequence[bytes] | None,
p2cread: int,
p2cwrite: int,
c2pread: int,
c2pwrite: int,
errread: int,
errwrite: int,
errpipe_read: int,
errpipe_write: int,
restore_signals: bool,
call_setsid: bool,
pgid_to_set: int,
gid: SupportsIndex | None,
extra_groups: list[int] | None,
uid: SupportsIndex | None,
child_umask: int,
preexec_fn: Callable[[], None],
allow_vfork: bool,
/,
) -> int: ...
@@ -1,14 +0,0 @@
import _typeshed
from typing import Any, NewType, TypeVar
_T = TypeVar("_T")
_CacheToken = NewType("_CacheToken", int)
def get_cache_token() -> _CacheToken: ...
class ABCMeta(type):
def __new__(
mcls: type[_typeshed.Self], name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any], /
) -> _typeshed.Self: ...
def register(cls, subclass: type[_T]) -> type[_T]: ...
@@ -1,50 +0,0 @@
# This is a slight lie, the implementations aren't exactly identical
# However, in all likelihood, the differences are inconsequential
import sys
from _decimal import *
__all__ = [
"Decimal",
"Context",
"DecimalTuple",
"DefaultContext",
"BasicContext",
"ExtendedContext",
"DecimalException",
"Clamped",
"InvalidOperation",
"DivisionByZero",
"Inexact",
"Rounded",
"Subnormal",
"Overflow",
"Underflow",
"FloatOperation",
"DivisionImpossible",
"InvalidContext",
"ConversionSyntax",
"DivisionUndefined",
"ROUND_DOWN",
"ROUND_HALF_UP",
"ROUND_HALF_EVEN",
"ROUND_CEILING",
"ROUND_FLOOR",
"ROUND_UP",
"ROUND_HALF_DOWN",
"ROUND_05UP",
"setcontext",
"getcontext",
"localcontext",
"MAX_PREC",
"MAX_EMAX",
"MIN_EMIN",
"MIN_ETINY",
"HAVE_THREADS",
"HAVE_CONTEXTVAR",
]
if sys.version_info >= (3, 14):
__all__ += ["IEEEContext", "IEEE_CONTEXT_MAX_BITS"]
if sys.version_info >= (3, 15):
__all__ += ["SPEC_VERSION"]
@@ -1,18 +0,0 @@
from types import GenericAlias
from typing import Any, Generic, TypeVar
from typing_extensions import disjoint_base
_T = TypeVar("_T")
class Empty(Exception): ...
@disjoint_base
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: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@@ -1,14 +0,0 @@
from typing import TypeAlias
from typing_extensions import disjoint_base
# Actually Tuple[(int,) * 625]
_State: TypeAlias = tuple[int, ...]
@disjoint_base
class Random:
def __init__(self, seed: object = ..., /) -> None: ...
def seed(self, n: object = None, /) -> None: ...
def getstate(self) -> _State: ...
def setstate(self, state: _State, /) -> None: ...
def random(self) -> float: ...
def getrandbits(self, k: int, /) -> int: ...
@@ -1,183 +0,0 @@
from _typeshed import StrOrBytesPath, structseq
from collections.abc import Callable
from typing import Final, TypeAlias, final
from typing_extensions import Self
_Location: TypeAlias = tuple[int, int, int, int] | LocationInfo | None
_Frame: TypeAlias = tuple[str, _Location, str, int | None] | FrameInfo
_Stats: TypeAlias = dict[str, int | float]
PROCESS_VM_READV_SUPPORTED: Final[int]
THREAD_STATUS_GIL_REQUESTED: Final[int]
THREAD_STATUS_HAS_EXCEPTION: Final[int]
THREAD_STATUS_HAS_GIL: Final[int]
THREAD_STATUS_MAIN_THREAD: Final[int]
THREAD_STATUS_ON_CPU: Final[int]
THREAD_STATUS_UNKNOWN: Final[int]
@final
class LocationInfo(structseq[int], tuple[int, int, int, int]):
__match_args__: Final = ("lineno", "end_lineno", "col_offset", "end_col_offset")
@property
def lineno(self) -> int: ...
@property
def end_lineno(self) -> int: ...
@property
def col_offset(self) -> int: ...
@property
def end_col_offset(self) -> int: ...
@final
class FrameInfo(structseq[object], tuple[str, _Location, str, int | None]):
__match_args__: Final = ("filename", "location", "funcname", "opcode")
@property
def filename(self) -> str: ...
@property
def location(self) -> _Location: ...
@property
def funcname(self) -> str: ...
@property
def opcode(self) -> int | None: ...
@final
class CoroInfo(structseq[object], tuple[list[_Frame], int | str]):
__match_args__: Final = ("call_stack", "task_name")
@property
def call_stack(self) -> list[_Frame]: ...
@property
def task_name(self) -> int | str: ...
@final
class TaskInfo(structseq[object], tuple[int, str, list[CoroInfo], list[CoroInfo]]):
__match_args__: Final = ("task_id", "task_name", "coroutine_stack", "awaited_by")
@property
def task_id(self) -> int: ...
@property
def task_name(self) -> str: ...
@property
def coroutine_stack(self) -> list[CoroInfo]: ...
@property
def awaited_by(self) -> list[CoroInfo]: ...
@final
class ThreadInfo(structseq[object], tuple[int, int, list[_Frame]]):
__match_args__: Final = ("thread_id", "status", "frame_info")
@property
def thread_id(self) -> int: ...
@property
def status(self) -> int: ...
@property
def frame_info(self) -> list[_Frame]: ...
@final
class InterpreterInfo(structseq[object], tuple[int, list[ThreadInfo]]):
__match_args__: Final = ("interpreter_id", "threads")
@property
def interpreter_id(self) -> int: ...
@property
def threads(self) -> list[ThreadInfo]: ...
@final
class AwaitedInfo(structseq[object], tuple[int, list[TaskInfo]]):
__match_args__: Final = ("thread_id", "awaited_by")
@property
def thread_id(self) -> int: ...
@property
def awaited_by(self) -> list[TaskInfo]: ...
@final
class GCStatsInfo(structseq[object], tuple[int, int, int, int, int, int, int, int, int, float]):
__match_args__: Final = (
"gen",
"iid",
"ts_start",
"ts_stop",
"collections",
"collected",
"uncollectable",
"candidates",
"heap_size",
"duration",
)
@property
def gen(self) -> int: ...
@property
def iid(self) -> int: ...
@property
def ts_start(self) -> int: ...
@property
def ts_stop(self) -> int: ...
@property
def collections(self) -> int: ...
@property
def collected(self) -> int: ...
@property
def uncollectable(self) -> int: ...
@property
def candidates(self) -> int: ...
@property
def heap_size(self) -> int: ...
@property
def duration(self) -> float: ...
@final
class RemoteUnwinder:
def __init__(
self,
pid: int,
*,
all_threads: bool = False,
only_active_thread: bool = False,
mode: int = 0,
debug: bool = False,
skip_non_matching_threads: bool = True,
native: bool = False,
gc: bool = False,
opcodes: bool = False,
cache_frames: bool = False,
stats: bool = False,
) -> None: ...
def get_stack_trace(self) -> list[InterpreterInfo]: ...
def get_all_awaited_by(self) -> list[AwaitedInfo]: ...
def get_async_stack_trace(self) -> list[AwaitedInfo]: ...
def get_stats(self) -> _Stats: ...
def pause_threads(self) -> bool: ...
def resume_threads(self) -> bool: ...
@final
class GCMonitor:
def __init__(self, pid: int, *, debug: bool = False) -> None: ...
def get_gc_stats(self, all_interpreters: bool = False) -> list[GCStatsInfo]: ...
@final
class BinaryWriter:
def __init__(
self, filename: StrOrBytesPath, sample_interval_us: int, start_time_us: int, *, compression: int = 0
) -> None: ...
@property
def total_samples(self) -> int: ...
def write_sample(self, stack_frames: list[InterpreterInfo], timestamp_us: int) -> None: ...
def finalize(self) -> None: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, exc_type: object = None, exc_val: object = None, exc_tb: object = None) -> bool: ...
def get_stats(self) -> _Stats: ...
@final
class BinaryReader:
def __init__(self, filename: StrOrBytesPath) -> None: ...
@property
def sample_count(self) -> int: ...
@property
def sample_interval_us(self) -> int: ...
def replay(self, collector: object, progress_callback: Callable[[int, int], object] | None = None) -> int: ...
def get_info(self) -> dict[str, object]: ...
def get_stats(self) -> _Stats: ...
def close(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, exc_type: object = None, exc_val: object = None, exc_tb: object = None) -> bool: ...
def zstd_available() -> bool: ...
def get_child_pids(pid: int, *, recursive: bool = True) -> list[int]: ...
def is_python_process(pid: int) -> bool: ...
def get_gc_stats(pid: int, *, all_interpreters: bool = False) -> list[GCStatsInfo]: ...
@@ -1,966 +0,0 @@
import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from collections.abc import Iterable
from socket import error as error, gaierror as gaierror, herror as herror, timeout as timeout
from typing import Any, Final, SupportsIndex, TypeAlias, overload
from typing_extensions import CapsuleType, disjoint_base
_CMSG: TypeAlias = tuple[int, int, bytes]
_CMSGArg: TypeAlias = tuple[int, int, ReadableBuffer]
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
# AF_NETLINK, AF_TIPC) or strings/buffers (AF_UNIX).
# See getsockaddrarg() in socketmodule.c.
if sys.version_info >= (3, 14):
# A bare int is accepted for Bluetooth HCI device IDs.
_Address: TypeAlias = tuple[Any, ...] | str | ReadableBuffer | int
else:
_Address: TypeAlias = tuple[Any, ...] | str | ReadableBuffer
_RetAddress: TypeAlias = Any
# ===== Constants =====
# This matches the order in the CPython documentation
# https://docs.python.org/3/library/socket.html#constants
if sys.platform != "win32":
AF_UNIX: Final[int]
AF_INET: Final[int]
AF_INET6: Final[int]
AF_UNSPEC: Final[int]
SOCK_STREAM: Final[int]
SOCK_DGRAM: Final[int]
SOCK_RAW: Final[int]
SOCK_RDM: Final[int]
SOCK_SEQPACKET: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 2.6.27
SOCK_CLOEXEC: Final[int]
SOCK_NONBLOCK: Final[int]
# --------------------
# Many constants of these forms, documented in the Unix documentation on
# sockets and/or the IP protocol, are also defined in the socket module.
# SO_*
# socket.SOMAXCONN
# MSG_*
# SOL_*
# SCM_*
# IPPROTO_*
# IPPORT_*
# INADDR_*
# IP_*
# IPV6_*
# EAI_*
# AI_*
# NI_*
# TCP_*
# --------------------
SO_ACCEPTCONN: Final[int]
SO_BROADCAST: Final[int]
SO_DEBUG: Final[int]
SO_DONTROUTE: Final[int]
SO_ERROR: Final[int]
SO_KEEPALIVE: Final[int]
SO_LINGER: Final[int]
SO_OOBINLINE: Final[int]
SO_RCVBUF: Final[int]
SO_RCVLOWAT: Final[int]
SO_RCVTIMEO: Final[int]
SO_REUSEADDR: Final[int]
SO_SNDBUF: Final[int]
SO_SNDLOWAT: Final[int]
SO_SNDTIMEO: Final[int]
SO_TYPE: Final[int]
if sys.platform != "linux":
SO_USELOOPBACK: Final[int]
if sys.platform == "win32":
SO_EXCLUSIVEADDRUSE: Final[int]
if sys.platform != "win32":
SO_REUSEPORT: Final[int]
if sys.platform != "darwin" or sys.version_info >= (3, 13):
SO_BINDTODEVICE: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
SO_DOMAIN: Final[int]
SO_MARK: Final[int]
SO_PASSCRED: Final[int]
SO_PASSSEC: Final[int]
SO_PEERCRED: Final[int]
SO_PEERSEC: Final[int]
SO_PRIORITY: Final[int]
SO_PROTOCOL: Final[int]
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
SO_SETFIB: Final[int]
if sys.platform == "linux" and sys.version_info >= (3, 13):
SO_BINDTOIFINDEX: Final[int]
SOMAXCONN: Final[int]
MSG_CTRUNC: Final[int]
MSG_DONTROUTE: Final[int]
MSG_OOB: Final[int]
MSG_PEEK: Final[int]
MSG_TRUNC: Final[int]
MSG_WAITALL: Final[int]
if sys.platform != "win32":
MSG_DONTWAIT: Final[int]
MSG_EOR: Final[int]
MSG_NOSIGNAL: Final[int] # Sometimes this exists on darwin, sometimes not
if sys.platform != "darwin":
MSG_ERRQUEUE: Final[int]
if sys.platform == "win32":
MSG_BCAST: Final[int]
MSG_MCAST: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
MSG_CMSG_CLOEXEC: Final[int]
MSG_CONFIRM: Final[int]
MSG_FASTOPEN: Final[int]
MSG_MORE: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
MSG_EOF: Final[int]
if sys.platform != "win32" and sys.platform != "linux" and sys.platform != "darwin":
MSG_NOTIFICATION: Final[int]
MSG_BTAG: Final[int] # Not FreeBSD either
MSG_ETAG: Final[int] # Not FreeBSD either
SOL_IP: Final[int]
SOL_SOCKET: Final[int]
SOL_TCP: Final[int]
SOL_UDP: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
# Defined in socket.h for Linux, but these aren't always present for
# some reason.
SOL_ATALK: Final[int]
SOL_AX25: Final[int]
SOL_HCI: Final[int]
SOL_IPX: Final[int]
SOL_NETROM: Final[int]
SOL_ROSE: Final[int]
if sys.platform != "win32":
SCM_RIGHTS: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
SCM_CREDENTIALS: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
SCM_CREDS: Final[int]
IPPROTO_ICMP: Final[int]
IPPROTO_IP: Final[int]
IPPROTO_RAW: Final[int]
IPPROTO_TCP: Final[int]
IPPROTO_UDP: Final[int]
IPPROTO_AH: Final[int]
IPPROTO_DSTOPTS: Final[int]
IPPROTO_EGP: Final[int]
IPPROTO_ESP: Final[int]
IPPROTO_FRAGMENT: Final[int]
IPPROTO_HOPOPTS: Final[int]
IPPROTO_ICMPV6: Final[int]
IPPROTO_IDP: Final[int]
IPPROTO_IGMP: Final[int]
IPPROTO_IPV6: Final[int]
IPPROTO_NONE: Final[int]
IPPROTO_PIM: Final[int]
IPPROTO_PUP: Final[int]
IPPROTO_ROUTING: Final[int]
IPPROTO_SCTP: Final[int]
if sys.platform != "linux":
IPPROTO_GGP: Final[int]
IPPROTO_IPV4: Final[int]
IPPROTO_MAX: Final[int]
IPPROTO_ND: Final[int]
if sys.platform == "win32":
IPPROTO_CBT: Final[int]
IPPROTO_ICLFXBM: Final[int]
IPPROTO_IGP: Final[int]
IPPROTO_L2TP: Final[int]
IPPROTO_PGM: Final[int]
IPPROTO_RDP: Final[int]
IPPROTO_ST: Final[int]
if sys.platform != "win32":
IPPROTO_GRE: Final[int]
IPPROTO_IPIP: Final[int]
IPPROTO_RSVP: Final[int]
IPPROTO_TP: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
IPPROTO_EON: Final[int]
IPPROTO_HELLO: Final[int]
IPPROTO_IPCOMP: Final[int]
IPPROTO_XTP: Final[int]
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
IPPROTO_BIP: Final[int] # Not FreeBSD either
IPPROTO_MOBILE: Final[int] # Not FreeBSD either
IPPROTO_VRRP: Final[int] # Not FreeBSD either
if sys.platform == "linux":
# Availability: Linux >= 2.6.20, FreeBSD >= 10.1
IPPROTO_UDPLITE: Final[int]
if sys.platform == "linux":
IPPROTO_MPTCP: Final[int]
IPPORT_RESERVED: Final[int]
IPPORT_USERRESERVED: Final[int]
INADDR_ALLHOSTS_GROUP: Final[int]
INADDR_ANY: Final[int]
INADDR_BROADCAST: Final[int]
INADDR_LOOPBACK: Final[int]
INADDR_MAX_LOCAL_GROUP: Final[int]
INADDR_NONE: Final[int]
INADDR_UNSPEC_GROUP: Final[int]
IP_ADD_MEMBERSHIP: Final[int]
IP_DROP_MEMBERSHIP: Final[int]
IP_HDRINCL: Final[int]
IP_MULTICAST_IF: Final[int]
IP_MULTICAST_LOOP: Final[int]
IP_MULTICAST_TTL: Final[int]
IP_OPTIONS: Final[int]
if sys.platform != "linux":
IP_RECVDSTADDR: Final[int]
IP_RECVTOS: Final[int]
IP_TOS: Final[int]
IP_TTL: Final[int]
if sys.platform != "win32":
IP_DEFAULT_MULTICAST_LOOP: Final[int]
IP_DEFAULT_MULTICAST_TTL: Final[int]
IP_MAX_MEMBERSHIPS: Final[int]
IP_RECVOPTS: Final[int]
IP_RECVRETOPTS: Final[int]
IP_RETOPTS: Final[int]
if sys.version_info >= (3, 13) and sys.platform == "linux":
CAN_RAW_ERR_FILTER: Final[int]
if sys.version_info >= (3, 15):
if sys.platform == "win32" or sys.platform == "linux":
IPV6_HDRINCL: Final[int]
if sys.version_info >= (3, 14):
IP_RECVTTL: Final[int]
if sys.platform == "win32" or sys.platform == "linux":
IPV6_RECVERR: Final[int]
IP_RECVERR: Final[int]
SO_ORIGINAL_DST: Final[int]
if sys.platform == "win32":
SOL_RFCOMM: Final[int]
SO_BTH_ENCRYPT: Final[int]
SO_BTH_MTU: Final[int]
SO_BTH_MTU_MAX: Final[int]
SO_BTH_MTU_MIN: Final[int]
TCP_QUICKACK: Final[int]
if sys.platform == "linux":
BDADDR_BREDR: Final[int]
BDADDR_LE_PUBLIC: Final[int]
BDADDR_LE_RANDOM: Final[int]
BT_CHANNEL_POLICY: Final[int]
BT_CHANNEL_POLICY_BREDR_ONLY: Final[int]
BT_CHANNEL_POLICY_BREDR_PREFERRED: Final[int]
BT_CODEC: Final[int]
BT_DEFER_SETUP: Final[int]
BT_FLUSHABLE: Final[int]
BT_FLUSHABLE_OFF: Final[int]
BT_FLUSHABLE_ON: Final[int]
BT_ISO_QOS: Final[int]
BT_MODE: Final[int]
BT_MODE_BASIC: Final[int]
BT_MODE_ERTM: Final[int]
BT_MODE_EXT_FLOWCTL: Final[int]
BT_MODE_LE_FLOWCTL: Final[int]
BT_MODE_STREAMING: Final[int]
BT_PHY: Final[int]
BT_PHY_BR_1M_1SLOT: Final[int]
BT_PHY_BR_1M_3SLOT: Final[int]
BT_PHY_BR_1M_5SLOT: Final[int]
BT_PHY_EDR_2M_1SLOT: Final[int]
BT_PHY_EDR_2M_3SLOT: Final[int]
BT_PHY_EDR_2M_5SLOT: Final[int]
BT_PHY_EDR_3M_1SLOT: Final[int]
BT_PHY_EDR_3M_3SLOT: Final[int]
BT_PHY_EDR_3M_5SLOT: Final[int]
BT_PHY_LE_1M_RX: Final[int]
BT_PHY_LE_1M_TX: Final[int]
BT_PHY_LE_2M_RX: Final[int]
BT_PHY_LE_2M_TX: Final[int]
BT_PHY_LE_CODED_RX: Final[int]
BT_PHY_LE_CODED_TX: Final[int]
BT_PKT_STATUS: Final[int]
BT_POWER: Final[int]
BT_POWER_FORCE_ACTIVE_OFF: Final[int]
BT_POWER_FORCE_ACTIVE_ON: Final[int]
BT_RCVMTU: Final[int]
BT_SECURITY: Final[int]
BT_SECURITY_FIPS: Final[int]
BT_SECURITY_HIGH: Final[int]
BT_SECURITY_LOW: Final[int]
BT_SECURITY_MEDIUM: Final[int]
BT_SECURITY_SDP: Final[int]
BT_SNDMTU: Final[int]
BT_VOICE: Final[int]
BT_VOICE_CVSD_16BIT: Final[int]
BT_VOICE_TRANSPARENT: Final[int]
BT_VOICE_TRANSPARENT_16BIT: Final[int]
HCI_CHANNEL_CONTROL: Final[int]
HCI_CHANNEL_LOGGING: Final[int]
HCI_CHANNEL_MONITOR: Final[int]
HCI_CHANNEL_RAW: Final[int]
HCI_CHANNEL_USER: Final[int]
HCI_DEV_NONE: Final[int]
IP_FREEBIND: Final[int]
IP_RECVORIGDSTADDR: Final[int]
L2CAP_LM: Final[int]
L2CAP_LM_AUTH: Final[int]
L2CAP_LM_ENCRYPT: Final[int]
L2CAP_LM_MASTER: Final[int]
L2CAP_LM_RELIABLE: Final[int]
L2CAP_LM_SECURE: Final[int]
L2CAP_LM_TRUSTED: Final[int]
SOL_BLUETOOTH: Final[int]
SOL_L2CAP: Final[int]
SOL_RFCOMM: Final[int]
SOL_SCO: Final[int]
VMADDR_CID_LOCAL: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
IP_TRANSPARENT: Final[int]
if sys.platform != "win32" and sys.platform != "darwin" and sys.version_info >= (3, 11):
IP_BIND_ADDRESS_NO_PORT: Final[int]
if sys.version_info >= (3, 12):
IP_ADD_SOURCE_MEMBERSHIP: Final[int]
IP_BLOCK_SOURCE: Final[int]
IP_DROP_SOURCE_MEMBERSHIP: Final[int]
IP_PKTINFO: Final[int]
IP_UNBLOCK_SOURCE: Final[int]
IPV6_CHECKSUM: Final[int]
IPV6_JOIN_GROUP: Final[int]
IPV6_LEAVE_GROUP: Final[int]
IPV6_MULTICAST_HOPS: Final[int]
IPV6_MULTICAST_IF: Final[int]
IPV6_MULTICAST_LOOP: Final[int]
IPV6_RECVTCLASS: Final[int]
IPV6_TCLASS: Final[int]
IPV6_UNICAST_HOPS: Final[int]
IPV6_V6ONLY: Final[int]
IPV6_DONTFRAG: Final[int]
IPV6_HOPLIMIT: Final[int]
IPV6_HOPOPTS: Final[int]
IPV6_PKTINFO: Final[int]
IPV6_RECVRTHDR: Final[int]
IPV6_RTHDR: Final[int]
if sys.platform != "win32":
IPV6_RTHDR_TYPE_0: Final[int]
IPV6_DSTOPTS: Final[int]
IPV6_NEXTHOP: Final[int]
IPV6_PATHMTU: Final[int]
IPV6_RECVDSTOPTS: Final[int]
IPV6_RECVHOPLIMIT: Final[int]
IPV6_RECVHOPOPTS: Final[int]
IPV6_RECVPATHMTU: Final[int]
IPV6_RECVPKTINFO: Final[int]
IPV6_RTHDRDSTOPTS: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
IPV6_USE_MIN_MTU: Final[int]
EAI_AGAIN: Final[int]
EAI_BADFLAGS: Final[int]
EAI_FAIL: Final[int]
EAI_FAMILY: Final[int]
EAI_MEMORY: Final[int]
EAI_NODATA: Final[int]
EAI_NONAME: Final[int]
EAI_SERVICE: Final[int]
EAI_SOCKTYPE: Final[int]
if sys.platform != "win32":
EAI_ADDRFAMILY: Final[int]
EAI_OVERFLOW: Final[int]
EAI_SYSTEM: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
EAI_BADHINTS: Final[int]
EAI_MAX: Final[int]
EAI_PROTOCOL: Final[int]
AI_ADDRCONFIG: Final[int]
AI_ALL: Final[int]
AI_CANONNAME: Final[int]
AI_NUMERICHOST: Final[int]
AI_NUMERICSERV: Final[int]
AI_PASSIVE: Final[int]
AI_V4MAPPED: Final[int]
if sys.platform != "win32" and sys.platform != "linux":
AI_DEFAULT: Final[int]
AI_MASK: Final[int]
AI_V4MAPPED_CFG: Final[int]
NI_DGRAM: Final[int]
NI_MAXHOST: Final[int]
NI_MAXSERV: Final[int]
NI_NAMEREQD: Final[int]
NI_NOFQDN: Final[int]
NI_NUMERICHOST: Final[int]
NI_NUMERICSERV: Final[int]
if sys.platform == "linux" and sys.version_info >= (3, 13):
NI_IDN: Final[int]
TCP_FASTOPEN: Final[int]
TCP_KEEPCNT: Final[int]
TCP_KEEPINTVL: Final[int]
TCP_MAXSEG: Final[int]
TCP_NODELAY: Final[int]
if sys.platform != "win32":
TCP_NOTSENT_LOWAT: Final[int]
if sys.platform != "darwin":
TCP_KEEPIDLE: Final[int]
if sys.platform == "darwin":
TCP_KEEPALIVE: Final[int]
if sys.version_info >= (3, 11) and sys.platform == "darwin":
TCP_CONNECTION_INFO: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
TCP_CONGESTION: Final[int]
TCP_CORK: Final[int]
TCP_DEFER_ACCEPT: Final[int]
TCP_INFO: Final[int]
TCP_LINGER2: Final[int]
TCP_QUICKACK: Final[int]
TCP_SYNCNT: Final[int]
TCP_USER_TIMEOUT: Final[int]
TCP_WINDOW_CLAMP: Final[int]
if sys.platform == "linux" and sys.version_info >= (3, 12):
TCP_CC_INFO: Final[int]
TCP_FASTOPEN_CONNECT: Final[int]
TCP_FASTOPEN_KEY: Final[int]
TCP_FASTOPEN_NO_COOKIE: Final[int]
TCP_INQ: Final[int]
TCP_MD5SIG: Final[int]
TCP_MD5SIG_EXT: Final[int]
TCP_QUEUE_SEQ: Final[int]
TCP_REPAIR: Final[int]
TCP_REPAIR_OPTIONS: Final[int]
TCP_REPAIR_QUEUE: Final[int]
TCP_REPAIR_WINDOW: Final[int]
TCP_SAVED_SYN: Final[int]
TCP_SAVE_SYN: Final[int]
TCP_THIN_DUPACK: Final[int]
TCP_THIN_LINEAR_TIMEOUTS: Final[int]
TCP_TIMESTAMP: Final[int]
TCP_TX_DELAY: Final[int]
TCP_ULP: Final[int]
TCP_ZEROCOPY_RECEIVE: Final[int]
# --------------------
# Specifically documented constants
# --------------------
if sys.platform == "linux":
# Availability: Linux >= 2.6.25, NetBSD >= 8
AF_CAN: Final[int]
PF_CAN: Final[int]
SOL_CAN_BASE: Final[int]
SOL_CAN_RAW: Final[int]
CAN_EFF_FLAG: Final[int]
CAN_EFF_MASK: Final[int]
CAN_ERR_FLAG: Final[int]
CAN_ERR_MASK: Final[int]
CAN_RAW: Final[int]
CAN_RAW_FILTER: Final[int]
CAN_RAW_LOOPBACK: Final[int]
CAN_RAW_RECV_OWN_MSGS: Final[int]
CAN_RTR_FLAG: Final[int]
CAN_SFF_MASK: Final[int]
if sys.version_info < (3, 11):
CAN_RAW_ERR_FILTER: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 2.6.25
CAN_BCM: Final[int]
CAN_BCM_TX_SETUP: Final[int]
CAN_BCM_TX_DELETE: Final[int]
CAN_BCM_TX_READ: Final[int]
CAN_BCM_TX_SEND: Final[int]
CAN_BCM_RX_SETUP: Final[int]
CAN_BCM_RX_DELETE: Final[int]
CAN_BCM_RX_READ: Final[int]
CAN_BCM_TX_STATUS: Final[int]
CAN_BCM_TX_EXPIRED: Final[int]
CAN_BCM_RX_STATUS: Final[int]
CAN_BCM_RX_TIMEOUT: Final[int]
CAN_BCM_RX_CHANGED: Final[int]
CAN_BCM_SETTIMER: Final[int]
CAN_BCM_STARTTIMER: Final[int]
CAN_BCM_TX_COUNTEVT: Final[int]
CAN_BCM_TX_ANNOUNCE: Final[int]
CAN_BCM_TX_CP_CAN_ID: Final[int]
CAN_BCM_RX_FILTER_ID: Final[int]
CAN_BCM_RX_CHECK_DLC: Final[int]
CAN_BCM_RX_NO_AUTOTIMER: Final[int]
CAN_BCM_RX_ANNOUNCE_RESUME: Final[int]
CAN_BCM_TX_RESET_MULTI_IDX: Final[int]
CAN_BCM_RX_RTR_FRAME: Final[int]
CAN_BCM_CAN_FD_FRAME: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 3.6
CAN_RAW_FD_FRAMES: Final[int]
# Availability: Linux >= 4.1
CAN_RAW_JOIN_FILTERS: Final[int]
# Availability: Linux >= 2.6.25
CAN_ISOTP: Final[int]
if sys.version_info >= (3, 15):
CAN_ISOTP_CHK_PAD_DATA: Final[int]
CAN_ISOTP_CHK_PAD_LEN: Final[int]
CAN_ISOTP_DEFAULT_EXT_ADDRESS: Final[int]
CAN_ISOTP_DEFAULT_FLAGS: Final[int]
CAN_ISOTP_DEFAULT_FRAME_TXTIME: Final[int]
CAN_ISOTP_DEFAULT_LL_MTU: Final[int]
CAN_ISOTP_DEFAULT_LL_TX_DL: Final[int]
CAN_ISOTP_DEFAULT_LL_TX_FLAGS: Final[int]
CAN_ISOTP_DEFAULT_PAD_CONTENT: Final[int]
CAN_ISOTP_DEFAULT_RECV_BS: Final[int]
CAN_ISOTP_DEFAULT_RECV_STMIN: Final[int]
CAN_ISOTP_DEFAULT_RECV_WFTMAX: Final[int]
CAN_ISOTP_EXTEND_ADDR: Final[int]
CAN_ISOTP_FORCE_RXSTMIN: Final[int]
CAN_ISOTP_FORCE_TXSTMIN: Final[int]
CAN_ISOTP_HALF_DUPLEX: Final[int]
CAN_ISOTP_LL_OPTS: Final[int]
CAN_ISOTP_LISTEN_MODE: Final[int]
CAN_ISOTP_OPTS: Final[int]
CAN_ISOTP_RECV_FC: Final[int]
CAN_ISOTP_RX_EXT_ADDR: Final[int]
CAN_ISOTP_RX_PADDING: Final[int]
CAN_ISOTP_RX_STMIN: Final[int]
CAN_ISOTP_SF_BROADCAST: Final[int]
CAN_ISOTP_TX_PADDING: Final[int]
CAN_ISOTP_TX_STMIN: Final[int]
CAN_ISOTP_WAIT_TX_DONE: Final[int]
SOL_CAN_ISOTP: Final[int]
# Availability: Linux >= 5.4
CAN_J1939: Final[int]
J1939_MAX_UNICAST_ADDR: Final[int]
J1939_IDLE_ADDR: Final[int]
J1939_NO_ADDR: Final[int]
J1939_NO_NAME: Final[int]
J1939_PGN_REQUEST: Final[int]
J1939_PGN_ADDRESS_CLAIMED: Final[int]
J1939_PGN_ADDRESS_COMMANDED: Final[int]
J1939_PGN_PDU1_MAX: Final[int]
J1939_PGN_MAX: Final[int]
J1939_NO_PGN: Final[int]
SO_J1939_FILTER: Final[int]
SO_J1939_PROMISC: Final[int]
SO_J1939_SEND_PRIO: Final[int]
SO_J1939_ERRQUEUE: Final[int]
SCM_J1939_DEST_ADDR: Final[int]
SCM_J1939_DEST_NAME: Final[int]
SCM_J1939_PRIO: Final[int]
SCM_J1939_ERRQUEUE: Final[int]
J1939_NLA_PAD: Final[int]
J1939_NLA_BYTES_ACKED: Final[int]
J1939_EE_INFO_NONE: Final[int]
J1939_EE_INFO_TX_ABORT: Final[int]
J1939_FILTER_MAX: Final[int]
if sys.version_info >= (3, 12) and sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
# Availability: FreeBSD >= 14.0
AF_DIVERT: Final[int]
PF_DIVERT: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 2.2
AF_PACKET: Final[int]
PF_PACKET: Final[int]
PACKET_BROADCAST: Final[int]
PACKET_FASTROUTE: Final[int]
PACKET_HOST: Final[int]
PACKET_LOOPBACK: Final[int]
PACKET_MULTICAST: Final[int]
PACKET_OTHERHOST: Final[int]
PACKET_OUTGOING: Final[int]
if sys.version_info >= (3, 12) and sys.platform == "linux":
ETH_P_ALL: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 2.6.30
AF_RDS: Final[int]
PF_RDS: Final[int]
SOL_RDS: Final[int]
# These are present in include/linux/rds.h but don't always show up
# here.
RDS_CANCEL_SENT_TO: Final[int]
RDS_CMSG_RDMA_ARGS: Final[int]
RDS_CMSG_RDMA_DEST: Final[int]
RDS_CMSG_RDMA_MAP: Final[int]
RDS_CMSG_RDMA_STATUS: Final[int]
RDS_CONG_MONITOR: Final[int]
RDS_FREE_MR: Final[int]
RDS_GET_MR: Final[int]
RDS_GET_MR_FOR_DEST: Final[int]
RDS_RDMA_DONTWAIT: Final[int]
RDS_RDMA_FENCE: Final[int]
RDS_RDMA_INVALIDATE: Final[int]
RDS_RDMA_NOTIFY_ME: Final[int]
RDS_RDMA_READWRITE: Final[int]
RDS_RDMA_SILENT: Final[int]
RDS_RDMA_USE_ONCE: Final[int]
RDS_RECVERR: Final[int]
# This is supported by CPython but doesn't seem to be a real thing.
# The closest existing constant in rds.h is RDS_CMSG_CONG_UPDATE
# RDS_CMSG_RDMA_UPDATE: Final[int]
if sys.platform == "win32":
SIO_RCVALL: Final[int]
SIO_KEEPALIVE_VALS: Final[int]
SIO_LOOPBACK_FAST_PATH: Final[int]
RCVALL_MAX: Final[int]
RCVALL_OFF: Final[int]
RCVALL_ON: Final[int]
RCVALL_SOCKETLEVELONLY: Final[int]
if sys.platform == "linux":
AF_TIPC: Final[int]
SOL_TIPC: Final[int]
TIPC_ADDR_ID: Final[int]
TIPC_ADDR_NAME: Final[int]
TIPC_ADDR_NAMESEQ: Final[int]
TIPC_CFG_SRV: Final[int]
TIPC_CLUSTER_SCOPE: Final[int]
TIPC_CONN_TIMEOUT: Final[int]
TIPC_CRITICAL_IMPORTANCE: Final[int]
TIPC_DEST_DROPPABLE: Final[int]
TIPC_HIGH_IMPORTANCE: Final[int]
TIPC_IMPORTANCE: Final[int]
TIPC_LOW_IMPORTANCE: Final[int]
TIPC_MEDIUM_IMPORTANCE: Final[int]
TIPC_NODE_SCOPE: Final[int]
TIPC_PUBLISHED: Final[int]
TIPC_SRC_DROPPABLE: Final[int]
TIPC_SUBSCR_TIMEOUT: Final[int]
TIPC_SUB_CANCEL: Final[int]
TIPC_SUB_PORTS: Final[int]
TIPC_SUB_SERVICE: Final[int]
TIPC_TOP_SRV: Final[int]
TIPC_WAIT_FOREVER: Final[int]
TIPC_WITHDRAWN: Final[int]
TIPC_ZONE_SCOPE: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 2.6.38
AF_ALG: Final[int]
SOL_ALG: Final[int]
ALG_OP_DECRYPT: Final[int]
ALG_OP_ENCRYPT: Final[int]
ALG_OP_SIGN: Final[int]
ALG_OP_VERIFY: Final[int]
ALG_SET_AEAD_ASSOCLEN: Final[int]
ALG_SET_AEAD_AUTHSIZE: Final[int]
ALG_SET_IV: Final[int]
ALG_SET_KEY: Final[int]
ALG_SET_OP: Final[int]
ALG_SET_PUBKEY: Final[int]
if sys.platform == "linux":
# Availability: Linux >= 4.8 (or maybe 3.9, CPython docs are confusing)
AF_VSOCK: Final[int]
IOCTL_VM_SOCKETS_GET_LOCAL_CID: Final = 0x7B9
VMADDR_CID_ANY: Final = 0xFFFFFFFF
VMADDR_CID_HOST: Final = 2
VMADDR_PORT_ANY: Final = 0xFFFFFFFF
SO_VM_SOCKETS_BUFFER_MAX_SIZE: Final = 2
SO_VM_SOCKETS_BUFFER_SIZE: Final = 0
SO_VM_SOCKETS_BUFFER_MIN_SIZE: Final = 1
VM_SOCKETS_INVALID_VERSION: Final = 0xFFFFFFFF # undocumented
# Documented as only available on BSD, macOS, but empirically sometimes
# available on Windows
if sys.platform != "linux":
AF_LINK: Final[int]
has_ipv6: bool
if sys.platform != "darwin":
BDADDR_ANY: Final = "00:00:00:00:00:00"
BDADDR_LOCAL: Final = "00:00:00:FF:FF:FF"
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
HCI_FILTER: Final[int] # not in NetBSD or DragonFlyBSD
HCI_TIME_STAMP: Final[int] # not in FreeBSD, NetBSD, or DragonFlyBSD
HCI_DATA_DIR: Final[int] # not in FreeBSD, NetBSD, or DragonFlyBSD
if sys.platform == "linux":
AF_QIPCRTR: Final[int] # Availability: Linux >= 4.7
if sys.version_info >= (3, 11) and sys.platform != "linux" and sys.platform != "win32" and sys.platform != "darwin":
# FreeBSD
SCM_CREDS2: Final[int]
LOCAL_CREDS: Final[int]
LOCAL_CREDS_PERSISTENT: Final[int]
if sys.version_info >= (3, 11) and sys.platform == "linux":
SO_INCOMING_CPU: Final[int] # Availability: Linux >= 3.9
if sys.version_info >= (3, 12) and sys.platform == "win32":
# Availability: Windows
AF_HYPERV: Final[int]
HV_PROTOCOL_RAW: Final[int]
HVSOCKET_CONNECT_TIMEOUT: Final[int]
HVSOCKET_CONNECT_TIMEOUT_MAX: Final[int]
HVSOCKET_CONNECTED_SUSPEND: Final[int]
HVSOCKET_ADDRESS_FLAG_PASSTHRU: Final[int]
HV_GUID_ZERO: Final = "00000000-0000-0000-0000-000000000000"
HV_GUID_WILDCARD: Final = "00000000-0000-0000-0000-000000000000"
HV_GUID_BROADCAST: Final = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"
HV_GUID_CHILDREN: Final = "90DB8B89-0D35-4F79-8CE9-49EA0AC8B7CD"
HV_GUID_LOOPBACK: Final = "E0E16197-DD56-4A10-9195-5EE7A155A838"
HV_GUID_PARENT: Final = "A42E7CDA-D03F-480C-9CC2-A4DE20ABB878"
if sys.version_info >= (3, 12):
if sys.platform != "win32":
# Availability: Linux, FreeBSD, macOS
ETHERTYPE_ARP: Final[int]
ETHERTYPE_IP: Final[int]
ETHERTYPE_IPV6: Final[int]
ETHERTYPE_VLAN: Final[int]
# --------------------
# Semi-documented constants
# These are alluded to under the "Socket families" section in the docs
# https://docs.python.org/3/library/socket.html#socket-families
# --------------------
if sys.platform == "linux":
# Netlink is defined by Linux
AF_NETLINK: Final[int]
NETLINK_CRYPTO: Final[int]
NETLINK_DNRTMSG: Final[int]
NETLINK_FIREWALL: Final[int]
NETLINK_IP6_FW: Final[int]
NETLINK_NFLOG: Final[int]
NETLINK_ROUTE: Final[int]
NETLINK_USERSOCK: Final[int]
NETLINK_XFRM: Final[int]
# Technically still supported by CPython
# NETLINK_ARPD: Final[int] # linux 2.0 to 2.6.12 (EOL August 2005)
# NETLINK_ROUTE6: Final[int] # linux 2.2 to 2.6.12 (EOL August 2005)
# NETLINK_SKIP: Final[int] # linux 2.0 to 2.6.12 (EOL August 2005)
# NETLINK_TAPBASE: Final[int] # linux 2.2 to 2.6.12 (EOL August 2005)
# NETLINK_TCPDIAG: Final[int] # linux 2.6.0 to 2.6.13 (EOL December 2005)
# NETLINK_W1: Final[int] # linux 2.6.13 to 2.6.17 (EOL October 2006)
if sys.platform == "darwin":
PF_SYSTEM: Final[int]
SYSPROTO_CONTROL: Final[int]
if sys.platform != "darwin":
AF_BLUETOOTH: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
# Linux and some BSD support is explicit in the docs
# Windows and macOS do not support in practice
BTPROTO_HCI: Final[int]
BTPROTO_L2CAP: Final[int]
BTPROTO_SCO: Final[int] # not in FreeBSD
if sys.platform != "darwin":
BTPROTO_RFCOMM: Final[int]
if sys.platform == "linux":
UDPLITE_RECV_CSCOV: Final[int]
UDPLITE_SEND_CSCOV: Final[int]
# --------------------
# Documented under socket.shutdown
# --------------------
SHUT_RD: Final[int]
SHUT_RDWR: Final[int]
SHUT_WR: Final[int]
# --------------------
# Undocumented constants
# --------------------
# Undocumented address families
AF_APPLETALK: Final[int]
AF_DECnet: Final[int]
AF_IPX: Final[int]
AF_SNA: Final[int]
if sys.platform != "win32":
AF_ROUTE: Final[int]
if sys.platform == "darwin":
AF_SYSTEM: Final[int]
if sys.platform != "darwin":
AF_IRDA: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
AF_ASH: Final[int]
AF_ATMPVC: Final[int]
AF_ATMSVC: Final[int]
AF_AX25: Final[int]
AF_BRIDGE: Final[int]
AF_ECONET: Final[int]
AF_KEY: Final[int]
AF_LLC: Final[int]
AF_NETBEUI: Final[int]
AF_NETROM: Final[int]
AF_PPPOX: Final[int]
AF_ROSE: Final[int]
AF_SECURITY: Final[int]
AF_WANPIPE: Final[int]
AF_X25: Final[int]
# Miscellaneous undocumented
if sys.platform != "win32" and sys.platform != "linux":
LOCAL_PEERCRED: Final[int]
if sys.platform != "win32" and sys.platform != "darwin":
# Defined in linux socket.h, but this isn't always present for
# some reason.
IPX_TYPE: Final[int]
# ===== Classes =====
@disjoint_base
class socket:
@property
def family(self) -> int: ...
@property
def type(self) -> int: ...
@property
def proto(self) -> int: ...
# F811: "Redefinition of unused `timeout`"
@property
def timeout(self) -> float | None: ...
if sys.platform == "win32":
def __init__(
self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | bytes | None = None
) -> None: ...
else:
def __init__(self, family: int = ..., type: int = ..., proto: int = ..., fileno: SupportsIndex | None = None) -> None: ...
def bind(self, address: _Address, /) -> None: ...
def close(self) -> None: ...
def connect(self, address: _Address, /) -> None: ...
def connect_ex(self, address: _Address, /) -> int: ...
def detach(self) -> int: ...
def fileno(self) -> int: ...
def getpeername(self) -> _RetAddress: ...
def getsockname(self) -> _RetAddress: ...
@overload
def getsockopt(self, level: int, optname: int, /) -> int: ...
@overload
def getsockopt(self, level: int, optname: int, buflen: int, /) -> bytes: ...
def getblocking(self) -> bool: ...
def gettimeout(self) -> float | None: ...
if sys.platform == "win32":
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool, /) -> None: ...
def listen(self, backlog: int = ..., /) -> None: ...
def recv(self, bufsize: int, flags: int = 0, /) -> bytes: ...
def recvfrom(self, bufsize: int, flags: int = 0, /) -> tuple[bytes, _RetAddress]: ...
if sys.platform != "win32":
def recvmsg(self, bufsize: int, ancbufsize: int = 0, flags: int = 0, /) -> tuple[bytes, list[_CMSG], int, Any]: ...
def recvmsg_into(
self, buffers: Iterable[WriteableBuffer], ancbufsize: int = 0, flags: int = 0, /
) -> tuple[int, list[_CMSG], int, Any]: ...
def recvfrom_into(self, buffer: WriteableBuffer, nbytes: int = 0, flags: int = 0) -> tuple[int, _RetAddress]: ...
def recv_into(self, buffer: WriteableBuffer, nbytes: int = 0, flags: int = 0) -> int: ...
def send(self, data: ReadableBuffer, flags: int = 0, /) -> int: ...
def sendall(self, data: ReadableBuffer, flags: int = 0, /) -> None: ...
@overload
def sendto(self, data: ReadableBuffer, address: _Address, /) -> int: ...
@overload
def sendto(self, data: ReadableBuffer, flags: int, address: _Address, /) -> int: ...
if sys.platform != "win32":
def sendmsg(
self,
buffers: Iterable[ReadableBuffer],
ancdata: Iterable[_CMSGArg] = ...,
flags: int = 0,
address: _Address | None = None,
/,
) -> int: ...
if sys.platform == "linux":
def sendmsg_afalg(
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = 0
) -> int: ...
def setblocking(self, flag: bool, /) -> None: ...
def settimeout(self, value: float | None, /) -> None: ...
@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: ...
if sys.platform == "win32":
def share(self, process_id: int, /) -> bytes: ...
def shutdown(self, how: int, /) -> None: ...
SocketType = socket
# ===== Functions =====
def close(fd: SupportsIndex, /) -> None: ...
def dup(fd: SupportsIndex, /) -> int: ...
# the 5th tuple item is an address
def getaddrinfo(
host: bytes | str | None, port: bytes | str | int | None, family: int = ..., type: int = 0, proto: int = 0, flags: int = 0
) -> list[tuple[int, int, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]: ...
def gethostbyname(hostname: str, /) -> str: ...
def gethostbyname_ex(hostname: str, /) -> tuple[str, list[str], list[str]]: ...
def gethostname() -> str: ...
def gethostbyaddr(ip_address: str, /) -> tuple[str, list[str], list[str]]: ...
def getnameinfo(sockaddr: tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes], flags: int, /) -> tuple[str, str]: ...
def getprotobyname(protocolname: str, /) -> int: ...
def getservbyname(servicename: str, protocolname: str = ..., /) -> int: ...
def getservbyport(port: int, protocolname: str = ..., /) -> str: ...
def ntohl(x: int, /) -> int: ... # param & ret val are 32-bit ints
def ntohs(x: int, /) -> int: ... # param & ret val are 16-bit ints
def htonl(x: int, /) -> int: ... # param & ret val are 32-bit ints
def htons(x: int, /) -> int: ... # param & ret val are 16-bit ints
def inet_aton(ip_addr: str, /) -> bytes: ... # ret val 4 bytes in length
def inet_ntoa(packed_ip: ReadableBuffer, /) -> str: ...
def inet_pton(address_family: int, ip_string: str, /) -> bytes: ...
def inet_ntop(address_family: int, packed_ip: ReadableBuffer, /) -> str: ...
def getdefaulttimeout() -> float | None: ...
# F811: "Redefinition of unused `timeout`"
def setdefaulttimeout(timeout: float | None, /) -> None: ...
if sys.platform != "win32":
def sethostname(name: str, /) -> None: ...
def CMSG_LEN(length: int, /) -> int: ...
def CMSG_SPACE(length: int, /) -> int: ...
def socketpair(family: int = ..., type: int = ..., proto: int = 0, /) -> tuple[socket, socket]: ...
def if_nameindex() -> list[tuple[int, str]]: ...
def if_nametoindex(oname: str, /) -> int: ...
if sys.version_info >= (3, 14):
def if_indextoname(if_index: int, /) -> str: ...
else:
def if_indextoname(index: int, /) -> str: ...
CAPI: CapsuleType
@@ -1,311 +0,0 @@
import sys
from _typeshed import ReadableBuffer, StrOrBytesPath
from collections.abc import Callable
from sqlite3 import (
Connection as Connection,
Cursor as Cursor,
DatabaseError as DatabaseError,
DataError as DataError,
Error as Error,
IntegrityError as IntegrityError,
InterfaceError as InterfaceError,
InternalError as InternalError,
NotSupportedError as NotSupportedError,
OperationalError as OperationalError,
PrepareProtocol as PrepareProtocol,
ProgrammingError as ProgrammingError,
Row as Row,
Warning as Warning,
_IsolationLevel,
)
from typing import Any, Final, Literal, TypeAlias, TypeVar, overload
from typing_extensions import deprecated
if sys.version_info >= (3, 11):
from sqlite3 import Blob as Blob
_T = TypeVar("_T")
_ConnectionT = TypeVar("_ConnectionT", bound=Connection)
_SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
_Adapter: TypeAlias = Callable[[_T], _SqliteData]
_Converter: TypeAlias = Callable[[bytes], Any]
PARSE_COLNAMES: Final = 2
PARSE_DECLTYPES: Final = 1
SQLITE_ALTER_TABLE: Final = 26
SQLITE_ANALYZE: Final = 28
SQLITE_ATTACH: Final = 24
SQLITE_CREATE_INDEX: Final = 1
SQLITE_CREATE_TABLE: Final = 2
SQLITE_CREATE_TEMP_INDEX: Final = 3
SQLITE_CREATE_TEMP_TABLE: Final = 4
SQLITE_CREATE_TEMP_TRIGGER: Final = 5
SQLITE_CREATE_TEMP_VIEW: Final = 6
SQLITE_CREATE_TRIGGER: Final = 7
SQLITE_CREATE_VIEW: Final = 8
SQLITE_CREATE_VTABLE: Final = 29
SQLITE_DELETE: Final = 9
SQLITE_DENY: Final = 1
SQLITE_DETACH: Final = 25
SQLITE_DONE: Final = 101
SQLITE_DROP_INDEX: Final = 10
SQLITE_DROP_TABLE: Final = 11
SQLITE_DROP_TEMP_INDEX: Final = 12
SQLITE_DROP_TEMP_TABLE: Final = 13
SQLITE_DROP_TEMP_TRIGGER: Final = 14
SQLITE_DROP_TEMP_VIEW: Final = 15
SQLITE_DROP_TRIGGER: Final = 16
SQLITE_DROP_VIEW: Final = 17
SQLITE_DROP_VTABLE: Final = 30
SQLITE_FUNCTION: Final = 31
SQLITE_IGNORE: Final = 2
SQLITE_INSERT: Final = 18
SQLITE_OK: Final = 0
SQLITE_PRAGMA: Final = 19
SQLITE_READ: Final = 20
SQLITE_RECURSIVE: Final = 33
SQLITE_REINDEX: Final = 27
SQLITE_SAVEPOINT: Final = 32
SQLITE_SELECT: Final = 21
SQLITE_TRANSACTION: Final = 22
SQLITE_UPDATE: Final = 23
if sys.version_info >= (3, 15):
SQLITE_KEYWORDS: tuple[str, ...]
adapters: dict[tuple[type[Any], type[Any]], _Adapter[Any]]
converters: dict[str, _Converter]
sqlite_version: str
if sys.version_info < (3, 12):
version: str
if sys.version_info >= (3, 12):
LEGACY_TRANSACTION_CONTROL: Final = -1
SQLITE_DBCONFIG_DEFENSIVE: Final = 1010
SQLITE_DBCONFIG_DQS_DDL: Final = 1014
SQLITE_DBCONFIG_DQS_DML: Final = 1013
SQLITE_DBCONFIG_ENABLE_FKEY: Final = 1002
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: Final = 1004
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: Final = 1005
SQLITE_DBCONFIG_ENABLE_QPSG: Final = 1007
SQLITE_DBCONFIG_ENABLE_TRIGGER: Final = 1003
SQLITE_DBCONFIG_ENABLE_VIEW: Final = 1015
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: Final = 1012
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: Final = 1016
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: Final = 1006
SQLITE_DBCONFIG_RESET_DATABASE: Final = 1009
SQLITE_DBCONFIG_TRIGGER_EQP: Final = 1008
SQLITE_DBCONFIG_TRUSTED_SCHEMA: Final = 1017
SQLITE_DBCONFIG_WRITABLE_SCHEMA: Final = 1011
if sys.version_info >= (3, 11):
SQLITE_ABORT: Final = 4
SQLITE_ABORT_ROLLBACK: Final = 516
SQLITE_AUTH: Final = 23
SQLITE_AUTH_USER: Final = 279
SQLITE_BUSY: Final = 5
SQLITE_BUSY_RECOVERY: Final = 261
SQLITE_BUSY_SNAPSHOT: Final = 517
SQLITE_BUSY_TIMEOUT: Final = 773
SQLITE_CANTOPEN: Final = 14
SQLITE_CANTOPEN_CONVPATH: Final = 1038
SQLITE_CANTOPEN_DIRTYWAL: Final = 1294
SQLITE_CANTOPEN_FULLPATH: Final = 782
SQLITE_CANTOPEN_ISDIR: Final = 526
SQLITE_CANTOPEN_NOTEMPDIR: Final = 270
SQLITE_CANTOPEN_SYMLINK: Final = 1550
SQLITE_CONSTRAINT: Final = 19
SQLITE_CONSTRAINT_CHECK: Final = 275
SQLITE_CONSTRAINT_COMMITHOOK: Final = 531
SQLITE_CONSTRAINT_FOREIGNKEY: Final = 787
SQLITE_CONSTRAINT_FUNCTION: Final = 1043
SQLITE_CONSTRAINT_NOTNULL: Final = 1299
SQLITE_CONSTRAINT_PINNED: Final = 2835
SQLITE_CONSTRAINT_PRIMARYKEY: Final = 1555
SQLITE_CONSTRAINT_ROWID: Final = 2579
SQLITE_CONSTRAINT_TRIGGER: Final = 1811
SQLITE_CONSTRAINT_UNIQUE: Final = 2067
SQLITE_CONSTRAINT_VTAB: Final = 2323
SQLITE_CORRUPT: Final = 11
SQLITE_CORRUPT_INDEX: Final = 779
SQLITE_CORRUPT_SEQUENCE: Final = 523
SQLITE_CORRUPT_VTAB: Final = 267
SQLITE_EMPTY: Final = 16
SQLITE_ERROR: Final = 1
SQLITE_ERROR_MISSING_COLLSEQ: Final = 257
SQLITE_ERROR_RETRY: Final = 513
SQLITE_ERROR_SNAPSHOT: Final = 769
SQLITE_FORMAT: Final = 24
SQLITE_FULL: Final = 13
SQLITE_INTERNAL: Final = 2
SQLITE_INTERRUPT: Final = 9
SQLITE_IOERR: Final = 10
SQLITE_IOERR_ACCESS: Final = 3338
SQLITE_IOERR_AUTH: Final = 7178
SQLITE_IOERR_BEGIN_ATOMIC: Final = 7434
SQLITE_IOERR_BLOCKED: Final = 2826
SQLITE_IOERR_CHECKRESERVEDLOCK: Final = 3594
SQLITE_IOERR_CLOSE: Final = 4106
SQLITE_IOERR_COMMIT_ATOMIC: Final = 7690
SQLITE_IOERR_CONVPATH: Final = 6666
SQLITE_IOERR_CORRUPTFS: Final = 8458
SQLITE_IOERR_DATA: Final = 8202
SQLITE_IOERR_DELETE: Final = 2570
SQLITE_IOERR_DELETE_NOENT: Final = 5898
SQLITE_IOERR_DIR_CLOSE: Final = 4362
SQLITE_IOERR_DIR_FSYNC: Final = 1290
SQLITE_IOERR_FSTAT: Final = 1802
SQLITE_IOERR_FSYNC: Final = 1034
SQLITE_IOERR_GETTEMPPATH: Final = 6410
SQLITE_IOERR_LOCK: Final = 3850
SQLITE_IOERR_MMAP: Final = 6154
SQLITE_IOERR_NOMEM: Final = 3082
SQLITE_IOERR_RDLOCK: Final = 2314
SQLITE_IOERR_READ: Final = 266
SQLITE_IOERR_ROLLBACK_ATOMIC: Final = 7946
SQLITE_IOERR_SEEK: Final = 5642
SQLITE_IOERR_SHMLOCK: Final = 5130
SQLITE_IOERR_SHMMAP: Final = 5386
SQLITE_IOERR_SHMOPEN: Final = 4618
SQLITE_IOERR_SHMSIZE: Final = 4874
SQLITE_IOERR_SHORT_READ: Final = 522
SQLITE_IOERR_TRUNCATE: Final = 1546
SQLITE_IOERR_UNLOCK: Final = 2058
SQLITE_IOERR_VNODE: Final = 6922
SQLITE_IOERR_WRITE: Final = 778
SQLITE_LIMIT_ATTACHED: Final = 7
SQLITE_LIMIT_COLUMN: Final = 2
SQLITE_LIMIT_COMPOUND_SELECT: Final = 4
SQLITE_LIMIT_EXPR_DEPTH: Final = 3
SQLITE_LIMIT_FUNCTION_ARG: Final = 6
SQLITE_LIMIT_LENGTH: Final = 0
SQLITE_LIMIT_LIKE_PATTERN_LENGTH: Final = 8
SQLITE_LIMIT_SQL_LENGTH: Final = 1
SQLITE_LIMIT_TRIGGER_DEPTH: Final = 10
SQLITE_LIMIT_VARIABLE_NUMBER: Final = 9
SQLITE_LIMIT_VDBE_OP: Final = 5
SQLITE_LIMIT_WORKER_THREADS: Final = 11
SQLITE_LOCKED: Final = 6
SQLITE_LOCKED_SHAREDCACHE: Final = 262
SQLITE_LOCKED_VTAB: Final = 518
SQLITE_MISMATCH: Final = 20
SQLITE_MISUSE: Final = 21
SQLITE_NOLFS: Final = 22
SQLITE_NOMEM: Final = 7
SQLITE_NOTADB: Final = 26
SQLITE_NOTFOUND: Final = 12
SQLITE_NOTICE: Final = 27
SQLITE_NOTICE_RECOVER_ROLLBACK: Final = 539
SQLITE_NOTICE_RECOVER_WAL: Final = 283
SQLITE_OK_LOAD_PERMANENTLY: Final = 256
SQLITE_OK_SYMLINK: Final = 512
SQLITE_PERM: Final = 3
SQLITE_PROTOCOL: Final = 15
SQLITE_RANGE: Final = 25
SQLITE_READONLY: Final = 8
SQLITE_READONLY_CANTINIT: Final = 1288
SQLITE_READONLY_CANTLOCK: Final = 520
SQLITE_READONLY_DBMOVED: Final = 1032
SQLITE_READONLY_DIRECTORY: Final = 1544
SQLITE_READONLY_RECOVERY: Final = 264
SQLITE_READONLY_ROLLBACK: Final = 776
SQLITE_ROW: Final = 100
SQLITE_SCHEMA: Final = 17
SQLITE_TOOBIG: Final = 18
SQLITE_WARNING: Final = 28
SQLITE_WARNING_AUTOINDEX: Final = 284
threadsafety: Literal[0, 1, 3]
# Can take or return anything depending on what's in the registry.
@overload
def adapt(obj: Any, proto: Any, /) -> Any: ...
@overload
def adapt(obj: Any, proto: Any, alt: _T, /) -> Any | _T: ...
def complete_statement(statement: str) -> bool: ...
if sys.version_info >= (3, 12):
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
*,
autocommit: bool = ...,
) -> Connection: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float,
detect_types: int,
isolation_level: _IsolationLevel,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
*,
autocommit: bool = ...,
) -> _ConnectionT: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
autocommit: bool = ...,
) -> _ConnectionT: ...
else:
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
cached_statements: int = 128,
uri: bool = False,
) -> Connection: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float,
detect_types: int,
isolation_level: _IsolationLevel,
check_same_thread: bool,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
) -> _ConnectionT: ...
@overload
def connect(
database: StrOrBytesPath,
timeout: float = 5.0,
detect_types: int = 0,
isolation_level: _IsolationLevel = "DEFERRED",
check_same_thread: bool = True,
*,
factory: type[_ConnectionT],
cached_statements: int = 128,
uri: bool = False,
) -> _ConnectionT: ...
def enable_callback_tracebacks(enable: bool, /) -> None: ...
if sys.version_info < (3, 12):
# takes a pos-or-keyword argument because there is a C wrapper
@deprecated(
"Deprecated since Python 3.10; removed in Python 3.12. "
"Open database in URI mode using `cache=shared` parameter instead."
)
def enable_shared_cache(do_enable: int) -> None: ... # undocumented
def register_adapter(type: type[_T], adapter: _Adapter[_T], /) -> None: ...
def register_converter(typename: str, converter: _Converter, /) -> None: ...
@@ -1,303 +0,0 @@
import sys
from _typeshed import ReadableBuffer, StrOrBytesPath
from collections.abc import Callable
from ssl import (
SSLCertVerificationError as SSLCertVerificationError,
SSLContext,
SSLEOFError as SSLEOFError,
SSLError as SSLError,
SSLObject,
SSLSyscallError as SSLSyscallError,
SSLWantReadError as SSLWantReadError,
SSLWantWriteError as SSLWantWriteError,
SSLZeroReturnError as SSLZeroReturnError,
)
from typing import Any, ClassVar, Final, Literal, TypeAlias, TypedDict, final, overload, type_check_only
from typing_extensions import NotRequired, Self, deprecated, disjoint_base
_PasswordType: TypeAlias = Callable[[], str | bytes | bytearray] | str | bytes | bytearray
_PCTRTT: TypeAlias = tuple[tuple[str, str], ...]
_PCTRTTT: TypeAlias = tuple[_PCTRTT, ...]
_PeerCertRetDictType: TypeAlias = dict[str, str | _PCTRTTT | _PCTRTT]
@type_check_only
class _Cipher(TypedDict):
aead: bool
alg_bits: int
auth: str
description: str
digest: str | None
id: int
kea: str
name: str
protocol: str
strength_bits: int
symmetric: str
@type_check_only
class _CertInfo(TypedDict):
subject: tuple[tuple[tuple[str, str], ...], ...]
issuer: tuple[tuple[tuple[str, str], ...], ...]
version: int
serialNumber: str
notBefore: str
notAfter: str
subjectAltName: NotRequired[tuple[tuple[str, str], ...] | None]
OCSP: NotRequired[tuple[str, ...] | None]
caIssuers: NotRequired[tuple[str, ...] | None]
crlDistributionPoints: NotRequired[tuple[str, ...] | None]
def RAND_add(string: str | ReadableBuffer, entropy: float, /) -> None: ...
def RAND_bytes(n: int, /) -> bytes: ...
if sys.version_info < (3, 12):
@deprecated("Deprecated since Python 3.6; removed in Python 3.12. Use `ssl.RAND_bytes()` instead.")
def RAND_pseudo_bytes(n: int, /) -> tuple[bytes, bool]: ...
def RAND_status() -> bool: ...
def get_default_verify_paths() -> tuple[str, str, str, str]: ...
if sys.version_info >= (3, 15):
def get_sigalgs() -> list[str]: ...
if sys.platform == "win32":
_EnumRetType: TypeAlias = list[tuple[bytes, str, set[str] | bool]]
def enum_certificates(store_name: str) -> _EnumRetType: ...
def enum_crls(store_name: str) -> _EnumRetType: ...
def txt2obj(txt: str, name: bool = False) -> tuple[int, str, str, str]: ...
def nid2obj(nid: int, /) -> tuple[int, str, str, str]: ...
@disjoint_base
class _SSLContext:
check_hostname: bool
keylog_filename: str | None
maximum_version: int
minimum_version: int
num_tickets: int
options: int
post_handshake_auth: bool
protocol: int
security_level: int
sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None
verify_flags: int
verify_mode: int
def __new__(cls, protocol: int, /) -> Self: ...
def cert_store_stats(self) -> dict[str, int]: ...
@overload
def get_ca_certs(self, binary_form: Literal[False] = False) -> list[_PeerCertRetDictType]: ...
@overload
def get_ca_certs(self, binary_form: Literal[True]) -> list[bytes]: ...
@overload
def get_ca_certs(self, binary_form: bool = False) -> Any: ...
def get_ciphers(self) -> list[_Cipher]: ...
def load_cert_chain(
self, certfile: StrOrBytesPath, keyfile: StrOrBytesPath | None = None, password: _PasswordType | None = None
) -> None: ...
def load_dh_params(self, path: str, /) -> None: ...
def load_verify_locations(
self,
cafile: StrOrBytesPath | None = None,
capath: StrOrBytesPath | None = None,
cadata: str | ReadableBuffer | None = None,
) -> None: ...
def session_stats(self) -> dict[str, int]: ...
def set_ciphers(self, cipherlist: str, /) -> None: ...
def set_default_verify_paths(self) -> None: ...
def set_ecdh_curve(self, name: str, /) -> None: ...
if sys.version_info >= (3, 15):
def get_groups(self, *, include_aliases: bool = False) -> list[str]: ...
def set_ciphersuites(self, ciphersuites: str, /) -> None: ...
def set_client_sigalgs(self, sigalgslist: str, /) -> None: ...
def set_groups(self, grouplist: str, /) -> None: ...
def set_server_sigalgs(self, sigalgslist: str, /) -> None: ...
if sys.version_info >= (3, 13):
def set_psk_client_callback(self, callback: Callable[[str | None], tuple[str | None, bytes]] | None) -> None: ...
def set_psk_server_callback(
self, callback: Callable[[str | None], bytes] | None, identity_hint: str | None = None
) -> None: ...
@final
class MemoryBIO:
eof: bool
pending: int
def __new__(self) -> Self: ...
def read(self, size: int = -1, /) -> bytes: ...
def write(self, b: ReadableBuffer, /) -> int: ...
def write_eof(self) -> None: ...
@final
class SSLSession:
__hash__: ClassVar[None] # type: ignore[assignment]
@property
def has_ticket(self) -> bool: ...
@property
def id(self) -> bytes: ...
@property
def ticket_lifetime_hint(self) -> int: ...
@property
def time(self) -> int: ...
@property
def timeout(self) -> int: ...
# _ssl.Certificate is weird: it can't be instantiated or subclassed.
# Instances can only be created via methods of the private _ssl._SSLSocket class,
# for which the relevant method signatures are:
#
# class _SSLSocket:
# def get_unverified_chain(self) -> list[Certificate] | None: ...
# def get_verified_chain(self) -> list[Certificate] | None: ...
#
# You can find a _ssl._SSLSocket object as the _sslobj attribute of a ssl.SSLSocket object
@final
class Certificate:
def get_info(self) -> _CertInfo: ...
@overload
def public_bytes(self) -> str: ...
@overload
def public_bytes(self, format: Literal[1] = 1, /) -> str: ... # ENCODING_PEM
@overload
def public_bytes(self, format: Literal[2], /) -> bytes: ... # ENCODING_DER
@overload
def public_bytes(self, format: int, /) -> str | bytes: ...
if sys.version_info < (3, 12):
err_codes_to_names: dict[tuple[int, int], str]
err_names_to_codes: dict[str, tuple[int, int]]
lib_codes_to_names: dict[int, str]
_DEFAULT_CIPHERS: Final[str]
# SSL error numbers
SSL_ERROR_ZERO_RETURN: Final = 6
SSL_ERROR_WANT_READ: Final = 2
SSL_ERROR_WANT_WRITE: Final = 3
SSL_ERROR_WANT_X509_LOOKUP: Final = 4
SSL_ERROR_SYSCALL: Final = 5
SSL_ERROR_SSL: Final = 1
SSL_ERROR_WANT_CONNECT: Final = 7
SSL_ERROR_EOF: Final = 8
SSL_ERROR_INVALID_ERROR_CODE: Final = 10
# verify modes
CERT_NONE: Final = 0
CERT_OPTIONAL: Final = 1
CERT_REQUIRED: Final = 2
# verify flags
VERIFY_DEFAULT: Final = 0
VERIFY_CRL_CHECK_LEAF: Final = 0x04
VERIFY_CRL_CHECK_CHAIN: Final = 0x0C
VERIFY_X509_STRICT: Final = 0x20
VERIFY_X509_TRUSTED_FIRST: Final = 0x8000
VERIFY_ALLOW_PROXY_CERTS: Final = 0x40
VERIFY_X509_PARTIAL_CHAIN: Final = 0x80000
# alert descriptions
ALERT_DESCRIPTION_CLOSE_NOTIFY: Final = 0
ALERT_DESCRIPTION_UNEXPECTED_MESSAGE: Final = 10
ALERT_DESCRIPTION_BAD_RECORD_MAC: Final = 20
ALERT_DESCRIPTION_RECORD_OVERFLOW: Final = 22
ALERT_DESCRIPTION_DECOMPRESSION_FAILURE: Final = 30
ALERT_DESCRIPTION_HANDSHAKE_FAILURE: Final = 40
ALERT_DESCRIPTION_BAD_CERTIFICATE: Final = 42
ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: Final = 43
ALERT_DESCRIPTION_CERTIFICATE_REVOKED: Final = 44
ALERT_DESCRIPTION_CERTIFICATE_EXPIRED: Final = 45
ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN: Final = 46
ALERT_DESCRIPTION_ILLEGAL_PARAMETER: Final = 47
ALERT_DESCRIPTION_UNKNOWN_CA: Final = 48
ALERT_DESCRIPTION_ACCESS_DENIED: Final = 49
ALERT_DESCRIPTION_DECODE_ERROR: Final = 50
ALERT_DESCRIPTION_DECRYPT_ERROR: Final = 51
ALERT_DESCRIPTION_PROTOCOL_VERSION: Final = 70
ALERT_DESCRIPTION_INSUFFICIENT_SECURITY: Final = 71
ALERT_DESCRIPTION_INTERNAL_ERROR: Final = 80
ALERT_DESCRIPTION_USER_CANCELLED: Final = 90
ALERT_DESCRIPTION_NO_RENEGOTIATION: Final = 100
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: Final = 110
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE: Final = 111
ALERT_DESCRIPTION_UNRECOGNIZED_NAME: Final = 112
ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE: Final = 113
ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE: Final = 114
ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY: Final = 115
# protocol versions
PROTOCOL_SSLv23: Final = 2
PROTOCOL_TLS: Final = 2
PROTOCOL_TLS_CLIENT: Final = 16
PROTOCOL_TLS_SERVER: Final = 17
PROTOCOL_TLSv1: Final = 3
PROTOCOL_TLSv1_1: Final = 4
PROTOCOL_TLSv1_2: Final = 5
# protocol options
OP_ALL: Final[int]
OP_NO_SSLv2: Final = 0x0
OP_NO_SSLv3: Final = 0x2000000
OP_NO_TLSv1: Final = 0x4000000
OP_NO_TLSv1_1: Final = 0x10000000
OP_NO_TLSv1_2: Final = 0x8000000
OP_NO_TLSv1_3: Final = 0x20000000
OP_CIPHER_SERVER_PREFERENCE: Final = 0x400000
OP_SINGLE_DH_USE: Final = 0x0
OP_NO_TICKET: Final = 0x4000
OP_SINGLE_ECDH_USE: Final = 0x0
OP_NO_COMPRESSION: Final = 0x20000
OP_ENABLE_MIDDLEBOX_COMPAT: Final = 0x100000
OP_NO_RENEGOTIATION: Final = 0x40000000
if sys.version_info >= (3, 11) or sys.platform == "linux":
OP_IGNORE_UNEXPECTED_EOF: Final = 0x80
if sys.version_info >= (3, 12):
OP_LEGACY_SERVER_CONNECT: Final = 0x4
OP_ENABLE_KTLS: Final = 0x8
# host flags
HOSTFLAG_ALWAYS_CHECK_SUBJECT: Final = 0x1
HOSTFLAG_NEVER_CHECK_SUBJECT: Final = 0x20
HOSTFLAG_NO_WILDCARDS: Final = 0x2
HOSTFLAG_NO_PARTIAL_WILDCARDS: Final = 0x4
HOSTFLAG_MULTI_LABEL_WILDCARDS: Final = 0x8
HOSTFLAG_SINGLE_LABEL_SUBDOMAINS: Final = 0x10
# certificate file types
ENCODING_PEM: Final = 1
ENCODING_DER: Final = 2
# protocol versions
PROTO_MINIMUM_SUPPORTED: Final = -2
PROTO_MAXIMUM_SUPPORTED: Final = -1
PROTO_SSLv3: Final[int]
PROTO_TLSv1: Final[int]
PROTO_TLSv1_1: Final[int]
PROTO_TLSv1_2: Final[int]
PROTO_TLSv1_3: Final[int]
# feature support
HAS_SNI: Final[bool]
HAS_TLS_UNIQUE: Final[bool]
HAS_ECDH: Final[bool]
HAS_NPN: Final[bool]
if sys.version_info >= (3, 13):
HAS_PSK: Final[bool]
if sys.version_info >= (3, 15):
HAS_PSK_TLS13: Final[bool]
HAS_ALPN: Final[bool]
HAS_SSLv2: Final[bool]
HAS_SSLv3: Final[bool]
HAS_TLSv1: Final[bool]
HAS_TLSv1_1: Final[bool]
HAS_TLSv1_2: Final[bool]
HAS_TLSv1_3: Final[bool]
if sys.version_info >= (3, 14):
HAS_PHA: Final[bool]
# version info
OPENSSL_VERSION_NUMBER: Final[int]
OPENSSL_VERSION_INFO: Final[tuple[int, int, int, int, int]]
OPENSSL_VERSION: Final[str]
_OPENSSL_API_VERSION: Final[tuple[int, int, int, int, int]]
@@ -1,119 +0,0 @@
import sys
from typing import Final
SF_APPEND: Final = 0x00040000
SF_ARCHIVED: Final = 0x00010000
SF_IMMUTABLE: Final = 0x00020000
SF_NOUNLINK: Final = 0x00100000
SF_SNAPSHOT: Final = 0x00200000
ST_MODE: Final = 0
ST_INO: Final = 1
ST_DEV: Final = 2
ST_NLINK: Final = 3
ST_UID: Final = 4
ST_GID: Final = 5
ST_SIZE: Final = 6
ST_ATIME: Final = 7
ST_MTIME: Final = 8
ST_CTIME: Final = 9
S_IFIFO: Final = 0o010000
S_IFLNK: Final = 0o120000
S_IFREG: Final = 0o100000
S_IFSOCK: Final = 0o140000
S_IFBLK: Final = 0o060000
S_IFCHR: Final = 0o020000
S_IFDIR: Final = 0o040000
# These are 0 on systems that don't support the specific kind of file.
# Example: Linux doesn't support door files, so S_IFDOOR is 0 on linux.
S_IFDOOR: Final[int]
S_IFPORT: Final[int]
S_IFWHT: Final[int]
S_ISUID: Final = 0o4000
S_ISGID: Final = 0o2000
S_ISVTX: Final = 0o1000
S_IRWXU: Final = 0o0700
S_IRUSR: Final = 0o0400
S_IWUSR: Final = 0o0200
S_IXUSR: Final = 0o0100
S_IRWXG: Final = 0o0070
S_IRGRP: Final = 0o0040
S_IWGRP: Final = 0o0020
S_IXGRP: Final = 0o0010
S_IRWXO: Final = 0o0007
S_IROTH: Final = 0o0004
S_IWOTH: Final = 0o0002
S_IXOTH: Final = 0o0001
S_ENFMT: Final = 0o2000
S_IREAD: Final = 0o0400
S_IWRITE: Final = 0o0200
S_IEXEC: Final = 0o0100
UF_APPEND: Final = 0x00000004
UF_COMPRESSED: Final = 0x00000020 # OS X 10.6+ only
UF_HIDDEN: Final = 0x00008000 # OX X 10.5+ only
UF_IMMUTABLE: Final = 0x00000002
UF_NODUMP: Final = 0x00000001
UF_NOUNLINK: Final = 0x00000010
UF_OPAQUE: Final = 0x00000008
def S_IMODE(mode: int, /) -> int: ...
def S_IFMT(mode: int, /) -> int: ...
def S_ISBLK(mode: int, /) -> bool: ...
def S_ISCHR(mode: int, /) -> bool: ...
def S_ISDIR(mode: int, /) -> bool: ...
def S_ISDOOR(mode: int, /) -> bool: ...
def S_ISFIFO(mode: int, /) -> bool: ...
def S_ISLNK(mode: int, /) -> bool: ...
def S_ISPORT(mode: int, /) -> bool: ...
def S_ISREG(mode: int, /) -> bool: ...
def S_ISSOCK(mode: int, /) -> bool: ...
def S_ISWHT(mode: int, /) -> bool: ...
def filemode(mode: int, /) -> str: ...
if sys.platform == "win32":
IO_REPARSE_TAG_SYMLINK: Final = 0xA000000C
IO_REPARSE_TAG_MOUNT_POINT: Final = 0xA0000003
IO_REPARSE_TAG_APPEXECLINK: Final = 0x8000001B
if sys.platform == "win32":
FILE_ATTRIBUTE_ARCHIVE: Final = 32
FILE_ATTRIBUTE_COMPRESSED: Final = 2048
FILE_ATTRIBUTE_DEVICE: Final = 64
FILE_ATTRIBUTE_DIRECTORY: Final = 16
FILE_ATTRIBUTE_ENCRYPTED: Final = 16384
FILE_ATTRIBUTE_HIDDEN: Final = 2
FILE_ATTRIBUTE_INTEGRITY_STREAM: Final = 32768
FILE_ATTRIBUTE_NORMAL: Final = 128
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: Final = 8192
FILE_ATTRIBUTE_NO_SCRUB_DATA: Final = 131072
FILE_ATTRIBUTE_OFFLINE: Final = 4096
FILE_ATTRIBUTE_READONLY: Final = 1
FILE_ATTRIBUTE_REPARSE_POINT: Final = 1024
FILE_ATTRIBUTE_SPARSE_FILE: Final = 512
FILE_ATTRIBUTE_SYSTEM: Final = 4
FILE_ATTRIBUTE_TEMPORARY: Final = 256
FILE_ATTRIBUTE_VIRTUAL: Final = 65536
if sys.version_info >= (3, 13):
# Varies by platform.
SF_SETTABLE: Final[int]
# https://github.com/python/cpython/issues/114081#issuecomment-2119017790
# SF_RESTRICTED: Literal[0x00080000]
SF_FIRMLINK: Final = 0x00800000
SF_DATALESS: Final = 0x40000000
if sys.platform == "darwin":
SF_SUPPORTED: Final = 0x9F0000
SF_SYNTHETIC: Final = 0xC0000000
UF_TRACKED: Final = 0x00000040
UF_DATAVAULT: Final = 0x00000080
UF_SETTABLE: Final = 0x0000FFFF
@@ -1,24 +0,0 @@
from _typeshed import ReadableBuffer, WriteableBuffer
from collections.abc import Iterator
from typing import Any
from typing_extensions import disjoint_base
def pack(fmt: str | bytes, /, *v: Any) -> bytes: ...
def pack_into(fmt: str | bytes, buffer: WriteableBuffer, offset: int, /, *v: Any) -> None: ...
def unpack(format: str | bytes, buffer: ReadableBuffer, /) -> tuple[Any, ...]: ...
def unpack_from(format: str | bytes, /, buffer: ReadableBuffer, offset: int = 0) -> tuple[Any, ...]: ...
def iter_unpack(format: str | bytes, buffer: ReadableBuffer, /) -> Iterator[tuple[Any, ...]]: ...
def calcsize(format: str | bytes, /) -> int: ...
@disjoint_base
class Struct:
@property
def format(self) -> str: ...
@property
def size(self) -> int: ...
def __init__(self, format: str | bytes) -> None: ...
def pack(self, *v: Any) -> bytes: ...
def pack_into(self, buffer: WriteableBuffer, offset: int, *v: Any) -> None: ...
def unpack(self, buffer: ReadableBuffer, /) -> tuple[Any, ...]: ...
def unpack_from(self, buffer: ReadableBuffer, offset: int = 0) -> tuple[Any, ...]: ...
def iter_unpack(self, buffer: ReadableBuffer, /) -> Iterator[tuple[Any, ...]]: ...
@@ -1,123 +0,0 @@
import signal
import sys
from _typeshed import structseq
from collections.abc import Callable
from threading import Thread
from types import TracebackType
from typing import Any, Final, NoReturn, final, overload
from typing_extensions import TypeVarTuple, Unpack, deprecated, disjoint_base
_Ts = TypeVarTuple("_Ts")
error = RuntimeError
def _count() -> int: ...
@final
class RLock:
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release(self) -> None: ...
__enter__ = acquire
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
if sys.version_info >= (3, 14):
def locked(self) -> bool: ...
if sys.version_info >= (3, 13):
@final
class _ThreadHandle:
ident: int
def join(self, timeout: float | None = None, /) -> None: ...
def is_done(self) -> bool: ...
def _set_done(self) -> None: ...
def start_joinable_thread(
function: Callable[[], object], handle: _ThreadHandle | None = None, daemon: bool = True
) -> _ThreadHandle: ...
@final
class lock:
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release(self) -> None: ...
def locked(self) -> bool: ...
@deprecated("Obsolete synonym. Use `acquire()` instead.")
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented
@deprecated("Obsolete synonym. Use `release()` instead.")
def release_lock(self) -> None: ... # undocumented
@deprecated("Obsolete synonym. Use `locked()` instead.")
def locked_lock(self) -> bool: ... # undocumented
def __enter__(self) -> bool: ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
LockType = lock
else:
@final
class LockType:
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release(self) -> None: ...
def locked(self) -> bool: ...
@deprecated("Obsolete synonym. Use `acquire()` instead.")
def acquire_lock(self, blocking: bool = True, timeout: float = -1) -> bool: ... # undocumented
@deprecated("Obsolete synonym. Use `release()` instead.")
def release_lock(self) -> None: ... # undocumented
@deprecated("Obsolete synonym. Use `locked()` instead.")
def locked_lock(self) -> bool: ... # undocumented
def __enter__(self) -> bool: ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
@overload
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ...
@overload
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ...
@overload
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]], /) -> int: ... # undocumented
@overload
@deprecated("Obsolete synonym. Use `start_new_thread()` instead.")
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... # undocumented
def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ...
def exit() -> NoReturn: ...
@deprecated("Obsolete synonym. Use `exit()` instead.")
def exit_thread() -> NoReturn: ... # undocumented
def allocate_lock() -> LockType: ...
@deprecated("Obsolete synonym. Use `allocate_lock()` instead.")
def allocate() -> LockType: ... # undocumented
def get_ident() -> int: ...
def stack_size(size: int = 0, /) -> int: ...
TIMEOUT_MAX: Final[float]
def get_native_id() -> int: ... # only available on some platforms
@final
class _ExceptHookArgs(structseq[Any], tuple[type[BaseException], BaseException | None, TracebackType | None, Thread | None]):
__match_args__: Final = ("exc_type", "exc_value", "exc_traceback", "thread")
@property
def exc_type(self) -> type[BaseException]: ...
@property
def exc_value(self) -> BaseException | None: ...
@property
def exc_traceback(self) -> TracebackType | None: ...
@property
def thread(self) -> Thread | None: ...
_excepthook: Callable[[_ExceptHookArgs], Any]
if sys.version_info >= (3, 12):
def daemon_threads_allowed() -> bool: ...
if sys.version_info >= (3, 14):
def set_name(name: str) -> None: ...
@disjoint_base
class _local:
def __getattribute__(self, name: str, /) -> Any: ...
def __setattr__(self, name: str, value: Any, /) -> None: ...
def __delattr__(self, name: str, /) -> None: ...
@@ -1,24 +0,0 @@
from threading import RLock
from typing import Any, TypeAlias
from typing_extensions import Self
from weakref import ReferenceType
__all__ = ["local"]
_LocalDict: TypeAlias = dict[Any, Any]
class _localimpl:
__slots__ = ("key", "dicts", "localargs", "locallock", "__weakref__")
key: str
dicts: dict[int, tuple[ReferenceType[Any], _LocalDict]]
# Keep localargs in sync with the *args, **kwargs annotation on local.__new__
localargs: tuple[list[Any], dict[str, Any]]
locallock: RLock
def get_dict(self) -> _LocalDict: ...
def create_dict(self) -> _LocalDict: ...
class local:
__slots__ = ("_local__impl", "__dict__")
def __new__(cls, /, *args: Any, **kw: Any) -> Self: ...
def __getattribute__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __delattr__(self, name: str) -> None: ...
@@ -1,156 +0,0 @@
import sys
from _typeshed import FileDescriptorLike, Incomplete
from collections.abc import Callable
from typing import Any, ClassVar, Final, Literal, TypeAlias, final, overload
from typing_extensions import deprecated
# _tkinter is meant to be only used internally by tkinter, but some tkinter
# functions e.g. return _tkinter.Tcl_Obj objects. Tcl_Obj represents a Tcl
# object that hasn't been converted to a string.
#
# There are not many ways to get Tcl_Objs from tkinter, and I'm not sure if the
# only existing ways are supposed to return Tcl_Objs as opposed to returning
# strings. Here's one of these things that return Tcl_Objs:
#
# >>> import tkinter
# >>> text = tkinter.Text()
# >>> text.tag_add('foo', '1.0', 'end')
# >>> text.tag_ranges('foo')
# (<textindex object: '1.0'>, <textindex object: '2.0'>)
@final
class Tcl_Obj:
@property
def string(self) -> str: ...
@property
def typename(self) -> str: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __eq__(self, value, /): ...
def __ge__(self, value, /): ...
def __gt__(self, value, /): ...
def __le__(self, value, /): ...
def __lt__(self, value, /): ...
def __ne__(self, value, /): ...
class TclError(Exception): ...
_TkinterTraceFunc: TypeAlias = Callable[[tuple[str, ...]], object]
# This class allows running Tcl code. Tkinter uses it internally a lot, and
# it's often handy to drop a piece of Tcl code into a tkinter program. Example:
#
# >>> import tkinter, _tkinter
# >>> tkapp = tkinter.Tk().tk
# >>> isinstance(tkapp, _tkinter.TkappType)
# True
# >>> tkapp.call('set', 'foo', (1,2,3))
# (1, 2, 3)
# >>> tkapp.eval('return $foo')
# '1 2 3'
# >>>
#
# call args can be pretty much anything. Also, call(some_tuple) is same as call(*some_tuple).
#
# eval always returns str because _tkinter_tkapp_eval_impl in _tkinter.c calls
# Tkapp_UnicodeResult, and it returns a string when it succeeds.
@final
class TkappType:
# Please keep in sync with tkinter.Tk
def adderrorinfo(self, msg: str, /) -> None: ...
def call(self, command: Any, /, *args: Any) -> Any: ...
# TODO: Figure out what arguments the following `func` callbacks should accept
def createcommand(self, name: str, func: Callable[..., object], /) -> None: ...
if sys.platform != "win32":
def createfilehandler(self, file: FileDescriptorLike, mask: int, func: Callable[..., object], /) -> None: ...
def deletefilehandler(self, file: FileDescriptorLike, /) -> None: ...
def createtimerhandler(self, milliseconds: int, func: Callable[..., object], /): ...
def deletecommand(self, name: str, /) -> None: ...
def dooneevent(self, flags: int = 0, /) -> int: ...
def eval(self, script: str, /) -> str: ...
def evalfile(self, fileName: str, /) -> str: ...
def exprboolean(self, s: str, /) -> Literal[0, 1]: ...
def exprdouble(self, s: str, /) -> float: ...
def exprlong(self, s: str, /) -> int: ...
def exprstring(self, s: str, /) -> str: ...
def getboolean(self, arg, /) -> bool: ...
def getdouble(self, arg, /) -> float: ...
def getint(self, arg, /) -> int: ...
def getvar(self, *args, **kwargs): ...
def globalgetvar(self, *args, **kwargs): ...
def globalsetvar(self, *args, **kwargs): ...
def globalunsetvar(self, *args, **kwargs): ...
def interpaddr(self) -> int: ...
def loadtk(self) -> None: ...
def mainloop(self, threshold: int = 0, /) -> None: ...
def quit(self) -> None: ...
def record(self, script: str, /) -> str: ...
def setvar(self, *ags, **kwargs): ...
if sys.version_info < (3, 11):
@deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.")
def split(self, arg, /): ...
def splitlist(self, arg, /) -> tuple[Incomplete, ...]: ...
def unsetvar(self, *args, **kwargs): ...
if sys.version_info >= (3, 14):
@overload
def wantobjects(self) -> Literal[0, 1]: ...
else:
@overload
def wantobjects(self) -> bool: ...
@overload
def wantobjects(self, wantobjects: Literal[0, 1] | bool, /) -> None: ...
def willdispatch(self) -> None: ...
if sys.version_info >= (3, 12):
def gettrace(self, /) -> _TkinterTraceFunc | None: ...
def settrace(self, func: _TkinterTraceFunc | None, /) -> None: ...
# These should be kept in sync with tkinter.tix constants, except ALL_EVENTS which doesn't match TCL_ALL_EVENTS
ALL_EVENTS: Final = -3
FILE_EVENTS: Final = 8
IDLE_EVENTS: Final = 32
TIMER_EVENTS: Final = 16
WINDOW_EVENTS: Final = 4
DONT_WAIT: Final = 2
EXCEPTION: Final = 8
READABLE: Final = 2
WRITABLE: Final = 4
TCL_VERSION: Final[str]
TK_VERSION: Final[str]
@final
class TkttType:
def deletetimerhandler(self) -> None: ...
if sys.version_info >= (3, 13):
def create(
screenName: str | None = None,
baseName: str = "",
className: str = "Tk",
interactive: bool = False,
wantobjects: int = 0,
wantTk: bool = True,
sync: bool = False,
use: str | None = None,
/,
) -> TkappType: ...
else:
def create(
screenName: str | None = None,
baseName: str = "",
className: str = "Tk",
interactive: bool = False,
wantobjects: bool = False,
wantTk: bool = True,
sync: bool = False,
use: str | None = None,
/,
) -> TkappType: ...
def getbusywaitinterval() -> int: ...
def setbusywaitinterval(new_val: int, /) -> None: ...
@@ -1,13 +0,0 @@
from collections.abc import Sequence
from tracemalloc import _FrameTuple, _TraceTuple
def _get_object_traceback(obj: object, /) -> Sequence[_FrameTuple] | None: ...
def _get_traces() -> Sequence[_TraceTuple]: ...
def clear_traces() -> None: ...
def get_traceback_limit() -> int: ...
def get_traced_memory() -> tuple[int, int]: ...
def get_tracemalloc_memory() -> int: ...
def is_tracing() -> bool: ...
def reset_peak() -> None: ...
def start(nframe: int = 1, /) -> None: ...
def stop() -> None: ...
@@ -1,15 +0,0 @@
from collections.abc import Callable
from typing import Any, TypeVar, overload
from weakref import CallableProxyType as CallableProxyType, ProxyType as ProxyType, ReferenceType as ReferenceType, ref as ref
_C = TypeVar("_C", bound=Callable[..., Any])
_T = TypeVar("_T")
def getweakrefcount(object: Any, /) -> int: ...
def getweakrefs(object: Any, /) -> list[Any]: ...
# Return CallableProxyType if object is callable, ProxyType otherwise
@overload
def proxy(object: _C, callback: Callable[[_C], Any] | None = None, /) -> CallableProxyType[_C]: ...
@overload
def proxy(object: _T, callback: Callable[[_T], Any] | None = None, /) -> Any: ...
@@ -1,49 +0,0 @@
from collections.abc import Iterable, Iterator, MutableSet
from types import GenericAlias
from typing import Any, ClassVar, TypeVar, overload
from typing_extensions import Self
__all__ = ["WeakSet"]
_S = TypeVar("_S")
_T = TypeVar("_T")
class WeakSet(MutableSet[_T]):
@overload
def __init__(self, data: None = None) -> None: ...
@overload
def __init__(self, data: Iterable[_T]) -> None: ...
def add(self, item: _T) -> None: ...
def discard(self, item: _T) -> None: ...
def copy(self) -> Self: ...
def remove(self, item: _T) -> None: ...
def update(self, other: Iterable[_T]) -> None: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __contains__(self, item: object) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __ior__(self, other: Iterable[_T]) -> Self: ... # type: ignore[override,misc]
def difference(self, other: Iterable[_T]) -> Self: ...
def __sub__(self, other: Iterable[Any]) -> Self: ...
def difference_update(self, other: Iterable[Any]) -> None: ...
def __isub__(self, other: Iterable[Any]) -> Self: ...
def intersection(self, other: Iterable[_T]) -> Self: ...
def __and__(self, other: Iterable[Any]) -> Self: ...
def intersection_update(self, other: Iterable[Any]) -> None: ...
def __iand__(self, other: Iterable[Any]) -> Self: ...
def issubset(self, other: Iterable[_T]) -> bool: ...
def __le__(self, other: Iterable[_T]) -> bool: ...
def __lt__(self, other: Iterable[_T]) -> bool: ...
def issuperset(self, other: Iterable[_T]) -> bool: ...
def __ge__(self, other: Iterable[_T]) -> bool: ...
def __gt__(self, other: Iterable[_T]) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def symmetric_difference(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
def __xor__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
def symmetric_difference_update(self, other: Iterable[_T]) -> None: ...
def __ixor__(self, other: Iterable[_T]) -> Self: ... # type: ignore[override,misc]
def union(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
def __or__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
def isdisjoint(self, other: Iterable[_T]) -> bool: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@@ -1,314 +0,0 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Sequence
from typing import Any, Final, Literal, NoReturn, final, overload
if sys.platform == "win32":
ABOVE_NORMAL_PRIORITY_CLASS: Final = 0x8000
BELOW_NORMAL_PRIORITY_CLASS: Final = 0x4000
CREATE_BREAKAWAY_FROM_JOB: Final = 0x1000000
CREATE_DEFAULT_ERROR_MODE: Final = 0x4000000
CREATE_NO_WINDOW: Final = 0x8000000
CREATE_NEW_CONSOLE: Final = 0x10
CREATE_NEW_PROCESS_GROUP: Final = 0x200
DETACHED_PROCESS: Final = 8
DUPLICATE_CLOSE_SOURCE: Final = 1
DUPLICATE_SAME_ACCESS: Final = 2
ERROR_ALREADY_EXISTS: Final = 183
ERROR_BROKEN_PIPE: Final = 109
ERROR_IO_PENDING: Final = 997
ERROR_MORE_DATA: Final = 234
ERROR_NETNAME_DELETED: Final = 64
ERROR_NO_DATA: Final = 232
ERROR_NO_SYSTEM_RESOURCES: Final = 1450
ERROR_OPERATION_ABORTED: Final = 995
ERROR_PIPE_BUSY: Final = 231
ERROR_PIPE_CONNECTED: Final = 535
ERROR_SEM_TIMEOUT: Final = 121
if sys.version_info >= (3, 15):
EVENTLOG_AUDIT_FAILURE: Final = 16
EVENTLOG_AUDIT_SUCCESS: Final = 8
EVENTLOG_ERROR_TYPE: Final = 1
EVENTLOG_INFORMATION_TYPE: Final = 4
EVENTLOG_SUCCESS: Final = 0
EVENTLOG_WARNING_TYPE: Final = 2
FILE_FLAG_FIRST_PIPE_INSTANCE: Final = 0x80000
FILE_FLAG_OVERLAPPED: Final = 0x40000000
FILE_GENERIC_READ: Final = 1179785
FILE_GENERIC_WRITE: Final = 1179926
FILE_MAP_ALL_ACCESS: Final = 983071
FILE_MAP_COPY: Final = 1
FILE_MAP_EXECUTE: Final = 32
FILE_MAP_READ: Final = 4
FILE_MAP_WRITE: Final = 2
FILE_TYPE_CHAR: Final = 2
FILE_TYPE_DISK: Final = 1
FILE_TYPE_PIPE: Final = 3
FILE_TYPE_REMOTE: Final = 32768
FILE_TYPE_UNKNOWN: Final = 0
GENERIC_READ: Final = 0x80000000
GENERIC_WRITE: Final = 0x40000000
HIGH_PRIORITY_CLASS: Final = 0x80
INFINITE: Final = 0xFFFFFFFF
# Ignore the Flake8 error -- flake8-pyi assumes
# most numbers this long will be implementation details,
# but here we can see that it's a power of 2
INVALID_HANDLE_VALUE: Final = 0xFFFFFFFFFFFFFFFF # noqa: Y054
IDLE_PRIORITY_CLASS: Final = 0x40
NORMAL_PRIORITY_CLASS: Final = 0x20
REALTIME_PRIORITY_CLASS: Final = 0x100
NMPWAIT_WAIT_FOREVER: Final = 0xFFFFFFFF
MEM_COMMIT: Final = 0x1000
MEM_FREE: Final = 0x10000
MEM_IMAGE: Final = 0x1000000
MEM_MAPPED: Final = 0x40000
MEM_PRIVATE: Final = 0x20000
MEM_RESERVE: Final = 0x2000
NULL: Final = 0
OPEN_EXISTING: Final = 3
PIPE_ACCESS_DUPLEX: Final = 3
PIPE_ACCESS_INBOUND: Final = 1
PIPE_READMODE_MESSAGE: Final = 2
PIPE_TYPE_MESSAGE: Final = 4
PIPE_UNLIMITED_INSTANCES: Final = 255
PIPE_WAIT: Final = 0
PAGE_EXECUTE: Final = 0x10
PAGE_EXECUTE_READ: Final = 0x20
PAGE_EXECUTE_READWRITE: Final = 0x40
PAGE_EXECUTE_WRITECOPY: Final = 0x80
PAGE_GUARD: Final = 0x100
PAGE_NOACCESS: Final = 0x1
PAGE_NOCACHE: Final = 0x200
PAGE_READONLY: Final = 0x2
PAGE_READWRITE: Final = 0x4
PAGE_WRITECOMBINE: Final = 0x400
PAGE_WRITECOPY: Final = 0x8
PROCESS_ALL_ACCESS: Final = 0x1FFFFF
PROCESS_DUP_HANDLE: Final = 0x40
SEC_COMMIT: Final = 0x8000000
SEC_IMAGE: Final = 0x1000000
SEC_LARGE_PAGES: Final = 0x80000000
SEC_NOCACHE: Final = 0x10000000
SEC_RESERVE: Final = 0x4000000
SEC_WRITECOMBINE: Final = 0x40000000
if sys.version_info >= (3, 13):
STARTF_FORCEOFFFEEDBACK: Final = 0x80
STARTF_FORCEONFEEDBACK: Final = 0x40
STARTF_PREVENTPINNING: Final = 0x2000
STARTF_RUNFULLSCREEN: Final = 0x20
STARTF_TITLEISAPPID: Final = 0x1000
STARTF_TITLEISLINKNAME: Final = 0x800
STARTF_UNTRUSTEDSOURCE: Final = 0x8000
STARTF_USECOUNTCHARS: Final = 0x8
STARTF_USEFILLATTRIBUTE: Final = 0x10
STARTF_USEHOTKEY: Final = 0x200
STARTF_USEPOSITION: Final = 0x4
STARTF_USESIZE: Final = 0x2
STARTF_USESHOWWINDOW: Final = 0x1
STARTF_USESTDHANDLES: Final = 0x100
STD_ERROR_HANDLE: Final = 0xFFFFFFF4
STD_OUTPUT_HANDLE: Final = 0xFFFFFFF5
STD_INPUT_HANDLE: Final = 0xFFFFFFF6
STILL_ACTIVE: Final = 259
SW_HIDE: Final = 0
SYNCHRONIZE: Final = 0x100000
WAIT_ABANDONED_0: Final = 128
WAIT_OBJECT_0: Final = 0
WAIT_TIMEOUT: Final = 258
LOCALE_NAME_INVARIANT: Final[str]
LOCALE_NAME_MAX_LENGTH: Final[int]
LOCALE_NAME_SYSTEM_DEFAULT: Final[str]
LOCALE_NAME_USER_DEFAULT: Final[str | None]
LCMAP_FULLWIDTH: Final[int]
LCMAP_HALFWIDTH: Final[int]
LCMAP_HIRAGANA: Final[int]
LCMAP_KATAKANA: Final[int]
LCMAP_LINGUISTIC_CASING: Final[int]
LCMAP_LOWERCASE: Final[int]
LCMAP_SIMPLIFIED_CHINESE: Final[int]
LCMAP_TITLECASE: Final[int]
LCMAP_TRADITIONAL_CHINESE: Final[int]
LCMAP_UPPERCASE: Final[int]
if sys.version_info >= (3, 12):
COPYFILE2_CALLBACK_CHUNK_STARTED: Final = 1
COPYFILE2_CALLBACK_CHUNK_FINISHED: Final = 2
COPYFILE2_CALLBACK_STREAM_STARTED: Final = 3
COPYFILE2_CALLBACK_STREAM_FINISHED: Final = 4
COPYFILE2_CALLBACK_POLL_CONTINUE: Final = 5
COPYFILE2_CALLBACK_ERROR: Final = 6
COPYFILE2_PROGRESS_CONTINUE: Final = 0
COPYFILE2_PROGRESS_CANCEL: Final = 1
COPYFILE2_PROGRESS_STOP: Final = 2
COPYFILE2_PROGRESS_QUIET: Final = 3
COPYFILE2_PROGRESS_PAUSE: Final = 4
COPY_FILE_FAIL_IF_EXISTS: Final = 0x1
COPY_FILE_RESTARTABLE: Final = 0x2
COPY_FILE_OPEN_SOURCE_FOR_WRITE: Final = 0x4
COPY_FILE_ALLOW_DECRYPTED_DESTINATION: Final = 0x8
COPY_FILE_COPY_SYMLINK: Final = 0x800
COPY_FILE_NO_BUFFERING: Final = 0x1000
COPY_FILE_REQUEST_SECURITY_PRIVILEGES: Final = 0x2000
COPY_FILE_RESUME_FROM_PAUSE: Final = 0x4000
COPY_FILE_NO_OFFLOAD: Final = 0x40000
COPY_FILE_REQUEST_COMPRESSED_TRAFFIC: Final = 0x10000000
ERROR_ACCESS_DENIED: Final = 5
ERROR_PRIVILEGE_NOT_HELD: Final = 1314
if sys.version_info >= (3, 14):
COPY_FILE_DIRECTORY: Final = 0x00000080
def CloseHandle(handle: int, /) -> None: ...
@overload
def ConnectNamedPipe(handle: int, overlapped: Literal[True]) -> Overlapped: ...
@overload
def ConnectNamedPipe(handle: int, overlapped: Literal[False] = False) -> None: ...
@overload
def ConnectNamedPipe(handle: int, overlapped: bool) -> Overlapped | None: ...
def CreateFile(
file_name: str,
desired_access: int,
share_mode: int,
security_attributes: int,
creation_disposition: int,
flags_and_attributes: int,
template_file: int,
/,
) -> int: ...
def CreateFileMapping(
file_handle: int, security_attributes: int, protect: int, max_size_high: int, max_size_low: int, name: str, /
) -> int: ...
def CreateJunction(src_path: str, dst_path: str, /) -> None: ...
def CreateNamedPipe(
name: str,
open_mode: int,
pipe_mode: int,
max_instances: int,
out_buffer_size: int,
in_buffer_size: int,
default_timeout: int,
security_attributes: int,
/,
) -> int: ...
def CreatePipe(pipe_attrs: Any, size: int, /) -> tuple[int, int]: ...
def CreateProcess(
application_name: str | None,
command_line: str | None,
proc_attrs: Any,
thread_attrs: Any,
inherit_handles: bool,
creation_flags: int,
env_mapping: dict[str, str],
current_directory: str | None,
startup_info: Any,
/,
) -> tuple[int, int, int, int]: ...
def DuplicateHandle(
source_process_handle: int,
source_handle: int,
target_process_handle: int,
desired_access: int,
inherit_handle: bool,
options: int = 0,
/,
) -> int: ...
def ExitProcess(ExitCode: int, /) -> NoReturn: ...
def GetACP() -> int: ...
if sys.version_info >= (3, 15):
def DeregisterEventSource(handle: int, /) -> None: ...
def GetOEMCP() -> int: ...
def GetFileType(handle: int) -> int: ...
def GetCurrentProcess() -> int: ...
def GetExitCodeProcess(process: int, /) -> int: ...
def GetLastError() -> int: ...
def GetModuleFileName(module_handle: int, /) -> str: ...
def GetStdHandle(std_handle: int, /) -> int: ...
def GetVersion() -> int: ...
def MapViewOfFile(
file_map: int, desired_access: int, file_offset_high: int, file_offset_low: int, number_bytes: int, /
) -> int: ...
def OpenProcess(desired_access: int, inherit_handle: bool, process_id: int, /) -> int: ...
def PeekNamedPipe(handle: int, size: int = 0, /) -> tuple[int, int] | tuple[bytes, int, int]: ...
def LCMapStringEx(locale: str, flags: int, src: str) -> str: ...
if sys.version_info >= (3, 15):
def RegisterEventSource(unc_server_name: str | None, source_name: str, /) -> int: ...
def ReportEvent(handle: int, type: int, category: int, event_id: int, string: str, /) -> None: ...
def UnmapViewOfFile(address: int, /) -> None: ...
@overload
def ReadFile(handle: int, size: int, overlapped: Literal[True]) -> tuple[Overlapped, int]: ...
@overload
def ReadFile(handle: int, size: int, overlapped: Literal[False] = False) -> tuple[bytes, int]: ...
@overload
def ReadFile(handle: int, size: int, overlapped: int | bool) -> tuple[Any, int]: ...
def SetNamedPipeHandleState(
named_pipe: int, mode: int | None, max_collection_count: int | None, collect_data_timeout: int | None, /
) -> None: ...
def TerminateProcess(handle: int, exit_code: int, /) -> None: ...
def VirtualQuerySize(address: int, /) -> int: ...
def WaitForMultipleObjects(handle_seq: Sequence[int], wait_flag: bool, milliseconds: int = 0xFFFFFFFF, /) -> int: ...
def WaitForSingleObject(handle: int, milliseconds: int, /) -> int: ...
def WaitNamedPipe(name: str, timeout: int, /) -> None: ...
@overload
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: Literal[True]) -> tuple[Overlapped, int]: ...
@overload
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: Literal[False] = False) -> tuple[int, int]: ...
@overload
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: int | bool) -> tuple[Any, int]: ...
@final
class Overlapped:
event: int
def GetOverlappedResult(self, wait: bool, /) -> tuple[int, int]: ...
def cancel(self) -> None: ...
def getbuffer(self) -> bytes | None: ...
if sys.version_info >= (3, 13):
def BatchedWaitForMultipleObjects(
handle_seq: Sequence[int], wait_all: bool, milliseconds: int = 0xFFFFFFFF
) -> list[int]: ...
def CreateEventW(security_attributes: int, manual_reset: bool, initial_state: bool, name: str | None) -> int: ...
def CreateMutexW(security_attributes: int, initial_owner: bool, name: str) -> int: ...
def GetLongPathName(path: str) -> str: ...
def GetShortPathName(path: str) -> str: ...
def OpenEventW(desired_access: int, inherit_handle: bool, name: str) -> int: ...
def OpenMutexW(desired_access: int, inherit_handle: bool, name: str) -> int: ...
def ReleaseMutex(mutex: int) -> None: ...
def ResetEvent(event: int) -> None: ...
def SetEvent(event: int) -> None: ...
def OpenFileMapping(desired_access: int, inherit_handle: bool, name: str, /) -> int: ...
if sys.version_info >= (3, 12):
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ...
def NeedCurrentDirectoryForExePath(exe_name: str, /) -> bool: ...
@@ -1,102 +0,0 @@
from _typeshed import ReadableBuffer
from collections.abc import Mapping
from compression.zstd import CompressionParameter, DecompressionParameter
from typing import Final, Literal, TypeAlias, final
from typing_extensions import Self
ZSTD_CLEVEL_DEFAULT: Final = 3
ZSTD_DStreamOutSize: Final = 131072
ZSTD_btlazy2: Final = 6
ZSTD_btopt: Final = 7
ZSTD_btultra: Final = 8
ZSTD_btultra2: Final = 9
ZSTD_c_chainLog: Final = 103
ZSTD_c_checksumFlag: Final = 201
ZSTD_c_compressionLevel: Final = 100
ZSTD_c_contentSizeFlag: Final = 200
ZSTD_c_dictIDFlag: Final = 202
ZSTD_c_enableLongDistanceMatching: Final = 160
ZSTD_c_hashLog: Final = 102
ZSTD_c_jobSize: Final = 401
ZSTD_c_ldmBucketSizeLog: Final = 163
ZSTD_c_ldmHashLog: Final = 161
ZSTD_c_ldmHashRateLog: Final = 164
ZSTD_c_ldmMinMatch: Final = 162
ZSTD_c_minMatch: Final = 105
ZSTD_c_nbWorkers: Final = 400
ZSTD_c_overlapLog: Final = 402
ZSTD_c_searchLog: Final = 104
ZSTD_c_strategy: Final = 107
ZSTD_c_targetLength: Final = 106
ZSTD_c_windowLog: Final = 101
ZSTD_d_windowLogMax: Final = 100
ZSTD_dfast: Final = 2
ZSTD_fast: Final = 1
ZSTD_greedy: Final = 3
ZSTD_lazy: Final = 4
ZSTD_lazy2: Final = 5
_ZstdCompressorContinue: TypeAlias = Literal[0]
_ZstdCompressorFlushBlock: TypeAlias = Literal[1]
_ZstdCompressorFlushFrame: TypeAlias = Literal[2]
@final
class ZstdCompressor:
CONTINUE: Final = 0
FLUSH_BLOCK: Final = 1
FLUSH_FRAME: Final = 2
def __new__(
cls,
level: int | None = None,
options: Mapping[int, int] | None = None,
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
) -> Self: ...
def compress(
self, /, data: ReadableBuffer, mode: _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 0
) -> bytes: ...
def flush(self, /, mode: _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 2) -> bytes: ...
def set_pledged_input_size(self, size: int | None, /) -> None: ...
@property
def last_mode(self) -> _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame: ...
@final
class ZstdDecompressor:
def __new__(
cls, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, options: Mapping[int, int] | None = None
) -> Self: ...
def decompress(self, /, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
@property
def eof(self) -> bool: ...
@property
def needs_input(self) -> bool: ...
@property
def unused_data(self) -> bytes: ...
@final
class ZstdDict:
def __new__(cls, dict_content: ReadableBuffer, /, *, is_raw: bool = False) -> Self: ...
def __len__(self, /) -> int: ...
@property
def as_digested_dict(self) -> tuple[Self, int]: ...
@property
def as_prefix(self) -> tuple[Self, int]: ...
@property
def as_undigested_dict(self) -> tuple[Self, int]: ...
@property
def dict_content(self) -> bytes: ...
@property
def dict_id(self) -> int: ...
class ZstdError(Exception): ...
def finalize_dict(
custom_dict_bytes: bytes, samples_bytes: bytes, samples_sizes: tuple[int, ...], dict_size: int, compression_level: int, /
) -> bytes: ...
def get_frame_info(frame_buffer: ReadableBuffer) -> tuple[int, int]: ...
def get_frame_size(frame_buffer: ReadableBuffer) -> int: ...
def get_param_bounds(parameter: int, is_compress: bool) -> tuple[int, int]: ...
def set_parameter_types(c_parameter_type: type[CompressionParameter], d_parameter_type: type[DecompressionParameter]) -> None: ...
def train_dict(samples_bytes: bytes, samples_sizes: tuple[int, ...], dict_size: int, /) -> bytes: ...
zstd_version: Final[str]
zstd_version_number: Final[int]
@@ -1,79 +0,0 @@
from types import TracebackType
from typing import IO, Any, Literal, NamedTuple, TypeAlias, overload
from typing_extensions import Self
__all__ = ["Error", "open"]
class Error(Exception): ...
class _aifc_params(NamedTuple):
nchannels: int
sampwidth: int
framerate: int
nframes: int
comptype: bytes
compname: bytes
_File: TypeAlias = str | IO[bytes]
_Marker: TypeAlias = tuple[int, int, bytes]
class Aifc_read:
def __init__(self, f: _File) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def initfp(self, file: IO[bytes]) -> None: ...
def getfp(self) -> IO[bytes]: ...
def rewind(self) -> None: ...
def close(self) -> None: ...
def tell(self) -> int: ...
def getnchannels(self) -> int: ...
def getnframes(self) -> int: ...
def getsampwidth(self) -> int: ...
def getframerate(self) -> int: ...
def getcomptype(self) -> bytes: ...
def getcompname(self) -> bytes: ...
def getparams(self) -> _aifc_params: ...
def getmarkers(self) -> list[_Marker] | None: ...
def getmark(self, id: int) -> _Marker: ...
def setpos(self, pos: int) -> None: ...
def readframes(self, nframes: int) -> bytes: ...
class Aifc_write:
def __init__(self, f: _File) -> None: ...
def __del__(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
def initfp(self, file: IO[bytes]) -> None: ...
def aiff(self) -> None: ...
def aifc(self) -> None: ...
def setnchannels(self, nchannels: int) -> None: ...
def getnchannels(self) -> int: ...
def setsampwidth(self, sampwidth: int) -> None: ...
def getsampwidth(self) -> int: ...
def setframerate(self, framerate: int) -> None: ...
def getframerate(self) -> int: ...
def setnframes(self, nframes: int) -> None: ...
def getnframes(self) -> int: ...
def setcomptype(self, comptype: bytes, compname: bytes) -> None: ...
def getcomptype(self) -> bytes: ...
def getcompname(self) -> bytes: ...
def setparams(self, params: tuple[int, int, int, int, bytes, bytes]) -> None: ...
def getparams(self) -> _aifc_params: ...
def setmark(self, id: int, pos: int, name: bytes) -> None: ...
def getmark(self, id: int) -> _Marker: ...
def getmarkers(self) -> list[_Marker] | None: ...
def tell(self) -> int: ...
def writeframesraw(self, data: Any) -> None: ... # Actual type for data is Buffer Protocol
def writeframes(self, data: Any) -> None: ...
def close(self) -> None: ...
@overload
def open(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ...
@overload
def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
@overload
def open(f: _File, mode: str | None = None) -> Any: ...
@@ -1,156 +0,0 @@
import sys
from typing import Literal
if sys.version_info >= (3, 14):
import enum
import types
from _typeshed import AnnotateFunc, AnnotationForm, EvaluateFunc, SupportsItems
from collections.abc import Mapping
from typing import Any, ParamSpec, TypeVar, TypeVarTuple, final, overload
from warnings import deprecated
__all__ = [
"Format",
"ForwardRef",
"call_annotate_function",
"call_evaluate_function",
"get_annotate_from_class_namespace",
"get_annotations",
"annotations_to_string",
"type_repr",
]
class Format(enum.IntEnum):
VALUE = 1
VALUE_WITH_FAKE_GLOBALS = 2
FORWARDREF = 3
STRING = 4
@final
class ForwardRef:
__slots__ = (
"__forward_is_argument__",
"__forward_is_class__",
"__forward_module__",
"__weakref__",
"__arg__",
"__globals__",
"__extra_names__",
"__code__",
"__ast_node__",
"__cell__",
"__owner__",
"__stringifier_dict__",
"__resolved_str_cache__",
)
__forward_is_argument__: bool
__forward_is_class__: bool
__forward_module__: str | None
__resolved_str_cache__: str | None
def __init__(
self, arg: str, *, module: str | None = None, owner: object = None, is_argument: bool = True, is_class: bool = False
) -> None: ...
@overload
def evaluate(
self,
*,
globals: dict[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None,
owner: object = None,
format: Literal[Format.STRING],
) -> str: ...
@overload
def evaluate(
self,
*,
globals: dict[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None,
owner: object = None,
format: Literal[Format.FORWARDREF],
) -> AnnotationForm | ForwardRef: ...
@overload
def evaluate(
self,
*,
globals: dict[str, Any] | None = None,
locals: Mapping[str, Any] | None = None,
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] | None = None,
owner: object = None,
format: Format = Format.VALUE, # noqa: Y011
) -> AnnotationForm: ...
@deprecated("Use `ForwardRef.evaluate()` or `typing.evaluate_forward_ref()` instead.")
def _evaluate(
self,
globalns: dict[str, Any] | None,
localns: Mapping[str, Any] | None,
type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = ...,
*,
recursive_guard: frozenset[str],
) -> AnnotationForm: ...
@property
def __forward_arg__(self) -> str: ...
@property
def __forward_code__(self) -> types.CodeType: ...
@property
def __resolved_str__(self) -> str: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __or__(self, other: Any) -> types.UnionType: ...
def __ror__(self, other: Any) -> types.UnionType: ...
@overload
def call_evaluate_function(evaluate: EvaluateFunc, format: Literal[Format.STRING], *, owner: object = None) -> str: ...
@overload
def call_evaluate_function(
evaluate: EvaluateFunc, format: Literal[Format.FORWARDREF], *, owner: object = None
) -> AnnotationForm | ForwardRef: ...
@overload
def call_evaluate_function(evaluate: EvaluateFunc, format: Format, *, owner: object = None) -> AnnotationForm: ...
@overload
def call_annotate_function(
annotate: AnnotateFunc, format: Literal[Format.STRING], *, owner: object = None
) -> dict[str, str]: ...
@overload
def call_annotate_function(
annotate: AnnotateFunc, format: Literal[Format.FORWARDREF], *, owner: object = None
) -> dict[str, AnnotationForm | ForwardRef]: ...
@overload
def call_annotate_function(annotate: AnnotateFunc, format: Format, *, owner: object = None) -> dict[str, AnnotationForm]: ...
def get_annotate_from_class_namespace(obj: Mapping[str, object]) -> AnnotateFunc | None: ...
@overload
def get_annotations(
obj: Any, # any object with __annotations__ or __annotate__
*,
globals: dict[str, object] | None = None,
locals: Mapping[str, object] | None = None,
eval_str: bool = False,
format: Literal[Format.STRING],
) -> dict[str, str]: ...
@overload
def get_annotations(
obj: Any,
*,
globals: dict[str, object] | None = None,
locals: Mapping[str, object] | None = None,
eval_str: bool = False,
format: Literal[Format.FORWARDREF],
) -> dict[str, AnnotationForm | ForwardRef]: ...
@overload
def get_annotations(
obj: Any,
*,
globals: dict[str, object] | None = None,
locals: Mapping[str, object] | None = None,
eval_str: bool = False,
format: Format = Format.VALUE, # noqa: Y011
) -> dict[str, AnnotationForm]: ...
def type_repr(value: object) -> str: ...
def annotations_to_string(annotations: SupportsItems[str, object]) -> dict[str, str]: ...
@@ -1,3 +0,0 @@
from _typeshed import ReadableBuffer
def geohash(latitude: float, longitude: float, datedow: ReadableBuffer) -> None: ...
@@ -1,113 +0,0 @@
import sys
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from collections.abc import Iterable, MutableSequence
from types import GenericAlias
from typing import Any, ClassVar, Literal, SupportsIndex, TypeAlias, TypeVar, overload
from typing_extensions import Self, deprecated, disjoint_base
_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
if sys.version_info >= (3, 15):
_FloatTypeCode: TypeAlias = Literal["f", "d", "e", "Zf", "Zd"]
else:
_FloatTypeCode: TypeAlias = Literal["f", "d"]
if sys.version_info >= (3, 13):
_UnicodeTypeCode: TypeAlias = Literal["u", "w"]
else:
_UnicodeTypeCode: TypeAlias = Literal["u"]
_TypeCode: TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
_T = TypeVar("_T", int, float, str)
if sys.version_info >= (3, 15):
typecodes: tuple[str, ...]
else:
typecodes: str
@disjoint_base
class array(MutableSequence[_T]):
@property
def typecode(self) -> _TypeCode: ...
@property
def itemsize(self) -> int: ...
@overload
def __new__(
cls: type[array[int]], typecode: _IntTypeCode, initializer: bytes | bytearray | Iterable[int] = ..., /
) -> array[int]: ...
@overload
def __new__(
cls: type[array[float]], typecode: _FloatTypeCode, initializer: bytes | bytearray | Iterable[float] = ..., /
) -> array[float]: ...
if sys.version_info >= (3, 13):
@overload
def __new__(
cls: type[array[str]], typecode: Literal["w"], initializer: bytes | bytearray | Iterable[str] = ..., /
) -> array[str]: ...
@overload
@deprecated("Deprecated since Python 3.3; will be removed in Python 3.16. Use 'w' typecode instead.")
def __new__(
cls: type[array[str]], typecode: Literal["u"], initializer: bytes | bytearray | Iterable[str] = ..., /
) -> array[str]: ...
else:
@overload
@deprecated("Deprecated since Python 3.3; will be removed in Python 3.16.")
def __new__(
cls: type[array[str]], typecode: Literal["u"], initializer: bytes | bytearray | Iterable[str] = ..., /
) -> array[str]: ...
@overload
def __new__(cls, typecode: str, initializer: Iterable[_T], /) -> Self: ...
@overload
def __new__(cls, typecode: str, initializer: bytes | bytearray = ..., /) -> Self: ...
def append(self, v: _T, /) -> None: ...
def buffer_info(self) -> tuple[int, int]: ...
def byteswap(self) -> None: ...
def count(self, v: _T, /) -> int: ...
def extend(self, bb: Iterable[_T], /) -> None: ...
def frombytes(self, buffer: ReadableBuffer, /) -> None: ...
def fromfile(self, f: SupportsRead[bytes], n: int, /) -> None: ...
def fromlist(self, list: list[_T], /) -> None: ...
def fromunicode(self, ustr: str, /) -> None: ...
def index(self, v: _T, start: int = 0, stop: int = sys.maxsize, /) -> int: ...
def insert(self, i: int, v: _T, /) -> None: ...
def pop(self, i: int = -1, /) -> _T: ...
def remove(self, v: _T, /) -> None: ...
def tobytes(self) -> bytes: ...
def tofile(self, f: SupportsWrite[bytes], /) -> None: ...
def tolist(self) -> list[_T]: ...
def tounicode(self) -> str: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def __contains__(self, value: object, /) -> bool: ...
def __len__(self) -> int: ...
@overload
def __getitem__(self, key: SupportsIndex, /) -> _T: ...
@overload
def __getitem__(self, key: slice[SupportsIndex | None], /) -> array[_T]: ...
@overload # type: ignore[override]
def __setitem__(self, key: SupportsIndex, value: _T, /) -> None: ...
@overload
def __setitem__(self, key: slice[SupportsIndex | None], value: array[_T], /) -> None: ...
def __delitem__(self, key: SupportsIndex | slice[SupportsIndex | None], /) -> None: ...
def __add__(self, value: array[_T], /) -> array[_T]: ...
def __eq__(self, value: object, /) -> bool: ...
def __ge__(self, value: array[_T], /) -> bool: ...
def __gt__(self, value: array[_T], /) -> bool: ...
def __iadd__(self, value: array[_T], /) -> Self: ... # type: ignore[override]
def __imul__(self, value: int, /) -> Self: ...
def __le__(self, value: array[_T], /) -> bool: ...
def __lt__(self, value: array[_T], /) -> bool: ...
def __mul__(self, value: int, /) -> array[_T]: ...
def __rmul__(self, value: int, /) -> array[_T]: ...
def __copy__(self) -> array[_T]: ...
def __deepcopy__(self, unused: Any, /) -> array[_T]: ...
def __buffer__(self, flags: int, /) -> memoryview: ...
def __release_buffer__(self, buffer: memoryview, /) -> None: ...
if sys.version_info >= (3, 12):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
ArrayType = array
File diff suppressed because it is too large. Load diff
@@ -1,21 +0,0 @@
import asyncore
from abc import abstractmethod
class simple_producer:
def __init__(self, data: bytes, buffer_size: int = 512) -> None: ...
def more(self) -> bytes: ...
class async_chat(asyncore.dispatcher):
ac_in_buffer_size: int
ac_out_buffer_size: int
@abstractmethod
def collect_incoming_data(self, data: bytes) -> None: ...
@abstractmethod
def found_terminator(self) -> None: ...
def set_terminator(self, term: bytes | int | None) -> None: ...
def get_terminator(self) -> bytes | int | None: ...
def push(self, data: bytes) -> None: ...
def push_with_producer(self, producer: simple_producer) -> None: ...
def close_when_done(self) -> None: ...
def initiate_send(self) -> None: ...
def discard_buffers(self) -> None: ...
File diff suppressed because it is too large. Load diff
@@ -1,498 +0,0 @@
import ssl
import sys
from _typeshed import FileDescriptorLike, ReadableBuffer, WriteableBuffer
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 concurrent.futures import Executor, ThreadPoolExecutor
from contextvars import Context
from socket import AddressFamily, AddressInfo, SocketKind, _Address, _RetAddress, socket
from typing import IO, Any, Literal, TypeAlias, TypeVar, overload
from typing_extensions import TypeVarTuple, Unpack
# Keep asyncio.__all__ updated with any changes to __all__ here
__all__ = ("BaseEventLoop", "Server")
_T = TypeVar("_T")
_Ts = TypeVarTuple("_Ts")
_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
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: ...
if sys.version_info >= (3, 13):
def close_clients(self) -> None: ...
def abort_clients(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
def is_serving(self) -> bool: ...
async def start_serving(self) -> None: ...
async def serve_forever(self) -> None: ...
@property
def sockets(self) -> tuple[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[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> Handle: ...
def call_later(
self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> TimerHandle: ...
def call_at(
self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> TimerHandle: ...
def time(self) -> float: ...
# Future methods
def create_future(self) -> Future[Any]: ...
# Tasks methods
if sys.version_info >= (3, 14):
def create_task(
self,
coro: _CoroutineLike[_T],
*,
name: object = None,
context: Context | None = None,
eager_start: bool | None = None,
) -> Task[_T]: ...
elif sys.version_info >= (3, 11):
def create_task(self, coro: _CoroutineLike[_T], *, name: object = None, context: Context | None = None) -> Task[_T]: ...
else:
def create_task(self, coro: _CoroutineLike[_T], *, name: object = None) -> 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[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> Handle: ...
def run_in_executor(self, executor: Executor | None, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
def set_default_executor(self, executor: ThreadPoolExecutor) -> None: ... # type: ignore[override]
# 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] | tuple[int, bytes]]]: ...
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]: ...
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,
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]: ...
if sys.version_info >= (3, 13):
# 3.13 added `keep_alive`.
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = 0,
flags: int = 1,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
keep_alive: 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 = 0,
flags: int = 1,
sock: socket = ...,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
keep_alive: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
elif sys.version_info >= (3, 11):
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
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 = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
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: ...
else:
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
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 = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
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: ...
if sys.version_info >= (3, 11):
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:
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,
) -> 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,
text: Literal[False] | None = None,
**kwargs: Any,
) -> tuple[SubprocessTransport, _ProtocolT]: ...
def add_reader(self, fd: FileDescriptorLike, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
def remove_reader(self, fd: FileDescriptorLike) -> bool: ...
def add_writer(self, fd: FileDescriptorLike, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> 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[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> 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: ...
else:
async def shutdown_default_executor(self) -> None: ...
def __del__(self) -> None: ...
@@ -1,17 +0,0 @@
from _asyncio import Future
from collections.abc import Callable, Sequence
from contextvars import Context
from typing import Any, Final
from typing_extensions import TypeIs
from . import futures
__all__ = ()
_PENDING: Final = "PENDING" # undocumented
_CANCELLED: Final = "CANCELLED" # undocumented
_FINISHED: Final = "FINISHED" # undocumented
def isfuture(obj: object) -> TypeIs[Future[Any]]: ...
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
@@ -1,62 +0,0 @@
import subprocess
from collections import deque
from collections.abc import Callable, Sequence
from typing import IO, Any, TypeAlias
from . import events, futures, protocols, transports
_File: TypeAlias = int | IO[Any] | None
class BaseSubprocessTransport(transports.SubprocessTransport):
_closed: bool # undocumented
_protocol: protocols.SubprocessProtocol # undocumented
_loop: events.AbstractEventLoop # undocumented
_proc: subprocess.Popen[Any] | None # undocumented
_pid: int | None # undocumented
_returncode: int | None # undocumented
_exit_waiters: list[futures.Future[Any]] # undocumented
_pending_calls: deque[tuple[Callable[..., Any], tuple[Any, ...]]] # undocumented
_pipes: dict[int, _File] # undocumented
_finished: bool # undocumented
def __init__(
self,
loop: events.AbstractEventLoop,
protocol: protocols.SubprocessProtocol,
args: str | bytes | Sequence[str | bytes],
shell: bool,
stdin: _File,
stdout: _File,
stderr: _File,
bufsize: int,
waiter: futures.Future[Any] | None = None,
extra: Any | None = None,
**kwargs: Any,
) -> None: ...
def _start(
self,
args: str | bytes | Sequence[str | bytes],
shell: bool,
stdin: _File,
stdout: _File,
stderr: _File,
bufsize: int,
**kwargs: Any,
) -> None: ... # undocumented
def get_pid(self) -> int | None: ... # type: ignore[override]
def get_pipe_transport(self, fd: int) -> _File: ... # type: ignore[override]
def _check_proc(self) -> None: ... # undocumented
def send_signal(self, signal: int) -> None: ...
async def _connect_pipes(self, waiter: futures.Future[Any] | None) -> None: ... # undocumented
def _call(self, cb: Callable[..., object], *data: Any) -> None: ... # undocumented
def _pipe_connection_lost(self, fd: int, exc: BaseException | None) -> None: ... # undocumented
def _pipe_data_received(self, fd: int, data: bytes) -> None: ... # undocumented
def _process_exited(self, returncode: int) -> None: ... # undocumented
async def _wait(self) -> int: ... # undocumented
def _try_finish(self) -> None: ... # undocumented
def _call_connection_lost(self, exc: BaseException | None) -> None: ... # undocumented
def __del__(self) -> None: ...
class WriteSubprocessPipeProto(protocols.BaseProtocol): # undocumented
def __init__(self, proc: BaseSubprocessTransport, fd: int) -> None: ...
class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): ... # undocumented
@@ -1,17 +0,0 @@
import sys
from _typeshed import StrOrBytesPath
from types import FrameType
from typing import Any
from .tasks import Task
def _task_repr_info(task: Task[Any]) -> list[str]: ... # undocumented
if sys.version_info >= (3, 13):
def _task_repr(task: Task[Any]) -> str: ... # undocumented
elif sys.version_info >= (3, 11):
def _task_repr(self: Task[Any]) -> str: ... # undocumented
def _task_get_stack(task: Task[Any], limit: int | None) -> list[FrameType]: ... # undocumented
def _task_print_stack(task: Task[Any], limit: int | None, file: StrOrBytesPath) -> None: ... # undocumented
@@ -1,20 +0,0 @@
import enum
import sys
from typing import Final
LOG_THRESHOLD_FOR_CONNLOST_WRITES: Final = 5
ACCEPT_RETRY_DELAY: Final = 1
DEBUG_STACK_DEPTH: Final = 10
SSL_HANDSHAKE_TIMEOUT: float
SENDFILE_FALLBACK_READBUFFER_SIZE: Final = 262144
if sys.version_info >= (3, 11):
SSL_SHUTDOWN_TIMEOUT: float
FLOW_CONTROL_HIGH_WATER_SSL_READ: Final = 256
FLOW_CONTROL_HIGH_WATER_SSL_WRITE: Final = 512
if sys.version_info >= (3, 12):
THREAD_JOIN_TIMEOUT: Final = 300
class _SendfileMode(enum.Enum):
UNSUPPORTED = 1
TRY_NATIVE = 2
FALLBACK = 3
@@ -1,45 +0,0 @@
import sys
from collections.abc import Awaitable, Callable, Coroutine
from typing import Any, ParamSpec, TypeGuard, TypeVar, overload
from typing_extensions import TypeIs, deprecated
# Keep asyncio.__all__ updated with any changes to __all__ here
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):
@deprecated("Deprecated since Python 3.8; removed in Python 3.11. Use `async def` instead.")
def coroutine(func: _FunctionT) -> _FunctionT: ...
def iscoroutine(obj: object) -> TypeIs[Coroutine[Any, Any, Any]]: ...
if sys.version_info >= (3, 11):
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ...
else:
# Sometimes needed in Python < 3.11 due to the fact that it supports @coroutine
# which was removed in 3.11 which the inspect version doesn't support.
@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]]]: ...
@@ -1,671 +0,0 @@
import ssl
import sys
from _asyncio import (
_get_running_loop as _get_running_loop,
_set_running_loop as _set_running_loop,
get_event_loop as get_event_loop,
get_running_loop as get_running_loop,
)
from _typeshed import FileDescriptorLike, ReadableBuffer, StrPath, Unused, WriteableBuffer
from abc import ABCMeta, abstractmethod
from collections.abc import Callable, Sequence
from concurrent.futures import Executor
from contextvars import Context
from socket import AddressFamily, AddressInfo, SocketKind, _Address, _RetAddress, socket
from typing import IO, Any, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeVarTuple, Unpack, deprecated
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
if sys.version_info < (3, 14):
from .unix_events import AbstractChildWatcher
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 14):
__all__ = (
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
"get_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"set_event_loop",
"new_event_loop",
"_set_running_loop",
"get_running_loop",
"_get_running_loop",
)
else:
__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",
)
_T = TypeVar("_T")
_Ts = TypeVarTuple("_Ts")
_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_check_only
class _TaskFactory(Protocol):
def __call__(self, loop: AbstractEventLoop, factory: _CoroutineLike[_T], /) -> Future[_T]: ...
class Handle:
__slots__ = ("_callback", "_args", "_cancelled", "_loop", "_source_traceback", "_repr", "__weakref__", "_context")
_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):
__slots__ = ["_scheduled", "_when"]
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: ...
if sys.version_info >= (3, 13):
@abstractmethod
def close_clients(self) -> None: ...
@abstractmethod
def abort_clients(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.
# "context" added in 3.9.10/3.10.2 for call_*
@abstractmethod
def call_soon(
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> Handle: ...
@abstractmethod
def call_later(
self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> TimerHandle: ...
@abstractmethod
def call_at(
self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> TimerHandle: ...
@abstractmethod
def time(self) -> float: ...
# Future methods
@abstractmethod
def create_future(self) -> Future[Any]: ...
# Tasks methods
if sys.version_info >= (3, 14):
@abstractmethod
def create_task(
self,
coro: _CoroutineLike[_T],
*,
name: str | None = None,
context: Context | None = None,
eager_start: bool | None = None,
) -> Task[_T]: ...
elif sys.version_info >= (3, 11):
@abstractmethod
def create_task(
self, coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None
) -> Task[_T]: ...
else:
@abstractmethod
def create_task(self, coro: _CoroutineLike[_T], *, name: str | None = None) -> 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
# "context" added in 3.9.10/3.10.2
@abstractmethod
def call_soon_threadsafe(
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> Handle: ...
@abstractmethod
def run_in_executor(self, executor: Executor | None, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
@abstractmethod
def set_default_executor(self, executor: Executor) -> 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] | tuple[int, bytes]]]: ...
@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]: ...
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,
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]: ...
if sys.version_info >= (3, 13):
# 3.13 added `keep_alive`.
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
keep_alive: 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 = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: socket = ...,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
keep_alive: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
elif 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 = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
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 = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
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: ...
else:
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
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 = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
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: ...
if sys.version_info >= (3, 11):
@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:
@abstractmethod
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,
) -> 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]: ...
else:
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 = 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[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
@abstractmethod
def remove_reader(self, fd: FileDescriptorLike) -> bool: ...
@abstractmethod
def add_writer(self, fd: FileDescriptorLike, callback: Callable[[Unpack[_Ts]], Any], *args: Unpack[_Ts]) -> None: ...
@abstractmethod
def remove_writer(self, fd: FileDescriptorLike) -> bool: ...
@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[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> 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: ...
@abstractmethod
async def shutdown_default_executor(self) -> None: ...
if sys.version_info >= (3, 14):
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: ...
else:
@type_check_only
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
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
def get_child_watcher(self) -> AbstractChildWatcher: ...
@abstractmethod
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...
AbstractEventLoopPolicy = _AbstractEventLoopPolicy
if sys.version_info >= (3, 14):
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: ...
else:
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: ...
if sys.version_info >= (3, 14):
def _get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
def _set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...
@deprecated("Deprecated since Python 3.14; will be removed in Python 3.16.")
def get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
@deprecated("Deprecated since Python 3.14; will be removed in Python 3.16.")
def set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
def new_event_loop() -> AbstractEventLoop: ...
if sys.version_info < (3, 14):
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
def get_child_watcher() -> AbstractChildWatcher: ...
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
@@ -1,44 +0,0 @@
import sys
# Keep asyncio.__all__ updated with any changes to __all__ here
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): ...
if sys.version_info >= (3, 11):
from builtins import TimeoutError as TimeoutError
else:
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): ...
@@ -1,31 +0,0 @@
import functools
import sys
import traceback
from collections.abc import Iterable
from types import FrameType, FunctionType
from typing import Any, TypeAlias, overload, type_check_only
@type_check_only
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: ...
if sys.version_info >= (3, 13):
def _format_callback_source(func: object, args: Iterable[Any], *, debug: bool = False) -> str: ...
def _format_args_and_kwargs(args: Iterable[Any], kwargs: dict[str, Any], *, debug: bool = False) -> str: ...
def _format_callback(
func: object, args: Iterable[Any], kwargs: dict[str, Any], *, debug: bool = False, suffix: str = ""
) -> str: ...
else:
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: ...
@@ -1,19 +0,0 @@
import sys
from _asyncio import Future as Future
from concurrent.futures._base import Future as _ConcurrentFuture
from typing import TypeVar
from .base_futures import isfuture as isfuture
from .events import AbstractEventLoop
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 14):
from _asyncio import future_add_to_awaited_by, future_discard_from_awaited_by
__all__ = ("Future", "wrap_future", "isfuture", "future_discard_from_awaited_by", "future_add_to_awaited_by")
else:
__all__ = ("Future", "wrap_future", "isfuture")
_T = TypeVar("_T")
def wrap_future(future: _ConcurrentFuture[_T] | Future[_T], *, loop: AbstractEventLoop | None = None) -> Future[_T]: ...
@@ -1,29 +0,0 @@
import sys
from _typeshed import SupportsWrite
from asyncio import Future
from dataclasses import dataclass
from types import FrameType
from typing import Any, overload
if sys.version_info >= (3, 14):
__all__ = ("capture_call_graph", "format_call_graph", "print_call_graph", "FrameCallGraphEntry", "FutureCallGraph")
@dataclass(frozen=True, slots=True)
class FrameCallGraphEntry:
frame: FrameType
@dataclass(frozen=True, slots=True)
class FutureCallGraph:
future: Future[Any]
call_stack: tuple[FrameCallGraphEntry, ...]
awaited_by: tuple[FutureCallGraph, ...]
@overload
def capture_call_graph(future: None = None, /, *, depth: int = 1, limit: int | None = None) -> FutureCallGraph | None: ...
@overload
def capture_call_graph(future: Future[Any], /, *, depth: int = 1, limit: int | None = None) -> FutureCallGraph | None: ...
def format_call_graph(future: Future[Any] | None = None, /, *, depth: int = 1, limit: int | None = None) -> str: ...
def print_call_graph(
future: Future[Any] | None = None, /, *, file: SupportsWrite[str] | None = None, depth: int = 1, limit: int | None = None
) -> None: ...
@@ -1,83 +0,0 @@
import enum
import sys
from _typeshed import Unused
from collections import deque
from collections.abc import Callable
from types import TracebackType
from typing import Any, Literal, TypeVar
from typing_extensions import Self
from .futures import Future
from .mixins import _LoopBoundMixin
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 11):
__all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore", "Barrier")
else:
__all__ = ("Lock", "Event", "Condition", "Semaphore", "BoundedSemaphore")
_T = TypeVar("_T")
class _ContextManagerMixin:
async def __aenter__(self) -> None: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> None: ...
class Lock(_ContextManagerMixin, _LoopBoundMixin):
_waiters: deque[Future[Any]] | None
def __init__(self) -> None: ...
def locked(self) -> bool: ...
async def acquire(self) -> Literal[True]: ...
def release(self) -> None: ...
class Event(_LoopBoundMixin):
_waiters: deque[Future[Any]]
def __init__(self) -> None: ...
def is_set(self) -> bool: ...
def set(self) -> None: ...
def clear(self) -> None: ...
async def wait(self) -> Literal[True]: ...
class Condition(_ContextManagerMixin, _LoopBoundMixin):
_waiters: deque[Future[Any]]
def __init__(self, lock: Lock | 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, _LoopBoundMixin):
_value: int
_waiters: deque[Future[Any]] | None
def __init__(self, value: int = 1) -> 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 = "filling"
DRAINING = "draining"
RESETTING = "resetting"
BROKEN = "broken"
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: ...
@@ -1,3 +0,0 @@
import logging
logger: logging.Logger
@@ -1,9 +0,0 @@
import sys
import threading
from typing_extensions import Never
_global_lock: threading.Lock
class _LoopBoundMixin:
if sys.version_info < (3, 11):
def __init__(self, *, loop: Never = ...) -> None: ...
@@ -1,53 +0,0 @@
from collections.abc import Mapping
from socket import socket
from typing import Any, ClassVar, Literal
from . import base_events, constants, events, futures, streams, transports
__all__ = ("BaseProactorEventLoop",)
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: ...
def __del__(self) -> None: ...
class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport):
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: ...
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: ...
async def sock_recv(self, sock: socket, n: int) -> bytes: ...
@@ -1,41 +0,0 @@
from _typeshed import ReadableBuffer
from asyncio import transports
from typing import Any
# Keep asyncio.__all__ updated with any changes to __all__ here
__all__ = ("BaseProtocol", "Protocol", "DatagramProtocol", "SubprocessProtocol", "BufferedProtocol")
class BaseProtocol:
__slots__ = ()
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):
# Need annotation or mypy will complain about 'Cannot determine type of "__slots__" in base class'
__slots__: tuple[str, ...] = ()
def data_received(self, data: bytes) -> None: ...
def eof_received(self) -> bool | None: ...
class BufferedProtocol(BaseProtocol):
__slots__ = ()
def get_buffer(self, sizehint: int) -> ReadableBuffer: ...
def buffer_updated(self, nbytes: int) -> None: ...
def eof_received(self) -> bool | None: ...
class DatagramProtocol(BaseProtocol):
__slots__ = ()
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):
__slots__: tuple[str, ...] = ()
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: ...
@@ -1,45 +0,0 @@
import sys
from _typeshed import SupportsRichComparisonT
from types import GenericAlias
from typing import Any, Generic, TypeVar
from .mixins import _LoopBoundMixin
class QueueEmpty(Exception): ...
class QueueFull(Exception): ...
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 13):
__all__ = ("Queue", "PriorityQueue", "LifoQueue", "QueueFull", "QueueEmpty", "QueueShutDown")
else:
__all__ = ("Queue", "PriorityQueue", "LifoQueue", "QueueFull", "QueueEmpty")
_T = TypeVar("_T")
if sys.version_info >= (3, 13):
class QueueShutDown(Exception): ...
class Queue(_LoopBoundMixin, Generic[_T]):
def __init__(self, maxsize: int = 0) -> 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: ...
def __class_getitem__(cls, type: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 13):
def shutdown(self, immediate: bool = False) -> None: ...
class PriorityQueue(Queue[SupportsRichComparisonT]): ...
class LifoQueue(Queue[_T]): ...
@@ -1,41 +0,0 @@
import sys
from _typeshed import Unused
from collections.abc import Awaitable, Callable, Coroutine
from contextvars import Context
from typing import Any, TypeVar, final
from typing_extensions import Self
from .events import AbstractEventLoop
# Keep asyncio.__all__ updated with any changes to __all__ here
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: ...
if sys.version_info >= (3, 14):
def run(self, coro: Awaitable[_T], *, context: Context | None = None) -> _T: ...
else:
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = None) -> _T: ...
if sys.version_info >= (3, 14):
def run(
main: Awaitable[_T], *, debug: bool | None = None, loop_factory: Callable[[], AbstractEventLoop] | None = None
) -> _T: ...
elif sys.version_info >= (3, 12):
def run(
main: Coroutine[Any, Any, _T], *, debug: bool | None = None, loop_factory: Callable[[], AbstractEventLoop] | None = None
) -> _T: ...
else:
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = None) -> _T: ...
@@ -1,10 +0,0 @@
import selectors
from socket import socket
from . import base_events
__all__ = ("BaseSelectorEventLoop",)
class BaseSelectorEventLoop(base_events.BaseEventLoop):
def __init__(self, selector: selectors.BaseSelector | None = None) -> None: ...
async def sock_recv(self, sock: socket, n: int) -> bytes: ...
@@ -1,164 +0,0 @@
import ssl
import sys
from collections import deque
from collections.abc import Callable
from enum import Enum
from typing import Any, ClassVar, Final, 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 = "UNWRAPPED"
DO_HANDSHAKE = "DO_HANDSHAKE"
WRAPPED = "WRAPPED"
FLUSHING = "FLUSHING"
SHUTDOWN = "SHUTDOWN"
class AppProtocolState(Enum):
STATE_INIT = "STATE_INIT"
STATE_CON_MADE = "STATE_CON_MADE"
STATE_EOF = "STATE_EOF"
STATE_CON_LOST = "STATE_CON_LOST"
def add_flowcontrol_defaults(high: int | None, low: int | None, kb: int) -> tuple[int, int]: ...
else:
_UNWRAPPED: Final = "UNWRAPPED"
_DO_HANDSHAKE: Final = "DO_HANDSHAKE"
_WRAPPED: Final = "WRAPPED"
_SHUTDOWN: Final = "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[Any]) -> None: ... # any memoryview format or shape
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: ...
def __del__(self) -> None: ...
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]]
_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: ...
if sys.version_info >= (3, 11):
def _abort(self, exc: BaseException | None) -> None: ...
def get_buffer(self, n: int) -> memoryview: ...
else:
def _abort(self) -> None: ...
def _finalize(self) -> None: ...
def _process_write_backlog(self) -> None: ...
@@ -1,10 +0,0 @@
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]]: ...
@@ -1,124 +0,0 @@
import ssl
import sys
from _typeshed import ReadableBuffer, StrPath
from collections.abc import Awaitable, Callable, Iterable, Sequence, Sized
from types import ModuleType
from typing import Any, Protocol, SupportsIndex, TypeAlias, type_check_only
from typing_extensions import Self
from . import events, protocols, transports
from .base_events import Server
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.platform == "win32":
__all__ = ("StreamReader", "StreamWriter", "StreamReaderProtocol", "open_connection", "start_server")
else:
__all__ = (
"StreamReader",
"StreamWriter",
"StreamReaderProtocol",
"open_connection",
"start_server",
"open_unix_connection",
"start_unix_server",
)
_ClientConnectedCallback: TypeAlias = Callable[[StreamReader, StreamWriter], Awaitable[None] | None]
@type_check_only
class _ReaduntilBuffer(ReadableBuffer, Sized, Protocol): ...
async def open_connection(
host: str | None = None,
port: int | str | None = None,
*,
limit: int = 65536,
ssl_handshake_timeout: float | None = 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 = None,
**kwds: Any,
) -> Server: ...
if sys.platform != "win32":
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: ...
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: ...
def __del__(self) -> 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: ...
if sys.version_info >= (3, 13):
def __del__(self, warnings: ModuleType = ...) -> None: ...
elif sys.version_info >= (3, 11):
def __del__(self) -> None: ...
class StreamReader:
def __init__(self, limit: int = 65536, loop: events.AbstractEventLoop | None = None) -> None: ...
def exception(self) -> Exception | None: ...
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: ...
if sys.version_info >= (3, 13):
async def readuntil(self, separator: _ReaduntilBuffer | tuple[_ReaduntilBuffer, ...] = b"\n") -> bytes: ...
else:
async def readuntil(self, separator: _ReaduntilBuffer = 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: ...
@@ -1,166 +0,0 @@
import subprocess
import sys
from _typeshed import StrOrBytesPath
from asyncio import events, protocols, streams, transports
from collections.abc import Callable, Collection
from typing import IO, Any, Literal
# Keep asyncio.__all__ updated with any changes to __all__ here
__all__ = ("create_subprocess_exec", "create_subprocess_shell")
PIPE: int
STDOUT: int
DEVNULL: int
class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol):
stdin: streams.StreamWriter | None
stdout: streams.StreamReader | None
stderr: streams.StreamReader | None
def __init__(self, limit: int, loop: events.AbstractEventLoop) -> None: ...
def pipe_data_received(self, fd: int, data: bytes | str) -> None: ...
class Process:
stdin: streams.StreamWriter | None
stdout: streams.StreamReader | None
stderr: streams.StreamReader | None
pid: int
def __init__(
self, transport: transports.BaseTransport, protocol: protocols.BaseProtocol, loop: events.AbstractEventLoop
) -> None: ...
@property
def returncode(self) -> int | None: ...
async def wait(self) -> int: ...
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
async def communicate(self, input: bytes | bytearray | memoryview | None = None) -> tuple[bytes, bytes]: ...
if sys.version_info >= (3, 11):
async def create_subprocess_shell(
cmd: str | bytes,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False] | None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: StrOrBytesPath | None = None,
preexec_fn: Callable[[], Any] | None = None,
close_fds: bool = True,
cwd: StrOrBytesPath | None = None,
env: subprocess._ENV | None = None,
startupinfo: Any | None = None,
creationflags: int = 0,
restore_signals: bool = True,
start_new_session: bool = False,
pass_fds: Collection[int] = (),
group: None | str | int = None,
extra_groups: None | Collection[str | int] = None,
user: None | str | int = None,
umask: int = -1,
process_group: int | None = None,
pipesize: int = -1,
) -> Process: ...
async def create_subprocess_exec(
program: StrOrBytesPath,
*args: StrOrBytesPath,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
universal_newlines: Literal[False] = False,
shell: Literal[False] = False,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False] | None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: StrOrBytesPath | None = None,
preexec_fn: Callable[[], Any] | None = None,
close_fds: bool = True,
cwd: StrOrBytesPath | None = None,
env: subprocess._ENV | None = None,
startupinfo: Any | None = None,
creationflags: int = 0,
restore_signals: bool = True,
start_new_session: bool = False,
pass_fds: Collection[int] = (),
group: None | str | int = None,
extra_groups: None | Collection[str | int] = None,
user: None | str | int = None,
umask: int = -1,
process_group: int | None = None,
pipesize: int = -1,
) -> Process: ...
else:
async def create_subprocess_shell(
cmd: str | bytes,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
*,
# These parameters are forced to these values by BaseEventLoop.subprocess_shell
universal_newlines: Literal[False] = False,
shell: Literal[True] = True,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False] | None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: StrOrBytesPath | None = None,
preexec_fn: Callable[[], Any] | None = None,
close_fds: bool = True,
cwd: StrOrBytesPath | None = None,
env: subprocess._ENV | None = None,
startupinfo: Any | None = None,
creationflags: int = 0,
restore_signals: bool = True,
start_new_session: bool = False,
pass_fds: Collection[int] = (),
group: None | str | int = None,
extra_groups: None | Collection[str | int] = None,
user: None | str | int = None,
umask: int = -1,
pipesize: int = -1,
) -> Process: ...
async def create_subprocess_exec(
program: StrOrBytesPath,
*args: StrOrBytesPath,
stdin: int | IO[Any] | None = None,
stdout: int | IO[Any] | None = None,
stderr: int | IO[Any] | None = None,
limit: int = 65536,
# These parameters are forced to these values by BaseEventLoop.subprocess_exec
universal_newlines: Literal[False] = False,
shell: Literal[False] = False,
bufsize: Literal[0] = 0,
encoding: None = None,
errors: None = None,
text: Literal[False] | None = None,
# These parameters are taken by subprocess.Popen, which this ultimately delegates to
executable: StrOrBytesPath | None = None,
preexec_fn: Callable[[], Any] | None = None,
close_fds: bool = True,
cwd: StrOrBytesPath | None = None,
env: subprocess._ENV | None = None,
startupinfo: Any | None = None,
creationflags: int = 0,
restore_signals: bool = True,
start_new_session: bool = False,
pass_fds: Collection[int] = (),
group: None | str | int = None,
extra_groups: None | Collection[str | int] = None,
user: None | str | int = None,
umask: int = -1,
pipesize: int = -1,
) -> Process: ...
@@ -1,41 +0,0 @@
import sys
from contextvars import Context
from types import TracebackType
from typing import Any, TypeVar
from typing_extensions import Self
from . import _CoroutineLike
from .events import AbstractEventLoop
from .tasks import Task
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 12):
__all__ = ("TaskGroup",)
else:
__all__ = ["TaskGroup"]
_T = TypeVar("_T")
class TaskGroup:
_loop: AbstractEventLoop | None
_tasks: set[Task[Any]]
async def __aenter__(self) -> Self: ...
async def __aexit__(self, et: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ...
if sys.version_info >= (3, 14):
def create_task(
self,
coro: _CoroutineLike[_T],
*,
name: str | None = None,
context: Context | None = None,
eager_start: bool | None = None,
) -> Task[_T]: ...
else:
def create_task(
self, coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None
) -> Task[_T]: ...
def _on_task_done(self, task: Task[object]) -> None: ...
if sys.version_info >= (3, 15):
def cancel(self) -> None: ...
@@ -1,315 +0,0 @@
import concurrent.futures
import sys
from _asyncio import (
Task as Task,
_enter_task as _enter_task,
_leave_task as _leave_task,
_register_task as _register_task,
_unregister_task as _unregister_task,
)
from collections.abc import AsyncIterator, Awaitable, Coroutine, Generator, Iterable, Iterator
from typing import Any, Final, Literal, Protocol, TypeAlias, TypeVar, overload, type_check_only
from . import _CoroutineLike
from .events import AbstractEventLoop
from .futures import Future
if sys.version_info >= (3, 11):
from contextvars import Context
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 12):
__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",
"create_eager_task_factory",
"eager_task_factory",
"_register_task",
"_unregister_task",
"_enter_task",
"_leave_task",
)
else:
__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")
_T6 = TypeVar("_T6")
_FT = TypeVar("_FT", bound=Future[Any])
if sys.version_info >= (3, 12):
_FutureLike: TypeAlias = Future[_T] | Awaitable[_T]
else:
_FutureLike: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
_TaskYieldType: TypeAlias = Future[object] | None
FIRST_COMPLETED: Final = concurrent.futures.FIRST_COMPLETED
FIRST_EXCEPTION: Final = concurrent.futures.FIRST_EXCEPTION
ALL_COMPLETED: Final = concurrent.futures.ALL_COMPLETED
if sys.version_info >= (3, 13):
@type_check_only
class _SyncAndAsyncIterator(Iterator[Coroutine[Any, Any, _T]], AsyncIterator[Future[_T]], Protocol[_T]): ...
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> _SyncAndAsyncIterator[_T]: ...
else:
def as_completed(fs: Iterable[_FutureLike[_T]], *, timeout: float | None = None) -> Iterator[Future[_T]]: ...
@overload
def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[overload-overlap]
@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.
#
# N.B. Having overlapping overloads is the only way to get acceptable type inference in all edge cases.
@overload
def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap]
@overload
def gather( # type: ignore[overload-overlap]
coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False
) -> Future[tuple[_T1, _T2]]: ...
@overload
def gather( # type: ignore[overload-overlap]
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[overload-overlap]
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[overload-overlap]
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( # type: ignore[overload-overlap]
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],
coro_or_future6: _FutureLike[_T6],
/,
*,
return_exceptions: Literal[False] = False,
) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
@overload
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap]
@overload
def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
@overload
def gather(
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(
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(
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(
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],
coro_or_future6: _FutureLike[_T6],
/,
*,
return_exceptions: bool,
) -> Future[
tuple[
_T1 | BaseException,
_T2 | BaseException,
_T3 | BaseException,
_T4 | BaseException,
_T5 | BaseException,
_T6 | BaseException,
]
]: ...
@overload
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: bool) -> Future[list[_T | BaseException]]: ...
# unlike some asyncio apis, This does strict runtime checking of actually being a coroutine, not of any future-like.
def run_coroutine_threadsafe(coro: Coroutine[Any, Any, _T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
def shield(arg: _FutureLike[_T]) -> Future[_T]: ...
@overload
async def sleep(delay: float) -> None: ...
@overload
async def sleep(delay: float, result: _T) -> _T: ...
async def wait_for(fut: _FutureLike[_T], timeout: float | None) -> _T: ...
if sys.version_info >= (3, 11):
async def wait(
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
) -> tuple[set[_FT], set[_FT]]: ...
else:
@overload
async def wait( # type: ignore[overload-overlap]
fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
) -> tuple[set[_FT], set[_FT]]: ...
@overload
async def wait(
fs: Iterable[Awaitable[_T]], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED"
) -> tuple[set[Task[_T]], set[Task[_T]]]: ...
if sys.version_info >= (3, 12):
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
else:
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 14):
def create_task(
coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None, eager_start: bool | None = None
) -> Task[_T]: ...
elif sys.version_info >= (3, 11):
def create_task(coro: _CoroutineLike[_T], *, name: str | None = None, context: Context | None = None) -> Task[_T]: ...
else:
def create_task(coro: _CoroutineLike[_T], *, name: str | None = None) -> Task[_T]: ...
if sys.version_info >= (3, 12):
from _asyncio import current_task as current_task
else:
def current_task(loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
if sys.version_info >= (3, 14):
def eager_task_factory(
loop: AbstractEventLoop | None,
coro: _TaskCompatibleCoro[_T_co],
*,
name: str | None = None,
context: Context | None = None,
eager_start: bool = True,
) -> Task[_T_co]: ...
elif sys.version_info >= (3, 12):
def eager_task_factory(
loop: AbstractEventLoop | None,
coro: _TaskCompatibleCoro[_T_co],
*,
name: str | None = None,
context: Context | None = None,
) -> Task[_T_co]: ...
if sys.version_info >= (3, 12):
_TaskT_co = TypeVar("_TaskT_co", bound=Task[Any], covariant=True)
@type_check_only
class _CustomTaskConstructor(Protocol[_TaskT_co]):
def __call__(
self,
coro: _TaskCompatibleCoro[Any],
/,
*,
loop: AbstractEventLoop,
name: str | None,
context: Context | None,
eager_start: bool,
) -> _TaskT_co: ...
@type_check_only
class _EagerTaskFactoryType(Protocol[_TaskT_co]):
def __call__(
self,
loop: AbstractEventLoop,
coro: _TaskCompatibleCoro[Any],
*,
name: str | None = None,
context: Context | None = None,
) -> _TaskT_co: ...
def create_eager_task_factory(
custom_task_constructor: _CustomTaskConstructor[_TaskT_co],
) -> _EagerTaskFactoryType[_TaskT_co]: ...
@@ -1,9 +0,0 @@
from collections.abc import Callable
from typing import ParamSpec, TypeVar
# Keep asyncio.__all__ updated with any changes to __all__ here
__all__ = ("to_thread",)
_P = ParamSpec("_P")
_R = TypeVar("_R")
async def to_thread(func: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ...
@@ -1,20 +0,0 @@
from types import TracebackType
from typing import final
from typing_extensions import Self
# Keep asyncio.__all__ updated with any changes to __all__ here
__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: ...
@@ -1,51 +0,0 @@
import sys
from collections.abc import Iterable
from enum import Enum
from typing import NamedTuple, SupportsIndex, type_check_only
@type_check_only
class _AwaitedInfo(NamedTuple): # AwaitedInfo_Type from _remote_debugging
thread_id: int
awaited_by: list[_TaskInfo]
@type_check_only
class _TaskInfo(NamedTuple): # TaskInfo_Type from _remote_debugging
task_id: int
task_name: str
coroutine_stack: list[_CoroInfo]
awaited_by: list[_CoroInfo]
@type_check_only
class _CoroInfo(NamedTuple): # CoroInfo_Type from _remote_debugging
call_stack: list[_FrameInfo]
task_name: int | str
@type_check_only
class _FrameInfo(NamedTuple): # FrameInfo_Type from _remote_debugging
filename: str
lineno: int
funcname: str
class NodeType(Enum):
COROUTINE = 1
TASK = 2
class CycleFoundException(Exception):
cycles: list[list[int]]
id2name: dict[int, str]
def __init__(self, cycles: list[list[int]], id2name: dict[int, str]) -> None: ...
def get_all_awaited_by(pid: SupportsIndex) -> list[_AwaitedInfo]: ...
def build_async_tree(result: Iterable[_AwaitedInfo], task_emoji: str = "(T)", cor_emoji: str = "") -> list[list[str]]: ...
def build_task_table(result: Iterable[_AwaitedInfo]) -> list[list[int | str]]: ...
if sys.version_info >= (3, 14):
def exit_with_permission_help_text() -> None: ...
if sys.version_info >= (3, 15):
def display_awaited_by_tasks_table(pid: SupportsIndex, retries: SupportsIndex = 3) -> None: ...
def display_awaited_by_tasks_tree(pid: SupportsIndex, retries: SupportsIndex = 3) -> None: ...
else:
def display_awaited_by_tasks_table(pid: SupportsIndex) -> None: ...
def display_awaited_by_tasks_tree(pid: SupportsIndex) -> None: ...
@@ -1,57 +0,0 @@
from asyncio.events import AbstractEventLoop
from asyncio.protocols import BaseProtocol
from collections.abc import Iterable, Mapping
from socket import _Address
from typing import Any
# Keep asyncio.__all__ updated with any changes to __all__ here
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")
class BaseTransport:
__slots__ = ("_extra",)
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):
__slots__ = ()
def is_reading(self) -> bool: ...
def pause_reading(self) -> None: ...
def resume_reading(self) -> None: ...
class WriteTransport(BaseTransport):
__slots__ = ()
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[Any]) -> None: ... # any memoryview format or shape
def writelines(
self, list_of_data: Iterable[bytes | bytearray | memoryview[Any]]
) -> None: ... # any memoryview format or shape
def write_eof(self) -> None: ...
def can_write_eof(self) -> bool: ...
def abort(self) -> None: ...
class Transport(ReadTransport, WriteTransport):
__slots__ = ()
class DatagramTransport(BaseTransport):
__slots__ = ()
def sendto(self, data: bytes | bytearray | memoryview, addr: _Address | None = None) -> None: ...
def abort(self) -> None: ...
class SubprocessTransport(BaseTransport):
__slots__ = ()
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):
__slots__ = ("_loop", "_protocol_paused", "_high_water", "_low_water")
def __init__(self, extra: Mapping[str, Any] | None = None, loop: AbstractEventLoop | None = None) -> None: ...
@@ -1,137 +0,0 @@
import socket
import sys
from _typeshed import ReadableBuffer
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, TypeAlias, overload
from typing_extensions import deprecated
# 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:
__slots__ = ("_sock",)
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: ...
@deprecated("Removed in Python 3.11")
def accept(self) -> tuple[socket.socket, _RetAddress]: ...
@deprecated("Removed in Python 3.11")
def connect(self, address: _Address) -> None: ...
@deprecated("Removed in Python 3.11")
def connect_ex(self, address: _Address) -> int: ...
@deprecated("Removed in Python 3.11")
def bind(self, address: _Address) -> None: ...
if sys.platform == "win32":
@deprecated("Removed in Python 3.11")
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ...
else:
@deprecated("Removed in Python 3.11")
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ...
@deprecated("Removed in Python 3.11")
def listen(self, backlog: int = ..., /) -> None: ...
@deprecated("Removed in Python 3.11")
def makefile(self) -> BinaryIO: ...
@deprecated("Removed in Python 3.11")
def sendfile(self, file: BinaryIO, offset: int = 0, count: int | None = None) -> int: ...
@deprecated("Removed in Python 3.11")
def close(self) -> None: ...
@deprecated("Removed in Python 3.11")
def detach(self) -> int: ...
if sys.platform == "linux":
@deprecated("Removed in Python 3.11")
def sendmsg_afalg(
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = 0
) -> int: ...
else:
@deprecated("Removed in Python 3.11.")
def sendmsg_afalg(
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = 0
) -> NoReturn: ...
@deprecated("Removed in Python 3.11.")
def sendmsg(
self,
buffers: Iterable[ReadableBuffer],
ancdata: Iterable[_CMSG] = ...,
flags: int = 0,
address: _Address | None = None,
/,
) -> int: ...
@overload
@deprecated("Removed in Python 3.11.")
def sendto(self, data: ReadableBuffer, address: _Address) -> int: ...
@overload
@deprecated("Removed in Python 3.11.")
def sendto(self, data: ReadableBuffer, flags: int, address: _Address) -> int: ...
@deprecated("Removed in Python 3.11.")
def send(self, data: ReadableBuffer, flags: int = 0) -> int: ...
@deprecated("Removed in Python 3.11.")
def sendall(self, data: ReadableBuffer, flags: int = 0) -> None: ...
@deprecated("Removed in Python 3.11.")
def set_inheritable(self, inheritable: bool) -> None: ...
if sys.platform == "win32":
@deprecated("Removed in Python 3.11.")
def share(self, process_id: int) -> bytes: ...
else:
@deprecated("Removed in Python 3.11.")
def share(self, process_id: int) -> NoReturn: ...
@deprecated("Removed in Python 3.11.")
def recv_into(self, buffer: _WriteBuffer, nbytes: int = 0, flags: int = 0) -> int: ...
@deprecated("Removed in Python 3.11.")
def recvfrom_into(self, buffer: _WriteBuffer, nbytes: int = 0, flags: int = 0) -> tuple[int, _RetAddress]: ...
@deprecated("Removed in Python 3.11.")
def recvmsg_into(
self, buffers: Iterable[_WriteBuffer], ancbufsize: int = 0, flags: int = 0, /
) -> tuple[int, list[_CMSG], int, Any]: ...
@deprecated("Removed in Python 3.11.")
def recvmsg(self, bufsize: int, ancbufsize: int = 0, flags: int = 0, /) -> tuple[bytes, list[_CMSG], int, Any]: ...
@deprecated("Removed in Python 3.11.")
def recvfrom(self, bufsize: int, flags: int = 0) -> tuple[bytes, _RetAddress]: ...
@deprecated("Removed in Python 3.11.")
def recv(self, bufsize: int, flags: int = 0) -> bytes: ...
@deprecated("Removed in Python 3.11.")
def __enter__(self) -> socket.socket: ...
@deprecated("Removed in Python 3.11.")
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
Loaded 100 of 716 files, more files were not shown because too many files have changed in this diff. Show more