diff --git a/docs/mypy-comparison.md b/docs/mypy-comparison.md index d42cdf94b5..9e11f209bc 100644 --- a/docs/mypy-comparison.md +++ b/docs/mypy-comparison.md @@ -9,7 +9,9 @@ Mypy is the “OG” in the world of Python type checkers. It was started by Juk Mypy served as a reference implementation of [PEP 484](https://www.python.org/dev/peps/pep-0484/), which defines standard behaviors for Python static typing. Although PEP 484 spells out many type checking behaviors, it intentionally leaves many other behaviors undefined. This approach has allowed different type checkers to innovate and differentiate. -Pyright generally adheres to the type checking behaviors spelled out in PEP 484 and follow-on typing PEPs (526, 544, 586, 589, etc.). For behaviors that are not explicitly spelled out in these standards, pyright generally tries to adhere to mypy’s behavior unless there is a compelling justification for deviating. This document discusses these differences and provides the reasoning behind each design choice. +Pyright generally adheres to the official [Python typing specification](https://typing.readthedocs.io/en/latest/spec/index.html), which incorporates and builds upon PEP 484 and other typing-related PEPs. The typing spec is accompanied by an ever-expanding suite of conformance tests. For the latest conformance test results for pyright, mypy and other type checkers, refer to [this page](https://htmlpreview.github.io/?https://github.com/python/typing/blob/main/conformance/results/results.html). + +For behaviors that are not explicitly spelled out in the typing spec, pyright generally tries to adhere to mypy’s behavior unless there is a compelling justification for deviating. This document discusses these differences and provides the reasoning behind each design choice. ### Design Goals @@ -18,9 +20,9 @@ Pyright was designed with performance in mind. It is not unusual for pyright to Pyright was also designed to be used as the foundation for a Python [language server](https://microsoft.github.io/language-server-protocol/). Language servers provide interactive programming features such as completion suggestions, function signature help, type information on hover, semantic-aware search, semantic-aware renaming, semantic token coloring, refactoring tools, etc. For a good user experience, these features require highly responsive type evaluation performance during interactive code modification. They also require type evaluation to work on code that is incomplete and contains syntax errors. -To achieve these design goals, pyright is implemented as a “lazy” or “just-in-time” type evaluator. Rather than analyzing all code in a module from top to bottom, it is able to evaluate the type of an arbitrary identifier anywhere within a module. If the type of that identifier depends on the types of other expressions or symbols, pyright recursively evaluates those in turn until it has enough information to determine the type of the requested identifier. By comparison, mypy uses a more traditional multi-pass architecture where semantic analysis is performed multiple times on a module from the top to the bottom until all types converge. +To achieve these design goals, pyright is implemented as a “lazy” or “just-in-time” type evaluator. Rather than analyzing all code in a module from top to bottom, it is able to evaluate the type of an arbitrary identifier anywhere within a module. If the type of that identifier depends on the types of other expressions or symbols, pyright recursively evaluates those in turn until it has enough information to determine the type of the target identifier. By comparison, mypy uses a more traditional multi-pass architecture where semantic analysis is performed multiple times on a module from the top to the bottom until all types converge. -Pyright implements its own parser, which recovers gracefully from syntax errors and continues parsing the remainder of the source file. By comparison, mypy uses the parser built in to the Python interpreter, and it does not support recovery after a syntax error. +Pyright implements its own parser, which recovers gracefully from syntax errors and continues parsing the remainder of the source file. By comparison, mypy uses the parser built in to the Python interpreter, and it does not support recovery after a syntax error. This also means that when you run mypy on an older version of Python, it cannot support newer language features that require grammar changes. ### Type Checking Unannotated Code @@ -29,8 +31,6 @@ By default, pyright performs type checking for all code regardless of whether it By default, mypy skips all functions or methods that do not have type annotations. This is a common source of confusion for mypy users who are surprised when type violations in unannotated functions go unreported. If the option `--check-untyped-defs` is enabled, mypy performs type checking for all functions and methods. -Mypy supports the `typing.no_type_check` decorator. This decorator does not make sense for language servers, so it is ignored by pyright. - ### Inferred Return Types @@ -220,7 +220,7 @@ x = 'a' reveal_type(x) # pyright: Literal['a'], mypy: str ``` -Pyright also supports “literal math” for simple operations between literals. +Pyright also supports “literal math” for simple operations involving literals. ```python def func1(a: Literal[1, 2], b: Literal[2, 3]): diff --git a/lerna.json b/lerna.json index 8992b7461d..10e3f652f6 100644 --- a/lerna.json +++ b/lerna.json @@ -2,7 +2,7 @@ "packages": [ "packages/*" ], - "version": "1.1.376", + "version": "1.1.377", "command": { "version": { "push": false, diff --git a/packages/pyright-internal/package-lock.json b/packages/pyright-internal/package-lock.json index 6cf94a636e..00ec8a0161 100644 --- a/packages/pyright-internal/package-lock.json +++ b/packages/pyright-internal/package-lock.json @@ -1,12 +1,12 @@ { "name": "pyright-internal", - "version": "1.1.376", + "version": "1.1.377", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pyright-internal", - "version": "1.1.376", + "version": "1.1.377", "license": "MIT", "dependencies": { "@actions/core": "^1.10.1", diff --git a/packages/pyright-internal/package.json b/packages/pyright-internal/package.json index 4833c414b9..f6b778cd2b 100644 --- a/packages/pyright-internal/package.json +++ b/packages/pyright-internal/package.json @@ -2,7 +2,7 @@ "name": "pyright-internal", "displayName": "pyright", "description": "Type checker for the Python language", - "version": "1.1.376", + "version": "1.1.377", "license": "MIT", "private": true, "files": [ diff --git a/packages/pyright-internal/src/analyzer/analyzerFileInfo.ts b/packages/pyright-internal/src/analyzer/analyzerFileInfo.ts index 5b8455471d..35ad360768 100644 --- a/packages/pyright-internal/src/analyzer/analyzerFileInfo.ts +++ b/packages/pyright-internal/src/analyzer/analyzerFileInfo.ts @@ -10,7 +10,7 @@ import { DiagnosticRuleSet, ExecutionEnvironment } from '../common/configOptions'; import { TextRangeDiagnosticSink } from '../common/diagnosticSink'; -import { pythonVersion3_14 } from '../common/pythonVersion'; +import { PythonVersion, pythonVersion3_14 } from '../common/pythonVersion'; import { TextRange } from '../common/textRange'; import { TextRangeCollection } from '../common/textRangeCollection'; import { Uri } from '../common/uri/uri'; @@ -79,7 +79,7 @@ export function isAnnotationEvaluationPostponed(fileInfo: AnalyzerFileInfo) { // release to reduce the risk. As of May 8, 2024, the change did not make it into // Python 3.13beta1, so it has been deferred to Python 3.14. // https://discuss.python.org/t/pep-649-deferred-evaluation-of-annotations-tentatively-accepted/21331 - if (fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(pythonVersion3_14)) { + if (PythonVersion.isGreaterOrEqualTo(fileInfo.executionEnvironment.pythonVersion, pythonVersion3_14)) { return true; } diff --git a/packages/pyright-internal/src/analyzer/checker.ts b/packages/pyright-internal/src/analyzer/checker.ts index c4b70e8ce8..f6e05aabfd 100644 --- a/packages/pyright-internal/src/analyzer/checker.ts +++ b/packages/pyright-internal/src/analyzer/checker.ts @@ -19,7 +19,7 @@ import { appendArray } from '../common/collectionUtils'; import { assert, assertNever } from '../common/debug'; import { ActionKind, Diagnostic, DiagnosticAddendum, RenameShadowedFileAction } from '../common/diagnostic'; import { DiagnosticRule } from '../common/diagnosticRules'; -import { pythonVersion3_12, pythonVersion3_5, pythonVersion3_6 } from '../common/pythonVersion'; +import { PythonVersion, pythonVersion3_12, pythonVersion3_5, pythonVersion3_6 } from '../common/pythonVersion'; import { TextRange } from '../common/textRange'; import { Uri } from '../common/uri/uri'; import { DefinitionProvider } from '../languageService/definitionProvider'; @@ -638,7 +638,7 @@ export class Checker extends ParseTreeWalker { if ( this._fileInfo.diagnosticRuleSet.reportTypeCommentUsage !== 'none' && - this._fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(pythonVersion3_5) + PythonVersion.isGreaterOrEqualTo(this._fileInfo.executionEnvironment.pythonVersion, pythonVersion3_5) ) { this._evaluator.addDiagnostic( DiagnosticRule.reportTypeCommentUsage, @@ -1208,7 +1208,7 @@ export class Checker extends ParseTreeWalker { if ( this._fileInfo.diagnosticRuleSet.reportTypeCommentUsage !== 'none' && - this._fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(pythonVersion3_6) + PythonVersion.isGreaterOrEqualTo(this._fileInfo.executionEnvironment.pythonVersion, pythonVersion3_6) ) { this._evaluator.addDiagnostic( DiagnosticRule.reportTypeCommentUsage, @@ -1385,7 +1385,7 @@ export class Checker extends ParseTreeWalker { // associated with f-strings that we need to validate. Determine whether // we're within an f-string (or multiple f-strings if nesting is used). const fStringContainers: FormatStringNode[] = []; - if (this._fileInfo.executionEnvironment.pythonVersion.isLessThan(pythonVersion3_12)) { + if (PythonVersion.isLessThan(this._fileInfo.executionEnvironment.pythonVersion, pythonVersion3_12)) { let curNode: ParseNode | undefined = node; while (curNode) { if (curNode.nodeType === ParseNodeType.FormatString) { @@ -4406,12 +4406,17 @@ export class Checker extends ParseTreeWalker { (isInstantiableClass(type) && type.shared.fullName === deprecatedForm.fullName) || type.props?.typeAliasInfo?.fullName === deprecatedForm.fullName ) { - if (this._fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(deprecatedForm.version)) { + if ( + PythonVersion.isGreaterOrEqualTo( + this._fileInfo.executionEnvironment.pythonVersion, + deprecatedForm.version + ) + ) { if (!deprecatedForm.typingImportOnly || isImportFromTyping) { this._evaluator.addDiagnostic( DiagnosticRule.reportDeprecated, LocMessage.deprecatedType().format({ - version: deprecatedForm.version.toString(), + version: PythonVersion.toString(deprecatedForm.version), replacement: deprecatedForm.replacementText, }), node diff --git a/packages/pyright-internal/src/analyzer/codeFlowEngine.ts b/packages/pyright-internal/src/analyzer/codeFlowEngine.ts index d5b0dc42a8..58a8b246b3 100644 --- a/packages/pyright-internal/src/analyzer/codeFlowEngine.ts +++ b/packages/pyright-internal/src/analyzer/codeFlowEngine.ts @@ -1299,7 +1299,6 @@ export function getCodeFlowEngine( (FlowFlags.VariableAnnotation | FlowFlags.Assignment | FlowFlags.WildcardImport | - FlowFlags.NarrowForPattern | FlowFlags.ExhaustedMatch) ) { const typedFlowNode = curFlowNode as @@ -1311,6 +1310,25 @@ export function getCodeFlowEngine( continue; } + if (curFlowNode.flags & FlowFlags.NarrowForPattern) { + const patternFlowNode = curFlowNode as FlowNarrowForPattern; + + const typeResult = evaluator.evaluateTypeForSubnode(patternFlowNode.statement, () => { + if (patternFlowNode.statement.nodeType === ParseNodeType.Case) { + evaluator.evaluateTypesForCaseStatement(patternFlowNode.statement); + } else { + evaluator.evaluateTypesForMatchStatement(patternFlowNode.statement); + } + }); + + if (typeResult && isNever(typeResult.type)) { + return cacheReachabilityResult(Reachability.UnreachableByAnalysis); + } + + curFlowNode = patternFlowNode.antecedent; + continue; + } + if ( curFlowNode.flags & (FlowFlags.TrueCondition | diff --git a/packages/pyright-internal/src/analyzer/dataClasses.ts b/packages/pyright-internal/src/analyzer/dataClasses.ts index 8620e1fa62..238a979601 100644 --- a/packages/pyright-internal/src/analyzer/dataClasses.ts +++ b/packages/pyright-internal/src/analyzer/dataClasses.ts @@ -11,7 +11,7 @@ import { assert } from '../common/debug'; import { DiagnosticAddendum } from '../common/diagnostic'; import { DiagnosticRule } from '../common/diagnosticRules'; -import { pythonVersion3_13 } from '../common/pythonVersion'; +import { PythonVersion, pythonVersion3_13 } from '../common/pythonVersion'; import { LocMessage } from '../localization/localize'; import { ArgCategory, @@ -122,7 +122,12 @@ export function synthesizeDataClassMethods( // For Python 3.13 and newer, synthesize a __replace__ method. let replaceType: FunctionType | undefined; - if (AnalyzerNodeInfo.getFileInfo(node).executionEnvironment.pythonVersion >= pythonVersion3_13) { + if ( + PythonVersion.isGreaterOrEqualTo( + AnalyzerNodeInfo.getFileInfo(node).executionEnvironment.pythonVersion, + pythonVersion3_13 + ) + ) { replaceType = FunctionType.createSynthesizedInstance('__replace__'); FunctionType.addParam(replaceType, selfParam); FunctionType.addKeywordOnlyParamSeparator(replaceType); @@ -208,6 +213,7 @@ export function synthesizeDataClassMethods( let variableTypeEvaluator: EntryTypeEvaluator | undefined; let hasDefaultValue = false; let isKeywordOnly = ClassType.isDataClassKeywordOnly(classType) || sawKeywordOnlySeparator; + let defaultExpr: ExpressionNode | undefined; let includeInInit = true; let converter: ArgumentNode | undefined; @@ -230,6 +236,7 @@ export function synthesizeDataClassMethods( } hasDefaultValue = true; + defaultExpr = statement.d.rightExpr; // If the RHS of the assignment is assigning a field instance where the // "init" parameter is set to false, do not include it in the init method. @@ -293,6 +300,9 @@ export function synthesizeDataClassMethods( ); hasDefaultValue = !!defaultArg; + if (defaultArg?.d.valueExpr) { + defaultExpr = defaultArg.d.valueExpr; + } const aliasArg = statement.d.rightExpr.d.args.find((arg) => arg.d.name?.d.value === 'alias'); if (aliasArg) { @@ -360,6 +370,7 @@ export function synthesizeDataClassMethods( alias: aliasName, isKeywordOnly: false, hasDefault: hasDefaultValue, + defaultExpr, includeInInit, nameNode: variableNameNode, type: UnknownType.create(), @@ -377,6 +388,7 @@ export function synthesizeDataClassMethods( alias: aliasName, isKeywordOnly, hasDefault: hasDefaultValue, + defaultExpr, includeInInit, nameNode: variableNameNode, type: UnknownType.create(), @@ -402,6 +414,7 @@ export function synthesizeDataClassMethods( // causes overridden variables to "inherit" default values from parent classes. if (!dataClassEntry.hasDefault && oldEntry.hasDefault && oldEntry.includeInInit) { dataClassEntry.hasDefault = true; + dataClassEntry.defaultExpr = oldEntry.defaultExpr; hasDefaultValue = true; // Warn the user of this case because it can result in type errors if the @@ -541,7 +554,8 @@ export function synthesizeDataClassMethods( effectiveType, FunctionParamFlags.TypeDeclared, effectiveName, - entry.hasDefault ? entry.type : undefined + entry.hasDefault ? entry.type : undefined, + entry.defaultExpr ); if (entry.isKeywordOnly) { diff --git a/packages/pyright-internal/src/analyzer/enums.ts b/packages/pyright-internal/src/analyzer/enums.ts index 3c5bc81c9b..683e2990a0 100644 --- a/packages/pyright-internal/src/analyzer/enums.ts +++ b/packages/pyright-internal/src/analyzer/enums.ts @@ -8,7 +8,7 @@ */ import { assert } from '../common/debug'; -import { pythonVersion3_13 } from '../common/pythonVersion'; +import { PythonVersion, pythonVersion3_13 } from '../common/pythonVersion'; import { ArgCategory, ExpressionNode, NameNode, ParseNode, ParseNodeType } from '../parser/parseNodes'; import { getFileInfo } from './analyzerNodeInfo'; import { VariableDeclaration } from './declaration'; @@ -413,7 +413,10 @@ export function transformTypeForEnumMember( // are treated as members. if (isInstantiableClass(assignedType)) { const fileInfo = getFileInfo(primaryDecl.node); - isMemberOfEnumeration = fileInfo.executionEnvironment.pythonVersion.isLessThan(pythonVersion3_13); + isMemberOfEnumeration = PythonVersion.isLessThan( + fileInfo.executionEnvironment.pythonVersion, + pythonVersion3_13 + ); } } } diff --git a/packages/pyright-internal/src/analyzer/importResolver.ts b/packages/pyright-internal/src/analyzer/importResolver.ts index 9e3f0bc580..b05b1bc2a5 100644 --- a/packages/pyright-internal/src/analyzer/importResolver.ts +++ b/packages/pyright-internal/src/analyzer/importResolver.ts @@ -472,7 +472,7 @@ export class ImportResolver { this._cachedTypeshedStdLibModuleVersionInfo.forEach((versionInfo, moduleName) => { let shouldExcludeModule = false; - if (versionInfo.max !== undefined && pythonVersion.isGreaterThan(versionInfo.max)) { + if (versionInfo.max !== undefined && PythonVersion.isGreaterThan(pythonVersion, versionInfo.max)) { shouldExcludeModule = true; } @@ -2008,11 +2008,11 @@ export class ImportResolver { const versionInfo = this._cachedTypeshedStdLibModuleVersionInfo.get(namePartsToConsider.join('.')); if (versionInfo) { - if (pythonVersion.isLessThan(versionInfo.min)) { + if (PythonVersion.isLessThan(pythonVersion, versionInfo.min)) { return false; } - if (versionInfo.max !== undefined && pythonVersion.isGreaterThan(versionInfo.max)) { + if (versionInfo.max !== undefined && PythonVersion.isGreaterThan(pythonVersion, versionInfo.max)) { return false; } diff --git a/packages/pyright-internal/src/analyzer/operations.ts b/packages/pyright-internal/src/analyzer/operations.ts index 9e3d4384ab..78417ae875 100644 --- a/packages/pyright-internal/src/analyzer/operations.ts +++ b/packages/pyright-internal/src/analyzer/operations.ts @@ -10,7 +10,7 @@ import { DiagnosticAddendum } from '../common/diagnostic'; import { DiagnosticRule } from '../common/diagnosticRules'; -import { pythonVersion3_10 } from '../common/pythonVersion'; +import { PythonVersion, pythonVersion3_10 } from '../common/pythonVersion'; import { LocMessage } from '../localization/localize'; import { AugmentedAssignmentNode, @@ -170,62 +170,23 @@ export function validateBinaryOperation( // The "in" and "not in" operators make use of the __contains__ // magic method. if (operator === OperatorType.In || operator === OperatorType.NotIn) { - type = evaluator.mapSubtypesExpandTypeVars( - rightType, - /* options */ undefined, - (rightSubtypeExpanded, rightSubtypeUnexpanded) => { - return evaluator.mapSubtypesExpandTypeVars( - concreteLeftType, - { conditionFilter: getTypeCondition(rightSubtypeExpanded) }, - (leftSubtype) => { - if (isAnyOrUnknown(leftSubtype) || isAnyOrUnknown(rightSubtypeUnexpanded)) { - return preserveUnknown(leftSubtype, rightSubtypeExpanded); - } - - let returnTypeResult = evaluator.getTypeOfMagicMethodCall( - rightSubtypeExpanded, - '__contains__', - [{ type: leftSubtype, isIncomplete: leftTypeResult.isIncomplete }], - errorNode, - /* inferenceContext */ undefined - ); - - if (!returnTypeResult) { - // If __contains__ was not supported, fall back - // on an iterable. - const iteratorType = evaluator.getTypeOfIterator( - { type: rightSubtypeExpanded, isIncomplete: rightTypeResult.isIncomplete }, - /* isAsync */ false, - errorNode, - /* emitNotIterableError */ false - )?.type; - - if (iteratorType && evaluator.assignType(iteratorType, leftSubtype)) { - returnTypeResult = { type: evaluator.getBuiltInObject(errorNode, 'bool') }; - } - } + const result = validateContainmentOperation( + evaluator, + operator, + leftTypeResult, + concreteLeftType, + rightTypeResult, + errorNode, + diag + ); - if (!returnTypeResult) { - diag.addMessage( - LocMessage.typeNotSupportBinaryOperator().format({ - operator: printOperator(operator), - leftType: evaluator.printType(leftSubtype), - rightType: evaluator.printType(rightSubtypeExpanded), - }) - ); - } + if (result.magicMethodDeprecationInfo) { + deprecatedInfo = result.magicMethodDeprecationInfo; + } - if (returnTypeResult?.magicMethodDeprecationInfo) { - deprecatedInfo = returnTypeResult.magicMethodDeprecationInfo; - } + type = result.type; - return returnTypeResult?.type; - } - ); - } - ); - - // Assume that a bool is returned even if the type is unknown + // Assume that a bool is returned even if the type is unknown. if (type && !isNever(type)) { type = evaluator.getBuiltInObject(errorNode, 'bool'); } @@ -262,151 +223,22 @@ export function validateBinaryOperation( } if (!type) { - type = evaluator.mapSubtypesExpandTypeVars( - leftType, - /* options */ undefined, - (leftSubtypeExpanded, leftSubtypeUnexpanded) => { - return evaluator.mapSubtypesExpandTypeVars( - rightType, - { conditionFilter: getTypeCondition(leftSubtypeExpanded) }, - (rightSubtypeExpanded, rightSubtypeUnexpanded) => { - if (isAnyOrUnknown(leftSubtypeUnexpanded) || isAnyOrUnknown(rightSubtypeUnexpanded)) { - return preserveUnknown(leftSubtypeUnexpanded, rightSubtypeUnexpanded); - } - - const tupleClassType = evaluator.getTupleClassType(); - - // Special-case __add__ for tuples when the types for both tuples are known. - if ( - options.isTupleAddAllowed && - operator === OperatorType.Add && - isClassInstance(leftSubtypeExpanded) && - isTupleClass(leftSubtypeExpanded) && - leftSubtypeExpanded.priv.tupleTypeArgs && - isClassInstance(rightSubtypeExpanded) && - isTupleClass(rightSubtypeExpanded) && - rightSubtypeExpanded.priv.tupleTypeArgs && - tupleClassType && - isInstantiableClass(tupleClassType) - ) { - // If at least one of the tuples is of fixed size, we can - // combine them into a precise new type. If both are unbounded - // (or contain an unbounded element), we cannot combine them - // in this manner because tuples can contain at most one - // unbounded element. - if ( - !isUnboundedTupleClass(leftSubtypeExpanded) || - !isUnboundedTupleClass(rightSubtypeExpanded) - ) { - return ClassType.cloneAsInstance( - specializeTupleClass(tupleClassType, [ - ...leftSubtypeExpanded.priv.tupleTypeArgs, - ...rightSubtypeExpanded.priv.tupleTypeArgs, - ]) - ); - } - } - - const magicMethodName = binaryOperatorMap[operator][0]; - let resultTypeResult = evaluator.getTypeOfMagicMethodCall( - convertFunctionToObject(evaluator, leftSubtypeUnexpanded), - magicMethodName, - [{ type: rightSubtypeUnexpanded, isIncomplete: rightTypeResult.isIncomplete }], - errorNode, - inferenceContext - ); - - if (!resultTypeResult && leftSubtypeUnexpanded !== leftSubtypeExpanded) { - // Try the expanded left type. - resultTypeResult = evaluator.getTypeOfMagicMethodCall( - convertFunctionToObject(evaluator, leftSubtypeExpanded), - magicMethodName, - [{ type: rightSubtypeUnexpanded, isIncomplete: rightTypeResult.isIncomplete }], - errorNode, - inferenceContext - ); - } - - if (!resultTypeResult && rightSubtypeUnexpanded !== rightSubtypeExpanded) { - // Try the expanded left and right type. - resultTypeResult = evaluator.getTypeOfMagicMethodCall( - convertFunctionToObject(evaluator, leftSubtypeExpanded), - magicMethodName, - [{ type: rightSubtypeExpanded, isIncomplete: rightTypeResult.isIncomplete }], - errorNode, - inferenceContext - ); - } - - if (!resultTypeResult) { - // Try the alternate form (swapping right and left). - const altMagicMethodName = binaryOperatorMap[operator][1]; - resultTypeResult = evaluator.getTypeOfMagicMethodCall( - convertFunctionToObject(evaluator, rightSubtypeUnexpanded), - altMagicMethodName, - [{ type: leftSubtypeUnexpanded, isIncomplete: leftTypeResult.isIncomplete }], - errorNode, - inferenceContext - ); - - if (!resultTypeResult && rightSubtypeUnexpanded !== rightSubtypeExpanded) { - // Try the expanded right type. - resultTypeResult = evaluator.getTypeOfMagicMethodCall( - convertFunctionToObject(evaluator, rightSubtypeExpanded), - altMagicMethodName, - [ - { - type: leftSubtypeUnexpanded, - isIncomplete: leftTypeResult.isIncomplete, - }, - ], - errorNode, - inferenceContext - ); - } - - if (!resultTypeResult && leftSubtypeUnexpanded !== leftSubtypeExpanded) { - // Try the expanded right and left type. - resultTypeResult = evaluator.getTypeOfMagicMethodCall( - convertFunctionToObject(evaluator, rightSubtypeExpanded), - altMagicMethodName, - [{ type: leftSubtypeExpanded, isIncomplete: leftTypeResult.isIncomplete }], - errorNode, - inferenceContext - ); - } - } - - if (!resultTypeResult) { - if (inferenceContext) { - diag.addMessage( - LocMessage.typeNotSupportBinaryOperatorBidirectional().format({ - operator: printOperator(operator), - leftType: evaluator.printType(leftSubtypeExpanded), - rightType: evaluator.printType(rightSubtypeExpanded), - expectedType: evaluator.printType(inferenceContext.expectedType), - }) - ); - } else { - diag.addMessage( - LocMessage.typeNotSupportBinaryOperator().format({ - operator: printOperator(operator), - leftType: evaluator.printType(leftSubtypeExpanded), - rightType: evaluator.printType(rightSubtypeExpanded), - }) - ); - } - } + const result = validateArithmeticOperation( + evaluator, + operator, + leftTypeResult, + rightTypeResult, + errorNode, + inferenceContext, + diag, + options + ); - if (resultTypeResult?.magicMethodDeprecationInfo) { - deprecatedInfo = resultTypeResult.magicMethodDeprecationInfo; - } + if (result.magicMethodDeprecationInfo) { + deprecatedInfo = result.magicMethodDeprecationInfo; + } - return resultTypeResult?.type ?? UnknownType.create(isIncomplete); - } - ); - } - ); + type = result.type; } } @@ -538,7 +370,7 @@ export function getTypeOfBinaryOperation( const unionNotationSupported = fileInfo.isStubFile || (flags & EvalFlags.ForwardRefs) !== 0 || - fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(pythonVersion3_10); + PythonVersion.isGreaterOrEqualTo(fileInfo.executionEnvironment.pythonVersion, pythonVersion3_10); if (!unionNotationSupported) { // If the left type is Any, we can't say for sure whether this @@ -1263,3 +1095,234 @@ function isExpressionLocalVariable(evaluator: TypeEvaluator, node: ExpressionNod const currentScope = getScopeForNode(node); return currentScope === symbolWithScope.scope; } + +function validateContainmentOperation( + evaluator: TypeEvaluator, + operator: OperatorType, + leftTypeResult: TypeResult, + concreteLeftType: Type, + rightTypeResult: TypeResult, + errorNode: ExpressionNode, + diag: DiagnosticAddendum +): TypeResult { + let deprecatedInfo: MagicMethodDeprecationInfo | undefined; + + const type = evaluator.mapSubtypesExpandTypeVars( + rightTypeResult.type, + /* options */ undefined, + (rightSubtypeExpanded, rightSubtypeUnexpanded) => { + return evaluator.mapSubtypesExpandTypeVars( + concreteLeftType, + { conditionFilter: getTypeCondition(rightSubtypeExpanded) }, + (leftSubtype) => { + if (isAnyOrUnknown(leftSubtype) || isAnyOrUnknown(rightSubtypeUnexpanded)) { + return preserveUnknown(leftSubtype, rightSubtypeExpanded); + } + + let returnTypeResult = evaluator.getTypeOfMagicMethodCall( + rightSubtypeExpanded, + '__contains__', + [{ type: leftSubtype, isIncomplete: leftTypeResult.isIncomplete }], + errorNode, + /* inferenceContext */ undefined + ); + + if (!returnTypeResult) { + // If __contains__ was not supported, fall back + // on an iterable. + const iteratorType = evaluator.getTypeOfIterator( + { type: rightSubtypeExpanded, isIncomplete: rightTypeResult.isIncomplete }, + /* isAsync */ false, + errorNode, + /* emitNotIterableError */ false + )?.type; + + if (iteratorType && evaluator.assignType(iteratorType, leftSubtype)) { + returnTypeResult = { type: evaluator.getBuiltInObject(errorNode, 'bool') }; + } + } + + if (!returnTypeResult) { + diag.addMessage( + LocMessage.typeNotSupportBinaryOperator().format({ + operator: printOperator(operator), + leftType: evaluator.printType(leftSubtype), + rightType: evaluator.printType(rightSubtypeExpanded), + }) + ); + } + + if (returnTypeResult?.magicMethodDeprecationInfo) { + deprecatedInfo = returnTypeResult.magicMethodDeprecationInfo; + } + + return returnTypeResult?.type; + } + ); + } + ); + + return { type, magicMethodDeprecationInfo: deprecatedInfo }; +} + +function validateArithmeticOperation( + evaluator: TypeEvaluator, + operator: OperatorType, + leftTypeResult: TypeResult, + rightTypeResult: TypeResult, + errorNode: ExpressionNode, + inferenceContext: InferenceContext | undefined, + diag: DiagnosticAddendum, + options: BinaryOperationOptions +): TypeResult { + let deprecatedInfo: MagicMethodDeprecationInfo | undefined; + const isIncomplete = !!leftTypeResult.isIncomplete || !!rightTypeResult.isIncomplete; + + const type = evaluator.mapSubtypesExpandTypeVars( + leftTypeResult.type, + /* options */ undefined, + (leftSubtypeExpanded, leftSubtypeUnexpanded) => { + return evaluator.mapSubtypesExpandTypeVars( + rightTypeResult.type, + { conditionFilter: getTypeCondition(leftSubtypeExpanded) }, + (rightSubtypeExpanded, rightSubtypeUnexpanded) => { + if (isAnyOrUnknown(leftSubtypeUnexpanded) || isAnyOrUnknown(rightSubtypeUnexpanded)) { + return preserveUnknown(leftSubtypeUnexpanded, rightSubtypeUnexpanded); + } + + const tupleClassType = evaluator.getTupleClassType(); + + // Special-case __add__ for tuples when the types for both tuples are known. + if ( + options.isTupleAddAllowed && + operator === OperatorType.Add && + isClassInstance(leftSubtypeExpanded) && + isTupleClass(leftSubtypeExpanded) && + leftSubtypeExpanded.priv.tupleTypeArgs && + isClassInstance(rightSubtypeExpanded) && + isTupleClass(rightSubtypeExpanded) && + rightSubtypeExpanded.priv.tupleTypeArgs && + tupleClassType && + isInstantiableClass(tupleClassType) + ) { + // If at least one of the tuples is of fixed size, we can + // combine them into a precise new type. If both are unbounded + // (or contain an unbounded element), we cannot combine them + // in this manner because tuples can contain at most one + // unbounded element. + if ( + !isUnboundedTupleClass(leftSubtypeExpanded) || + !isUnboundedTupleClass(rightSubtypeExpanded) + ) { + return ClassType.cloneAsInstance( + specializeTupleClass(tupleClassType, [ + ...leftSubtypeExpanded.priv.tupleTypeArgs, + ...rightSubtypeExpanded.priv.tupleTypeArgs, + ]) + ); + } + } + + const magicMethodName = binaryOperatorMap[operator][0]; + let resultTypeResult = evaluator.getTypeOfMagicMethodCall( + convertFunctionToObject(evaluator, leftSubtypeUnexpanded), + magicMethodName, + [{ type: rightSubtypeUnexpanded, isIncomplete: rightTypeResult.isIncomplete }], + errorNode, + inferenceContext + ); + + if (!resultTypeResult && leftSubtypeUnexpanded !== leftSubtypeExpanded) { + // Try the expanded left type. + resultTypeResult = evaluator.getTypeOfMagicMethodCall( + convertFunctionToObject(evaluator, leftSubtypeExpanded), + magicMethodName, + [{ type: rightSubtypeUnexpanded, isIncomplete: rightTypeResult.isIncomplete }], + errorNode, + inferenceContext + ); + } + + if (!resultTypeResult && rightSubtypeUnexpanded !== rightSubtypeExpanded) { + // Try the expanded left and right type. + resultTypeResult = evaluator.getTypeOfMagicMethodCall( + convertFunctionToObject(evaluator, leftSubtypeExpanded), + magicMethodName, + [{ type: rightSubtypeExpanded, isIncomplete: rightTypeResult.isIncomplete }], + errorNode, + inferenceContext + ); + } + + if (!resultTypeResult) { + // Try the alternate form (swapping right and left). + const altMagicMethodName = binaryOperatorMap[operator][1]; + resultTypeResult = evaluator.getTypeOfMagicMethodCall( + convertFunctionToObject(evaluator, rightSubtypeUnexpanded), + altMagicMethodName, + [{ type: leftSubtypeUnexpanded, isIncomplete: leftTypeResult.isIncomplete }], + errorNode, + inferenceContext + ); + + if (!resultTypeResult && rightSubtypeUnexpanded !== rightSubtypeExpanded) { + // Try the expanded right type. + resultTypeResult = evaluator.getTypeOfMagicMethodCall( + convertFunctionToObject(evaluator, rightSubtypeExpanded), + altMagicMethodName, + [ + { + type: leftSubtypeUnexpanded, + isIncomplete: leftTypeResult.isIncomplete, + }, + ], + errorNode, + inferenceContext + ); + } + + if (!resultTypeResult && leftSubtypeUnexpanded !== leftSubtypeExpanded) { + // Try the expanded right and left type. + resultTypeResult = evaluator.getTypeOfMagicMethodCall( + convertFunctionToObject(evaluator, rightSubtypeExpanded), + altMagicMethodName, + [{ type: leftSubtypeExpanded, isIncomplete: leftTypeResult.isIncomplete }], + errorNode, + inferenceContext + ); + } + } + + if (!resultTypeResult) { + if (inferenceContext) { + diag.addMessage( + LocMessage.typeNotSupportBinaryOperatorBidirectional().format({ + operator: printOperator(operator), + leftType: evaluator.printType(leftSubtypeExpanded), + rightType: evaluator.printType(rightSubtypeExpanded), + expectedType: evaluator.printType(inferenceContext.expectedType), + }) + ); + } else { + diag.addMessage( + LocMessage.typeNotSupportBinaryOperator().format({ + operator: printOperator(operator), + leftType: evaluator.printType(leftSubtypeExpanded), + rightType: evaluator.printType(rightSubtypeExpanded), + }) + ); + } + } + + if (resultTypeResult?.magicMethodDeprecationInfo) { + deprecatedInfo = resultTypeResult.magicMethodDeprecationInfo; + } + + return resultTypeResult?.type ?? UnknownType.create(isIncomplete); + } + ); + } + ); + + return { type, magicMethodDeprecationInfo: deprecatedInfo }; +} diff --git a/packages/pyright-internal/src/analyzer/pythonPathUtils.ts b/packages/pyright-internal/src/analyzer/pythonPathUtils.ts index bbbf6e6e3f..65871da8bc 100644 --- a/packages/pyright-internal/src/analyzer/pythonPathUtils.ts +++ b/packages/pyright-internal/src/analyzer/pythonPathUtils.ts @@ -156,7 +156,7 @@ function findSitePackagesPath( // version), prefer that over other python directories. if (pythonVersion) { const preferredDir = candidateDirs.find( - (dirName) => dirName.fileName === `python${pythonVersion.toMajorMinorString()}` + (dirName) => dirName.fileName === `python${PythonVersion.toMajorMinorString(pythonVersion)}` ); if (preferredDir) { const dirPath = preferredDir.combinePaths(pathConsts.sitePackages); diff --git a/packages/pyright-internal/src/analyzer/staticExpressions.ts b/packages/pyright-internal/src/analyzer/staticExpressions.ts index b275418205..7f5edf237e 100644 --- a/packages/pyright-internal/src/analyzer/staticExpressions.ts +++ b/packages/pyright-internal/src/analyzer/staticExpressions.ts @@ -100,8 +100,8 @@ export function evaluateStaticBoolExpression( // Handle the special case of "sys.version_info[0] >= X" return _evaluateVersionBinaryOperation( node.d.operator, - new PythonVersion(execEnv.pythonVersion.major, 0), - new PythonVersion(node.d.rightExpr.d.value, 0) + PythonVersion.create(execEnv.pythonVersion.major, 0), + PythonVersion.create(node.d.rightExpr.d.value, 0) ); } @@ -238,12 +238,12 @@ function _convertTupleToVersion(node: TupleNode): PythonVersion | undefined { serial = node.d.items[4].d.value; } - return new PythonVersion(major, minor, micro, releaseLevel, serial); + return PythonVersion.create(major, minor, micro, releaseLevel, serial); } } else if (node.d.items.length === 1) { const major = node.d.items[0] as NumberNode; if (typeof major.d.value === 'number') { - return new PythonVersion(major.d.value, 0); + return PythonVersion.create(major.d.value, 0); } } @@ -257,27 +257,27 @@ function _evaluateVersionBinaryOperation( ): any | undefined { if (leftValue !== undefined && rightValue !== undefined) { if (operatorType === OperatorType.LessThan) { - return leftValue.isLessThan(rightValue); + return PythonVersion.isLessThan(leftValue, rightValue); } if (operatorType === OperatorType.LessThanOrEqual) { - return leftValue.isLessOrEqualTo(rightValue); + return PythonVersion.isLessOrEqualTo(leftValue, rightValue); } if (operatorType === OperatorType.GreaterThan) { - return leftValue.isGreaterThan(rightValue); + return PythonVersion.isGreaterThan(leftValue, rightValue); } if (operatorType === OperatorType.GreaterThanOrEqual) { - return leftValue.isGreaterOrEqualTo(rightValue); + return PythonVersion.isGreaterOrEqualTo(leftValue, rightValue); } if (operatorType === OperatorType.Equals) { - return leftValue.isEqualTo(rightValue); + return PythonVersion.isEqualTo(leftValue, rightValue); } if (operatorType === OperatorType.NotEquals) { - return !leftValue.isEqualTo(rightValue); + return !PythonVersion.isEqualTo(leftValue, rightValue); } } diff --git a/packages/pyright-internal/src/analyzer/typeEvaluator.ts b/packages/pyright-internal/src/analyzer/typeEvaluator.ts index cd6d33003e..fd35a80002 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluator.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluator.ts @@ -85,7 +85,7 @@ import { YieldNode, isExpressionNode, } from '../parser/parseNodes'; -import { ParseOptions, Parser } from '../parser/parser'; +import { ParseOptions, ParseTextMode, Parser } from '../parser/parser'; import { KeywordType, OperatorType, StringTokenFlags } from '../parser/tokenizerTypes'; import { AnalyzerFileInfo, ImportLookup, isAnnotationEvaluationPostponed } from './analyzerFileInfo'; import * as AnalyzerNodeInfo from './analyzerNodeInfo'; @@ -388,6 +388,7 @@ interface ScopedTypeVarResult { interface AliasMapEntry { alias: string; module: 'builtins' | 'collections' | 'contextlib' | 'self'; + implicitBaseClass?: string; isSpecialForm?: boolean; isIllegalInIsinstance?: boolean; typeParamVariance?: Variance; @@ -1184,15 +1185,13 @@ export function createTypeEvaluator( } case ParseNodeType.StringList: { - const isExpectingType = (flags & EvalFlags.StrLiteralAsType) !== 0 && !isAnnotationLiteralValue(node); - - if (isExpectingType) { + if ((flags & EvalFlags.StrLiteralAsType) !== 0) { // Don't report expecting type errors again. We will have already // reported them when analyzing the contents of the string. expectingInstantiable = false; } - typeResult = getTypeOfStringList(node, flags, isExpectingType); + typeResult = getTypeOfStringList(node, flags); break; } @@ -1528,10 +1527,10 @@ export function createTypeEvaluator( return typeResult; } - function getTypeOfStringList(node: StringListNode, flags: EvalFlags, isExpectingType: boolean) { + function getTypeOfStringList(node: StringListNode, flags: EvalFlags) { let typeResult: TypeResult | undefined; - if (isExpectingType) { + if ((flags & EvalFlags.StrLiteralAsType) !== 0) { let updatedFlags = flags | EvalFlags.ForwardRefs | EvalFlags.InstantiableType; // In most cases, annotations within a string are not parsed by the interpreter. @@ -1542,7 +1541,7 @@ export function createTypeEvaluator( if (node.d.annotation) { typeResult = getTypeOfExpression(node.d.annotation, updatedFlags); - } else if (!node.d.annotation && node.d.strings.length === 1) { + } else if (node.d.strings.length === 1) { const tokenFlags = node.d.strings[0].d.token.flags; if (tokenFlags & StringTokenFlags.Bytes) { @@ -3257,22 +3256,6 @@ export function createTypeEvaluator( ); } - // Determines whether the specified string literal is part - // of a Literal['xxx'] statement. If so, we will not treat - // the string as a normal forward-declared type annotation. - function isAnnotationLiteralValue(node: StringListNode): boolean { - if (node.parent && node.parent.nodeType === ParseNodeType.Index) { - const baseType = getTypeOfExpression(node.parent.d.leftExpr).type; - if (baseType && isInstantiableClass(baseType)) { - if (ClassType.isSpecialBuiltIn(baseType, 'Literal')) { - return true; - } - } - } - - return false; - } - function addInformation(message: string, node: ParseNode, range?: TextRange) { return addDiagnosticWithSuppressionCheck('information', message, node, range); } @@ -5653,8 +5636,10 @@ export function createTypeEvaluator( const getAttrSymbol = ModuleType.getField(baseType, '__getattr__'); if (getAttrSymbol) { const isModuleGetAttrSupported = - fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(pythonVersion3_7) || - getAttrSymbol.getDeclarations().some((decl) => decl.uri.hasExtension('.pyi')); + PythonVersion.isGreaterOrEqualTo( + fileInfo.executionEnvironment.pythonVersion, + pythonVersion3_7 + ) || getAttrSymbol.getDeclarations().some((decl) => decl.uri.hasExtension('.pyi')); if (isModuleGetAttrSupported) { const getAttrTypeResult = getEffectiveTypeOfSymbolForUsage(getAttrSymbol); @@ -6679,7 +6664,7 @@ export function createTypeEvaluator( const minPythonVersion = nonSubscriptableTypes.get(baseTypeResult.type.shared.fullName); if ( minPythonVersion !== undefined && - fileInfo.executionEnvironment.pythonVersion.isLessThan(minPythonVersion) && + PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, minPythonVersion) && !fileInfo.isStubFile ) { addDiagnostic( @@ -10537,7 +10522,7 @@ export function createTypeEvaluator( paramSpecTarget = TypeVarType.cloneForParamSpecAccess(varArgListParamType, /* access */ undefined); } else { positionalOnlyLimitIndex = varArgListParamIndex; - positionalArgCount = varArgListParamIndex; + positionalArgCount = Math.min(varArgListParamIndex, positionalArgCount); positionParamLimitIndex = varArgListParamIndex; } } @@ -11990,6 +11975,8 @@ export function createTypeEvaluator( return returnType; } + inferReturnTypeIfNecessary(returnType); + // Create a new scope ID based on the caller's position. This // will guarantee uniqueness. If another caller uses the same // call and arguments, the type vars will not conflict. @@ -12616,7 +12603,7 @@ export function createTypeEvaluator( const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode); if ( !fileInfo.isStubFile && - fileInfo.executionEnvironment.pythonVersion.isLessThan(pythonVersion3_13) && + PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, pythonVersion3_13) && classType.shared.moduleName !== 'typing_extensions' ) { addDiagnostic( @@ -12775,7 +12762,7 @@ export function createTypeEvaluator( const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode); if ( !fileInfo.isStubFile && - fileInfo.executionEnvironment.pythonVersion.isLessThan(pythonVersion3_13) && + PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, pythonVersion3_13) && classType.shared.moduleName !== 'typing_extensions' ) { addDiagnostic( @@ -12865,7 +12852,7 @@ export function createTypeEvaluator( const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode); if ( !fileInfo.isStubFile && - fileInfo.executionEnvironment.pythonVersion.isLessThan(pythonVersion3_13) && + PythonVersion.isLessThan(fileInfo.executionEnvironment.pythonVersion, pythonVersion3_13) && classType.shared.moduleName !== 'typing_extensions' ) { addDiagnostic( @@ -14615,7 +14602,8 @@ export function createTypeEvaluator( paramType ?? UnknownType.create(), FunctionParamFlags.TypeDeclared, param.d.name ? param.d.name.d.value : undefined, - param.d.defaultValue ? AnyType.create(/* isEllipsis */ true) : undefined + param.d.defaultValue ? AnyType.create(/* isEllipsis */ true) : undefined, + param.d.defaultValue ); FunctionType.addParam(functionType, functionParam); @@ -15343,10 +15331,7 @@ export function createTypeEvaluator( return type; } - // Creates a "TypeGuard" and "TypeIs" type. This is an alias for 'bool', which - // isn't a generic type and therefore doesn't have a typeParam. - // We'll abuse our internal types a bit by specializing it with - // a type argument anyway. + // Creates a "TypeGuard" and "TypeIs" type. function createTypeGuardType( classType: ClassType, errorNode: ParseNode, @@ -15688,15 +15673,19 @@ export function createTypeEvaluator( return { type: classType }; } - if (typeArgs) { + let type: Type | undefined; + + if (typeArgs && typeArgs.length > 0) { + type = typeArgs[0].type; + if (typeArgs.length < 2) { addDiagnostic(DiagnosticRule.reportInvalidTypeForm, LocMessage.annotatedTypeArgMissing(), errorNode); } else { - validateAnnotatedMetadata(errorNode, typeArgs[0].type, typeArgs.slice(1)); + type = validateAnnotatedMetadata(errorNode, typeArgs[0].type, typeArgs.slice(1)); } } - if (!typeArgs || typeArgs.length === 0) { + if (!type || !typeArgs || typeArgs.length === 0) { return { type: AnyType.create() }; } @@ -15705,69 +15694,87 @@ export function createTypeEvaluator( } return { - type: TypeBase.cloneAsSpecialForm(typeArgs[0].type, classType), + type: TypeBase.cloneAsSpecialForm(type, classType), isReadOnly: typeArgs[0].isReadOnly, isRequired: typeArgs[0].isRequired, isNotRequired: typeArgs[0].isNotRequired, }; } - // Enforces metadata consistency as specified in PEP 746. - function validateAnnotatedMetadata(errorNode: ExpressionNode, annotatedType: Type, metaArgs: TypeResultWithNode[]) { + // Enforces metadata consistency as specified in PEP 746 and associates + // refinement type predicates with the base type. + function validateAnnotatedMetadata( + errorNode: ExpressionNode, + baseType: Type, + metaArgs: TypeResultWithNode[] + ): Type { + for (const metaArg of metaArgs) { + validateTypeMetadata(errorNode, baseType, metaArg); + } + + return baseType; + } + + // Determines whether the metadata object is compatible with the base type. + function validateTypeMetadata(errorNode: ExpressionNode, baseType: Type, metaArg: TypeResultWithNode): boolean { // This is an experimental feature because PEP 746 hasn't been accepted. if (!AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.enableExperimentalFeatures) { - return; + return true; } - for (const metaArg of metaArgs) { - if (isClass(metaArg.type)) { - const supportsTypeMethod = getTypeOfBoundMember( - /* errorNode */ undefined, - metaArg.type, - '__supports_type__' - )?.type; + if (!isClass(metaArg.type)) { + return true; + } - if (!supportsTypeMethod) { - continue; - } + const supportsTypeMethod = getTypeOfBoundMember( + /* errorNode */ undefined, + metaArg.type, + '__supports_type__' + )?.type; - // "Call" the __supports_type__ method to determine if the type is supported. - const callResult = useSpeculativeMode(errorNode, () => - validateCallArgs( - errorNode, - [ - { - argCategory: ArgCategory.Simple, - typeResult: { type: convertToInstance(annotatedType) }, - }, - ], - { type: supportsTypeMethod }, - /* constraints */ undefined, - /* skipUnknownArgCheck */ true, - /* inferenceContext */ undefined - ) - ); + if (!supportsTypeMethod) { + return true; + } - if (callResult.isTypeIncomplete || !callResult.returnType) { - continue; - } + // "Call" the __supports_type__ method to determine if the type is supported. + const callResult = useSpeculativeMode(errorNode, () => + validateCallArgs( + errorNode, + [ + { + argCategory: ArgCategory.Simple, + typeResult: { type: convertToInstance(baseType) }, + }, + ], + { type: supportsTypeMethod }, + /* constraints */ undefined, + /* skipUnknownArgCheck */ true, + /* inferenceContext */ undefined + ) + ); - // If there are no errors and the return type is potentially truthy, - // we know that the type is supported by this metadata object. - if (!callResult.argumentErrors && canBeTruthy(callResult.returnType)) { - continue; - } + if (!callResult.returnType) { + return true; + } - addDiagnostic( - DiagnosticRule.reportInvalidTypeArguments, - LocMessage.annotatedMetadataInconsistent().format({ - metadataType: printType(metaArg.type), - type: printType(convertToInstance(annotatedType)), - }), - metaArg.node - ); - } + // If there are no errors and the return type is potentially truthy, + // we know that the type is supported by this metadata object. + if (!callResult.argumentErrors && canBeTruthy(callResult.returnType)) { + return true; } + + if (!callResult.isTypeIncomplete) { + addDiagnostic( + DiagnosticRule.reportInvalidTypeArguments, + LocMessage.annotatedMetadataInconsistent().format({ + metadataType: printType(metaArg.type), + type: printType(convertToInstance(baseType)), + }), + metaArg.node + ); + } + + return false; } // Creates one of several "special" types that are defined in typing.pyi @@ -16208,7 +16215,7 @@ export function createTypeEvaluator( specialClassType.shared.flags |= ClassTypeFlags.TypingExtensionClass; } - const baseClassName = aliasMapEntry.alias || 'object'; + const baseClassName = aliasMapEntry.implicitBaseClass || aliasMapEntry.alias || 'object'; let baseClass: Type | undefined; if (aliasMapEntry.module === 'builtins') { @@ -16283,7 +16290,13 @@ export function createTypeEvaluator( ['Concatenate', { alias: '', module: 'builtins', isSpecialForm: true }], [ 'TypeGuard', - { alias: '', module: 'builtins', isSpecialForm: true, typeParamVariance: Variance.Covariant }, + { + alias: '', + module: 'builtins', + implicitBaseClass: 'bool', + isSpecialForm: true, + typeParamVariance: Variance.Covariant, + }, ], ['Unpack', { alias: '', module: 'builtins', isSpecialForm: true }], ['Required', { alias: '', module: 'builtins', isSpecialForm: true }], @@ -16293,7 +16306,16 @@ export function createTypeEvaluator( ['Never', { alias: '', module: 'builtins', isSpecialForm: true }], ['LiteralString', { alias: '', module: 'builtins', isSpecialForm: true }], ['ReadOnly', { alias: '', module: 'builtins', isSpecialForm: true }], - ['TypeIs', { alias: '', module: 'builtins', isSpecialForm: true, typeParamVariance: Variance.Invariant }], + [ + 'TypeIs', + { + alias: '', + module: 'builtins', + implicitBaseClass: 'bool', + isSpecialForm: true, + typeParamVariance: Variance.Invariant, + }, + ], ]); const aliasMapEntry = specialTypes.get(assignedName); @@ -16886,7 +16908,10 @@ export function createTypeEvaluator( if ( !fileInfo.isStubFile && !ClassType.isTypingExtensionClass(argType) && - fileInfo.executionEnvironment.pythonVersion.isLessThan(pythonVersion3_7) + PythonVersion.isLessThan( + fileInfo.executionEnvironment.pythonVersion, + pythonVersion3_7 + ) ) { addDiagnostic( DiagnosticRule.reportInvalidTypeForm, @@ -16903,7 +16928,12 @@ export function createTypeEvaluator( // If the class directly derives from NamedTuple (in Python 3.6 or // newer), it's considered a (read-only) dataclass. - if (fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(pythonVersion3_6)) { + if ( + PythonVersion.isGreaterOrEqualTo( + fileInfo.executionEnvironment.pythonVersion, + pythonVersion3_6 + ) + ) { if (ClassType.isBuiltIn(argType, 'NamedTuple')) { isNamedTupleSubclass = true; classType.shared.flags |= ClassTypeFlags.ReadOnlyInstanceVariables; @@ -18401,7 +18431,8 @@ export function createTypeEvaluator( (isTypeInferred ? FunctionParamFlags.TypeInferred : FunctionParamFlags.None) | (paramTypeNode ? FunctionParamFlags.TypeDeclared : FunctionParamFlags.None), param.d.name ? param.d.name.d.value : undefined, - defaultValueType + defaultValueType, + param.d.defaultValue ); FunctionType.addParam(functionType, functionParam); @@ -19359,7 +19390,10 @@ export function createTypeEvaluator( // Handle PEP 562 support for module-level __getattr__ function, // introduced in Python 3.7. if ( - fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(pythonVersion3_7) || + PythonVersion.isGreaterOrEqualTo( + fileInfo.executionEnvironment.pythonVersion, + pythonVersion3_7 + ) || fileInfo.isStubFile ) { const getAttrSymbol = importLookupInfo.symbolTable.get('__getattr__'); @@ -20442,7 +20476,7 @@ export function createTypeEvaluator( const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode); if ( fileInfo.isStubFile || - fileInfo.executionEnvironment.pythonVersion.isGreaterOrEqualTo(pythonVersion3_9) || + PythonVersion.isGreaterOrEqualTo(fileInfo.executionEnvironment.pythonVersion, pythonVersion3_9) || isAnnotationEvaluationPostponed(AnalyzerNodeInfo.getFileInfo(errorNode)) || (flags & EvalFlags.ForwardRefs) !== 0 ) { @@ -23019,14 +23053,6 @@ export function createTypeEvaluator( return true; } - // If the type is a bool created with a `TypeGuard` or `TypeIs`, it is - // considered a subtype of `bool`. - if (isInstantiableClass(srcType) && ClassType.isBuiltIn(srcType, ['TypeGuard', 'TypeIs'])) { - if (isInstantiableClass(destType) && ClassType.isBuiltIn(destType, 'bool')) { - return (flags & AssignTypeFlags.Invariant) === 0; - } - } - if ((flags & AssignTypeFlags.Invariant) === 0 || ClassType.isSameGenericClass(srcType, destType)) { if (isDerivedFrom) { assert(inheritanceChain.length > 0); @@ -25786,7 +25812,8 @@ export function createTypeEvaluator( p.name, FunctionType.getParamDefaultType(effectiveSrcType, index) ? AnyType.create(/* isEllipsis */ true) - : undefined + : undefined, + p.defaultExpr ) ); } @@ -27225,12 +27252,12 @@ export function createTypeEvaluator( valueOffset, textValue.length, parseOptions, - /* parseTextMode */ undefined, + ParseTextMode.Expression, /* initialParenDepth */ undefined, fileInfo.typingSymbolAliases ); - if (parseResults.parseTree && parseResults.parseTree.nodeType !== ParseNodeType.FunctionAnnotation) { + if (parseResults.parseTree) { parseResults.diagnostics.forEach((diag) => { addDiagnosticWithSuppressionCheck('error', diag.message, node); }); diff --git a/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts b/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts index 6a5915456f..65274ae810 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts @@ -118,7 +118,7 @@ export const enum EvalFlags { // a base class whose TypeVar variance is inconsistent. EnforceVarianceConsistency = 1 << 14, - // Used for PEP 526-style variable type annotations + // Used for PEP 526-style variable type annotations. VarTypeAnnotation = 1 << 15, // 'ClassVar' is not allowed in this context. diff --git a/packages/pyright-internal/src/analyzer/typePrinter.ts b/packages/pyright-internal/src/analyzer/typePrinter.ts index ed42f38ee0..e717be3095 100644 --- a/packages/pyright-internal/src/analyzer/typePrinter.ts +++ b/packages/pyright-internal/src/analyzer/typePrinter.ts @@ -1086,7 +1086,6 @@ function printFunctionPartsInternal( ): [string[], string] { const paramTypeStrings: string[] = []; let sawDefinedName = false; - const functionNode = type.shared.declaration?.node; // Remove the (*args: P.args, **kwargs: P.kwargs) from the end of the parameter list. const paramSpec = FunctionType.getParamSpecFromArgsKwargs(type); @@ -1231,9 +1230,8 @@ function printFunctionPartsInternal( } if (defaultType) { - const paramNode = functionNode?.d.params.find((p) => p.d.name?.d.value === param.name); - if (paramNode?.d.defaultValue) { - paramString += defaultValueAssignment + ParseTreeUtils.printExpression(paramNode.d.defaultValue); + if (param.defaultExpr) { + paramString += defaultValueAssignment + ParseTreeUtils.printExpression(param.defaultExpr); } else { // If the function doesn't originate from a function declaration (e.g. it is // synthesized), we can't get to the default declaration, but we can still indicate diff --git a/packages/pyright-internal/src/analyzer/typeUtils.ts b/packages/pyright-internal/src/analyzer/typeUtils.ts index 2ad837426c..8e49cdbc97 100644 --- a/packages/pyright-internal/src/analyzer/typeUtils.ts +++ b/packages/pyright-internal/src/analyzer/typeUtils.ts @@ -1026,9 +1026,16 @@ export function isTypeAliasRecursive(typeAliasPlaceholder: TypeVarType, type: Ty ); } -export function transformPossibleRecursiveTypeAlias(type: Type): Type; -export function transformPossibleRecursiveTypeAlias(type: Type | undefined): Type | undefined; -export function transformPossibleRecursiveTypeAlias(type: Type | undefined): Type | undefined { +// Recursively transforms all top-level TypeVars that represent recursive +// type aliases into their actual types. +export function transformPossibleRecursiveTypeAlias(type: Type, recursionCount?: number): Type; +export function transformPossibleRecursiveTypeAlias(type: Type | undefined, recursionCount?: number): Type | undefined; +export function transformPossibleRecursiveTypeAlias(type: Type | undefined, recursionCount = 0): Type | undefined { + if (recursionCount >= maxTypeRecursionCount) { + return type; + } + recursionCount++; + if (type) { const aliasInfo = type.props?.typeAliasInfo; @@ -1038,15 +1045,18 @@ export function transformPossibleRecursiveTypeAlias(type: Type | undefined): Typ : type.shared.boundType; if (!aliasInfo?.typeArgs || !type.shared.recursiveAlias.typeParams) { - return unspecializedType; + return transformPossibleRecursiveTypeAlias(unspecializedType, recursionCount); } const solution = buildSolution(type.shared.recursiveAlias.typeParams, aliasInfo.typeArgs); - return applySolvedTypeVars(unspecializedType, solution); + return transformPossibleRecursiveTypeAlias( + applySolvedTypeVars(unspecializedType, solution), + recursionCount + ); } if (isUnion(type) && type.priv.includesRecursiveTypeAlias) { - let newType = mapSubtypes(type, (subtype) => transformPossibleRecursiveTypeAlias(subtype)); + let newType = mapSubtypes(type, (subtype) => transformPossibleRecursiveTypeAlias(subtype, recursionCount)); if (newType !== type && aliasInfo) { // Copy the type alias information if present. @@ -3205,7 +3215,8 @@ export function convertTypeToParamSpecValue(type: Type): FunctionType { FunctionType.getParamType(type, index), param.flags, param.name, - FunctionType.getParamDefaultType(type, index) + FunctionType.getParamDefaultType(type, index), + param.defaultExpr ) ); }); @@ -3766,7 +3777,8 @@ export class TypeVarTransformer { param.name && FunctionParam.isNameSynthesized(param) ? `__p${newFunctionType.shared.parameters.length}` : param.name, - FunctionType.getParamDefaultType(functionType, index) + FunctionType.getParamDefaultType(functionType, index), + param.defaultExpr ) ); } diff --git a/packages/pyright-internal/src/analyzer/types.ts b/packages/pyright-internal/src/analyzer/types.ts index 921c3fcef5..c9ef4a04e9 100644 --- a/packages/pyright-internal/src/analyzer/types.ts +++ b/packages/pyright-internal/src/analyzer/types.ts @@ -9,7 +9,7 @@ import { assert } from '../common/debug'; import { Uri } from '../common/uri/uri'; -import { ArgumentNode, NameNode, ParamCategory } from '../parser/parseNodes'; +import { ArgumentNode, ExpressionNode, NameNode, ParamCategory } from '../parser/parseNodes'; import { ClassDeclaration, FunctionDeclaration, SpecialBuiltInClassDeclaration } from './declaration'; import { Symbol, SymbolTable } from './symbol'; @@ -171,7 +171,7 @@ export interface TypeBaseProps { // Used only for type aliases typeAliasInfo: TypeAliasInfo | undefined; - // Used only for conditional (constrained) types + // Used only for types that are conditioned on a TypeVar condition: TypeCondition[] | undefined; } @@ -505,6 +505,7 @@ export interface DataClassEntry { alias?: string | undefined; hasDefault?: boolean | undefined; nameNode: NameNode | undefined; + defaultExpr?: ExpressionNode | undefined; includeInInit: boolean; type: Type; converter?: ArgumentNode | undefined; @@ -1442,6 +1443,8 @@ export interface FunctionParam { // Use getEffectiveParamDefaultArgType to access this field. // eslint-disable-next-line @typescript-eslint/naming-convention _defaultType: Type | undefined; + + defaultExpr: ExpressionNode | undefined; } export namespace FunctionParam { @@ -1450,9 +1453,10 @@ export namespace FunctionParam { type: Type, flags = FunctionParamFlags.None, name?: string, - defaultType?: Type + defaultType?: Type, + defaultExpr?: ExpressionNode ): FunctionParam { - return { category, flags, name, _type: type, _defaultType: defaultType }; + return { category, flags, name, _type: type, _defaultType: defaultType, defaultExpr }; } export function isNameSynthesized(param: FunctionParam) { @@ -1815,7 +1819,8 @@ export namespace FunctionType { FunctionType.getParamType(paramSpecValue, index), (param.flags & FunctionParamFlags.NameSynthesized) | FunctionParamFlags.TypeDeclared, param.name, - FunctionType.getParamDefaultType(paramSpecValue, index) + FunctionType.getParamDefaultType(paramSpecValue, index), + param.defaultExpr ); }), ]; diff --git a/packages/pyright-internal/src/backgroundThreadBase.ts b/packages/pyright-internal/src/backgroundThreadBase.ts index ac4cfcdc9c..fe087b9ae0 100644 --- a/packages/pyright-internal/src/backgroundThreadBase.ts +++ b/packages/pyright-internal/src/backgroundThreadBase.ts @@ -13,7 +13,6 @@ import { ConsoleInterface, LogLevel } from './common/console'; import { Disposable, isThenable } from './common/core'; import * as debug from './common/debug'; import { FileSystem, TempFile } from './common/fileSystem'; -import { PythonVersion } from './common/pythonVersion'; import { ServiceKeys } from './common/serviceKeys'; import { ServiceProvider } from './common/serviceProvider'; import './common/serviceProviderExtensions'; @@ -124,9 +123,6 @@ export function serializeReplacer(value: any) { if (Uri.is(value) && value.toJsonObj !== undefined) { return { __serialized_uri_val: value.toJsonObj() }; } - if (value instanceof PythonVersion) { - return { __serialized_version_val: value.toString() }; - } if (value instanceof Map) { return { __serialized_map_val: [...value] }; } @@ -154,9 +150,6 @@ export function deserializeReviver(value: any) { if (value.__serialized_uri_val !== undefined) { return Uri.fromJsonObj(value.__serialized_uri_val); } - if (value.__serialized_version_val) { - return PythonVersion.fromString(value.__serialized_version_val); - } if (value.__serialized_map_val) { return new Map(value.__serialized_map_val); } diff --git a/packages/pyright-internal/src/common/configOptions.ts b/packages/pyright-internal/src/common/configOptions.ts index 8a4eaad911..9470d327a8 100644 --- a/packages/pyright-internal/src/common/configOptions.ts +++ b/packages/pyright-internal/src/common/configOptions.ts @@ -1678,7 +1678,7 @@ export class ConfigOptions { const importFailureInfo: string[] = []; this.defaultPythonVersion = host.getPythonVersion(this.pythonPath, importFailureInfo); if (this.defaultPythonVersion !== undefined) { - console.info(`Assuming Python version ${this.defaultPythonVersion.toString()}`); + console.info(`Assuming Python version ${PythonVersion.toString(this.defaultPythonVersion)}`); } for (const log of importFailureInfo) { diff --git a/packages/pyright-internal/src/common/fullAccessHost.ts b/packages/pyright-internal/src/common/fullAccessHost.ts index 148e1be167..429227ec9a 100644 --- a/packages/pyright-internal/src/common/fullAccessHost.ts +++ b/packages/pyright-internal/src/common/fullAccessHost.ts @@ -121,7 +121,7 @@ export class FullAccessHost extends LimitedAccessHost { return undefined; } - const version = new PythonVersion( + const version = PythonVersion.create( versionJson[0], versionJson[1], versionJson[2], diff --git a/packages/pyright-internal/src/common/pythonVersion.ts b/packages/pyright-internal/src/common/pythonVersion.ts index 46fbca1c2e..2389904a34 100644 --- a/packages/pyright-internal/src/common/pythonVersion.ts +++ b/packages/pyright-internal/src/common/pythonVersion.ts @@ -9,77 +9,73 @@ export type PythonReleaseLevel = 'alpha' | 'beta' | 'candidate' | 'final'; -export class PythonVersion { - constructor( - private _major: number, - private _minor: number, - private _micro?: number, - private _releaseLevel?: PythonReleaseLevel, - private _serial?: number - ) {} - - get major() { - return this._major; - } - - get minor() { - return this._minor; - } - - get micro() { - return this._micro; - } - - get releaseLevel() { - return this._releaseLevel; - } +export interface PythonVersion { + major: number; + minor: number; + micro?: number; + releaseLevel?: PythonReleaseLevel; + serial?: number; +} - get serial() { - return this._serial; +export namespace PythonVersion { + export function create( + major: number, + minor: number, + micro?: number, + releaseLevel?: PythonReleaseLevel, + serial?: number + ): PythonVersion { + return { + major, + minor, + micro, + releaseLevel, + serial, + }; } - isEqualTo(other: PythonVersion) { - if (this.major !== other.major || this.minor !== other.minor) { + export function isEqualTo(version: PythonVersion, other: PythonVersion) { + if (version.major !== other.major || version.minor !== other.minor) { return false; } - if (this._micro === undefined || other._micro === undefined) { + if (version.micro === undefined || other.micro === undefined) { return true; - } else if (this._micro !== other._micro) { + } else if (version.micro !== other.micro) { return false; } - if (this._releaseLevel === undefined || other._releaseLevel === undefined) { + if (version.releaseLevel === undefined || other.releaseLevel === undefined) { return true; - } else if (this._releaseLevel !== other._releaseLevel) { + } else if (version.releaseLevel !== other.releaseLevel) { return false; } - if (this._serial === undefined || other._serial === undefined) { + if (version.serial === undefined || other.serial === undefined) { return true; - } else if (this._serial !== other._serial) { + } else if (version.serial !== other.serial) { return false; } return true; } - isGreaterThan(other: PythonVersion) { - if (this.major > other.major) { + export function isGreaterThan(version: PythonVersion, other: PythonVersion) { + if (version.major > other.major) { return true; - } else if (this.major < other.major) { + } else if (version.major < other.major) { return false; } - if (this.minor > other.minor) { + if (version.minor > other.minor) { return true; - } else if (this.minor < other.minor) { + } else if (version.minor < other.minor) { return false; } - if (this._micro === undefined || other._micro === undefined || this._micro < other._micro) { + if (version.micro === undefined || other.micro === undefined || version.micro < other.micro) { return false; - } else if (this._micro > other._micro) { + } else if (version.micro > other.micro) { return true; } @@ -87,18 +83,18 @@ export class PythonVersion { // of the release level designators are ordered by increasing // release level. if ( - this._releaseLevel === undefined || - other._releaseLevel === undefined || - this._releaseLevel < other._releaseLevel + version.releaseLevel === undefined || + other.releaseLevel === undefined || + version.releaseLevel < other.releaseLevel ) { return false; - } else if (this._releaseLevel > other._releaseLevel) { + } else if (version.releaseLevel > other.releaseLevel) { return true; } - if (this._serial === undefined || other._serial === undefined || this._serial < other._serial) { + if (version.serial === undefined || other.serial === undefined || version.serial < other.serial) { return false; - } else if (this._serial > other._serial) { + } else if (version.serial > other.serial) { return true; } @@ -106,46 +102,46 @@ export class PythonVersion { return false; } - isGreaterOrEqualTo(other: PythonVersion) { - return this.isEqualTo(other) || this.isGreaterThan(other); + export function isGreaterOrEqualTo(version: PythonVersion, other: PythonVersion) { + return isEqualTo(version, other) || isGreaterThan(version, other); } - isLessThan(other: PythonVersion) { - return !this.isGreaterOrEqualTo(other); + export function isLessThan(version: PythonVersion, other: PythonVersion) { + return !isGreaterOrEqualTo(version, other); } - isLessOrEqualTo(other: PythonVersion) { - return !this.isGreaterThan(other); + export function isLessOrEqualTo(version: PythonVersion, other: PythonVersion) { + return !isGreaterThan(version, other); } - toMajorMinorString(): string { - return `${this._major}.${this._minor}`; + export function toMajorMinorString(version: PythonVersion): string { + return `${version.major}.${version.minor}`; } - toString(): string { - let version = this.toMajorMinorString(); + export function toString(version: PythonVersion): string { + let versString = toMajorMinorString(version); - if (this._micro === undefined) { - return version; + if (version.micro === undefined) { + return versString; } - version += `.${this._micro}`; + versString += `.${version.micro}`; - if (this._releaseLevel === undefined) { - return version; + if (version.releaseLevel === undefined) { + return versString; } - version += `.${this._releaseLevel}`; + versString += `.${version.releaseLevel}`; - if (this._serial === undefined) { - return version; + if (version.serial === undefined) { + return versString; } - version += `.${this._serial}`; - return version; + versString += `.${version.serial}`; + return versString; } - static fromString(val: string): PythonVersion | undefined { + export function fromString(val: string): PythonVersion | undefined { const split = val.split('.'); if (split.length < 2) { @@ -183,25 +179,25 @@ export class PythonVersion { } } - return new PythonVersion(major, minor, micro, releaseLevel, serial); + return create(major, minor, micro, releaseLevel, serial); } } // Predefine some versions. -export const pythonVersion3_0 = new PythonVersion(3, 0); -export const pythonVersion3_1 = new PythonVersion(3, 1); -export const pythonVersion3_2 = new PythonVersion(3, 2); -export const pythonVersion3_3 = new PythonVersion(3, 3); -export const pythonVersion3_4 = new PythonVersion(3, 4); -export const pythonVersion3_5 = new PythonVersion(3, 5); -export const pythonVersion3_6 = new PythonVersion(3, 6); -export const pythonVersion3_7 = new PythonVersion(3, 7); -export const pythonVersion3_8 = new PythonVersion(3, 8); -export const pythonVersion3_9 = new PythonVersion(3, 9); -export const pythonVersion3_10 = new PythonVersion(3, 10); -export const pythonVersion3_11 = new PythonVersion(3, 11); -export const pythonVersion3_12 = new PythonVersion(3, 12); -export const pythonVersion3_13 = new PythonVersion(3, 13); -export const pythonVersion3_14 = new PythonVersion(3, 14); +export const pythonVersion3_0 = PythonVersion.create(3, 0); +export const pythonVersion3_1 = PythonVersion.create(3, 1); +export const pythonVersion3_2 = PythonVersion.create(3, 2); +export const pythonVersion3_3 = PythonVersion.create(3, 3); +export const pythonVersion3_4 = PythonVersion.create(3, 4); +export const pythonVersion3_5 = PythonVersion.create(3, 5); +export const pythonVersion3_6 = PythonVersion.create(3, 6); +export const pythonVersion3_7 = PythonVersion.create(3, 7); +export const pythonVersion3_8 = PythonVersion.create(3, 8); +export const pythonVersion3_9 = PythonVersion.create(3, 9); +export const pythonVersion3_10 = PythonVersion.create(3, 10); +export const pythonVersion3_11 = PythonVersion.create(3, 11); +export const pythonVersion3_12 = PythonVersion.create(3, 12); +export const pythonVersion3_13 = PythonVersion.create(3, 13); +export const pythonVersion3_14 = PythonVersion.create(3, 14); export const latestStablePythonVersion = pythonVersion3_12; diff --git a/packages/pyright-internal/src/languageService/completionProvider.ts b/packages/pyright-internal/src/languageService/completionProvider.ts index db9b83630b..2146b51120 100644 --- a/packages/pyright-internal/src/languageService/completionProvider.ts +++ b/packages/pyright-internal/src/languageService/completionProvider.ts @@ -175,10 +175,10 @@ namespace Keywords { const python3_10: string[] = [...python3_5, 'case', 'match']; export function forVersion(version: PythonVersion): string[] { - if (version.isGreaterOrEqualTo(pythonVersion3_10)) { + if (PythonVersion.isGreaterOrEqualTo(version, pythonVersion3_10)) { return python3_10; } - if (version.isGreaterOrEqualTo(pythonVersion3_5)) { + if (PythonVersion.isGreaterOrEqualTo(version, pythonVersion3_5)) { return python3_5; } return base; diff --git a/packages/pyright-internal/src/localization/localize.ts b/packages/pyright-internal/src/localization/localize.ts index 5e0ca4079b..c42caeb19d 100644 --- a/packages/pyright-internal/src/localization/localize.ts +++ b/packages/pyright-internal/src/localization/localize.ts @@ -472,10 +472,10 @@ export namespace Localizer { export const expectedExceptionClass = () => getRawString('Diagnostic.expectedExceptionClass'); export const expectedExceptionObj = () => getRawString('Diagnostic.expectedExceptionObj'); export const expectedExpr = () => getRawString('Diagnostic.expectedExpr'); + export const expectedIdentifier = () => getRawString('Diagnostic.expectedIdentifier'); export const expectedImport = () => getRawString('Diagnostic.expectedImport'); export const expectedImportAlias = () => getRawString('Diagnostic.expectedImportAlias'); export const expectedImportSymbols = () => getRawString('Diagnostic.expectedImportSymbols'); - export const expectedIdentifier = () => getRawString('Diagnostic.expectedIdentifier'); export const expectedIndentedBlock = () => getRawString('Diagnostic.expectedIndentedBlock'); export const expectedIn = () => getRawString('Diagnostic.expectedIn'); export const expectedInExpr = () => getRawString('Diagnostic.expectedInExpr'); diff --git a/packages/pyright-internal/src/parser/parser.ts b/packages/pyright-internal/src/parser/parser.ts index cc5b8c5246..4a5c8a6364 100644 --- a/packages/pyright-internal/src/parser/parser.ts +++ b/packages/pyright-internal/src/parser/parser.ts @@ -192,8 +192,8 @@ export interface ParseFileResults { tokenizerOutput: TokenizerOutput; } -export interface ParseExpressionTextResults { - parseTree?: ExpressionNode | FunctionAnnotationNode | undefined; +export interface ParseExpressionTextResults { + parseTree?: T | undefined; lines: TextRangeCollection; diagnostics: Diagnostic[]; } @@ -213,7 +213,7 @@ export interface ArgListResult { trailingComma: boolean; } -const enum ParseTextMode { +export const enum ParseTextMode { Expression, VariableAnnotation, FunctionAnnotation, @@ -291,6 +291,33 @@ export class Parser { }; } + parseTextExpression( + fileContents: string, + textOffset: number, + textLength: number, + parseOptions: ParseOptions, + parseTextMode: ParseTextMode.Expression, + initialParenDepth?: number, + typingSymbolAliases?: Map + ): ParseExpressionTextResults; + parseTextExpression( + fileContents: string, + textOffset: number, + textLength: number, + parseOptions: ParseOptions, + parseTextMode: ParseTextMode.VariableAnnotation, + initialParenDepth?: number, + typingSymbolAliases?: Map + ): ParseExpressionTextResults; + parseTextExpression( + fileContents: string, + textOffset: number, + textLength: number, + parseOptions: ParseOptions, + parseTextMode: ParseTextMode.FunctionAnnotation, + initialParenDepth?: number, + typingSymbolAliases?: Map + ): ParseExpressionTextResults; parseTextExpression( fileContents: string, textOffset: number, @@ -299,7 +326,7 @@ export class Parser { parseTextMode = ParseTextMode.Expression, initialParenDepth = 0, typingSymbolAliases?: Map - ): ParseExpressionTextResults { + ): ParseExpressionTextResults { const diagSink = new DiagnosticSink(); this._startNewParse(fileContents, textOffset, textLength, parseOptions, diagSink, initialParenDepth); @@ -474,7 +501,7 @@ export class Parser { private _parseTypeAliasStatement(): TypeAliasNode { const typeToken = this._getKeywordToken(KeywordType.Type); - if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion3_12)) { + if (!this._parseOptions.isStubFile && PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_12)) { this._addSyntaxError(LocMessage.typeAliasStatementIllegal(), typeToken); } @@ -577,7 +604,10 @@ export class Parser { /* allowUnpack */ typeParamCategory === TypeParamKind.TypeVarTuple ); - if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion3_13)) { + if ( + !this._parseOptions.isStubFile && + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_13) + ) { this._addSyntaxError(LocMessage.typeVarDefaultIllegal(), defaultExpression); } } @@ -702,7 +732,7 @@ export class Parser { } // This feature requires Python 3.10. - if (this._getLanguageVersion().isLessThan(pythonVersion3_10)) { + if (PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_10)) { this._addSyntaxError(LocMessage.matchIncompatible(), matchToken); } @@ -1629,7 +1659,10 @@ export class Parser { // Versions of Python earlier than 3.9 didn't allow unpack operators if the // tuple wasn't enclosed in parentheses. - if (this._getLanguageVersion().isLessThan(pythonVersion3_9) && !this._parseOptions.isStubFile) { + if ( + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_9) && + !this._parseOptions.isStubFile + ) { if (seqExpr.nodeType === ParseNodeType.Tuple && !seqExpr.d.hasParens) { let sawStar = false; seqExpr.d.items.forEach((expr) => { @@ -1805,7 +1838,10 @@ export class Parser { const possibleStarToken = this._peekToken(); let isExceptGroup = false; if (this._consumeTokenIfOperator(OperatorType.Multiply)) { - if (this._getLanguageVersion().isLessThan(pythonVersion3_11) && !this._parseOptions.isStubFile) { + if ( + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_11) && + !this._parseOptions.isStubFile + ) { this._addSyntaxError(LocMessage.exceptionGroupIncompatible(), possibleStarToken); } isExceptGroup = true; @@ -1904,7 +1940,10 @@ export class Parser { if (possibleOpenBracket.type === TokenType.OpenBracket) { typeParameters = this._parseTypeParameterList(); - if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion3_12)) { + if ( + !this._parseOptions.isStubFile && + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_12) + ) { this._addSyntaxError(LocMessage.functionTypeParametersIllegal(), typeParameters); } } @@ -2118,7 +2157,10 @@ export class Parser { } else if (this._consumeTokenIfOperator(OperatorType.Power)) { starCount = 2; } else if (this._consumeTokenIfOperator(OperatorType.Divide)) { - if (this._getLanguageVersion().isLessThan(pythonVersion3_8) && !this._parseOptions.isStubFile) { + if ( + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_8) && + !this._parseOptions.isStubFile + ) { this._addSyntaxError(LocMessage.positionOnlyIncompatible(), firstToken); } slashCount = 1; @@ -2222,7 +2264,7 @@ export class Parser { if (isParenthesizedWithItemList) { this._consumeTokenIfType(TokenType.OpenParenthesis); - if (this._getLanguageVersion().isLessThan(pythonVersion3_9)) { + if (PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_9)) { this._addSyntaxError(LocMessage.parenthesizedContextManagerIllegal(), possibleParen); } } @@ -2331,7 +2373,7 @@ export class Parser { // Versions of Python prior to 3.9 support a limited set of // expression forms. - if (this._getLanguageVersion().isLessThan(pythonVersion3_9)) { + if (PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_9)) { let isSupportedExpressionForm = false; if (this._isNameOrMemberAccessExpression(expression)) { isSupportedExpressionForm = true; @@ -2382,7 +2424,10 @@ export class Parser { if (possibleOpenBracket.type === TokenType.OpenBracket) { typeParameters = this._parseTypeParameterList(); - if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion3_12)) { + if ( + !this._parseOptions.isStubFile && + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_12) + ) { this._addSyntaxError(LocMessage.classTypeParametersIllegal(), typeParameters); } } @@ -2848,7 +2893,7 @@ export class Parser { const nextToken = this._peekToken(); if (this._consumeTokenIfKeyword(KeywordType.From)) { - if (this._getLanguageVersion().isLessThan(pythonVersion3_3)) { + if (PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_3)) { this._addSyntaxError(LocMessage.yieldFromIllegal(), nextToken); } return YieldFromNode.create(yieldToken, this._parseTestExpression(/* allowAssignmentExpression */ false)); @@ -3188,7 +3233,7 @@ export class Parser { this._addSyntaxError(LocMessage.walrusNotAllowed(), walrusToken); } - if (this._getLanguageVersion().isLessThan(pythonVersion3_8)) { + if (PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_8)) { this._addSyntaxError(LocMessage.walrusIllegal(), walrusToken); } @@ -3478,7 +3523,7 @@ export class Parser { let awaitToken: KeywordToken | undefined; if (this._peekKeywordType() === KeywordType.Await) { awaitToken = this._getKeywordToken(KeywordType.Await); - if (this._getLanguageVersion().isLessThan(pythonVersion3_5)) { + if (PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_5)) { this._addSyntaxError(LocMessage.awaitIllegal(), awaitToken); } } @@ -3671,7 +3716,10 @@ export class Parser { valueExpr = this._parseTestExpression(/* allowAssignmentExpression */ true); // Python 3.10 and newer allow assignment expressions to be used inside of a subscript. - if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion3_10)) { + if ( + !this._parseOptions.isStubFile && + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_10) + ) { this._addSyntaxError(LocMessage.assignmentExprInSubscript(), valueExpr); } } @@ -3698,7 +3746,7 @@ export class Parser { const unpackListAllowed = this._parseOptions.isStubFile || this._isParsingQuotedText || - this._getLanguageVersion().isGreaterOrEqualTo(pythonVersion3_11); + PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion3_11); if (argType === ArgCategory.UnpackedList && !unpackListAllowed) { this._addSyntaxError(LocMessage.unpackedSubscriptIllegal(), argNode); @@ -3752,7 +3800,8 @@ export class Parser { if (nextTokenType !== TokenType.Colon) { // Python 3.10 and newer allow assignment expressions to be used inside of a subscript. const allowAssignmentExpression = - this._parseOptions.isStubFile || this._getLanguageVersion().isGreaterOrEqualTo(pythonVersion3_10); + this._parseOptions.isStubFile || + PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion3_10); sliceExpressions[sliceIndex] = this._parseTestExpression(allowAssignmentExpression); } sliceIndex++; @@ -3861,7 +3910,7 @@ export class Parser { ) { nameNode = NameNode.create(nameExpr.d.token); - if (this._getLanguageVersion().isLessThan(pythonVersion3_14)) { + if (PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_14)) { this._addSyntaxError(LocMessage.keywordArgShortcutIllegal(), assignmentToken); valueExpr = ErrorNode.create(assignmentToken, ErrorExpressionCategory.MissingKeywordArgValue); } else { @@ -4187,7 +4236,7 @@ export class Parser { // Allow walrus operators in this context only for Python 3.10 and newer. // Older versions of Python generated a syntax error in this context. - let isWalrusAllowed = this._getLanguageVersion().isGreaterOrEqualTo(pythonVersion3_10); + let isWalrusAllowed = PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion3_10); if (this._consumeTokenIfType(TokenType.Colon)) { valueExpression = this._parseTestExpression(/* allowAssignmentExpression */ false); @@ -4391,7 +4440,10 @@ export class Parser { annotationExpr = this._parseTypeAnnotation(); leftExpr = TypeAnnotationNode.create(leftExpr, annotationExpr); - if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion3_6)) { + if ( + !this._parseOptions.isStubFile && + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_6) + ) { this._addSyntaxError(LocMessage.varAnnotationIllegal(), annotationExpr); } @@ -4575,7 +4627,7 @@ export class Parser { allowUnpack && !this._parseOptions.isStubFile && !this._isParsingQuotedText && - this._getLanguageVersion().isLessThan(pythonVersion3_11) + PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_11) ) { this._addSyntaxError(LocMessage.unpackedSubscriptIllegal(), startToken); } @@ -4603,7 +4655,7 @@ export class Parser { } if (stringToken.flags & StringTokenFlags.Format) { - if (this._getLanguageVersion().isLessThan(pythonVersion3_6)) { + if (PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion3_6)) { this._addSyntaxError(LocMessage.formatStringIllegal(), stringToken); } @@ -4691,7 +4743,6 @@ export class Parser { return undefined; } - assert(parseResults.parseTree.nodeType !== ParseNodeType.FunctionAnnotation); return parseResults.parseTree; } @@ -4713,7 +4764,7 @@ export class Parser { this._addSyntaxError(diag.message, stringListNode); }); - if (!parseResults.parseTree || parseResults.parseTree.nodeType !== ParseNodeType.FunctionAnnotation) { + if (!parseResults.parseTree) { return; } @@ -4758,7 +4809,7 @@ export class Parser { (nextToken as OperatorToken).operatorType === OperatorType.Assign ) { // This feature requires Python 3.8 or newer. - if (this._parseOptions.pythonVersion.isLessThan(pythonVersion3_8)) { + if (PythonVersion.isLessThan(this._parseOptions.pythonVersion, pythonVersion3_8)) { this._addSyntaxError(LocMessage.formatStringDebuggingIllegal(), nextToken); } @@ -4992,7 +5043,6 @@ export class Parser { }); if (parseResults.parseTree) { - assert(parseResults.parseTree.nodeType !== ParseNodeType.FunctionAnnotation); stringNode.d.annotation = parseResults.parseTree; stringNode.d.annotation.parent = stringNode; } @@ -5019,7 +5069,7 @@ export class Parser { return; } - if (this._parseOptions.pythonVersion.isGreaterOrEqualTo(pythonVersion)) { + if (PythonVersion.isGreaterOrEqualTo(this._parseOptions.pythonVersion, pythonVersion)) { return; } diff --git a/packages/pyright-internal/src/parser/tokenizer.ts b/packages/pyright-internal/src/parser/tokenizer.ts index af95673940..b573471d19 100644 --- a/packages/pyright-internal/src/parser/tokenizer.ts +++ b/packages/pyright-internal/src/parser/tokenizer.ts @@ -304,7 +304,9 @@ export class Tokenizer { // Insert an implied new line to make parsing easier. if (this._tokens.length === 0 || this._tokens[this._tokens.length - 1].type !== TokenType.NewLine) { - this._tokens.push(NewLineToken.create(this._cs.position, 0, NewLineType.Implied, this._getComments())); + if (this._parenDepth === 0) { + this._tokens.push(NewLineToken.create(this._cs.position, 0, NewLineType.Implied, this._getComments())); + } } // Insert any implied dedent tokens. diff --git a/packages/pyright-internal/src/tests/lsp/languageServerTestUtils.ts b/packages/pyright-internal/src/tests/lsp/languageServerTestUtils.ts index 5f8b3dbbff..174a0c7d38 100644 --- a/packages/pyright-internal/src/tests/lsp/languageServerTestUtils.ts +++ b/packages/pyright-internal/src/tests/lsp/languageServerTestUtils.ts @@ -342,7 +342,7 @@ export async function runPyrightServer( testName: expect.getState().currentTestName ?? 'NoName', code, projectRoots: projectRootsArray.map((p) => (p.includes(':') ? UriEx.parse(p) : UriEx.file(p))), - pythonVersion: pythonVersion.toString(), + pythonVersion: PythonVersion.toString(pythonVersion), backgroundAnalysis, logFile: UriEx.file(path.join(__dirname, `log${process.pid}.txt`)), pid: process.pid.toString(), diff --git a/packages/pyright-internal/src/tests/patternMatching.test.ts b/packages/pyright-internal/src/tests/patternMatching.test.ts index 37cf5be56d..d4401cb1a5 100644 --- a/packages/pyright-internal/src/tests/patternMatching.test.ts +++ b/packages/pyright-internal/src/tests/patternMatching.test.ts @@ -13,5 +13,6 @@ test('assert_never', () => { { code: DiagnosticRule.reportUnnecessaryComparison, line: 16 }, { code: DiagnosticRule.reportUnnecessaryComparison, line: 24 }, ], + unreachableCodes: [{ code: DiagnosticRule.reportUnreachable, line: 25 }], }); }); diff --git a/packages/pyright-internal/src/tests/samples/lambda14.py b/packages/pyright-internal/src/tests/samples/lambda14.py index 6756366ec1..c238d5ae1f 100644 --- a/packages/pyright-internal/src/tests/samples/lambda14.py +++ b/packages/pyright-internal/src/tests/samples/lambda14.py @@ -2,7 +2,7 @@ # context but has a default argument value. lambda1 = lambda x="": x -reveal_type(lambda1, expected_text="(x: str = ...) -> str") +reveal_type(lambda1, expected_text='(x: str = "") -> str') lambda2 = lambda x=None: x -reveal_type(lambda2, expected_text="(x: Unknown | None = ...) -> (Unknown | None)") +reveal_type(lambda2, expected_text="(x: Unknown | None = None) -> (Unknown | None)") diff --git a/packages/pyright-internal/src/tests/samples/paramSpec3.py b/packages/pyright-internal/src/tests/samples/paramSpec3.py index e2e8f2ee8e..b07a9cca48 100644 --- a/packages/pyright-internal/src/tests/samples/paramSpec3.py +++ b/packages/pyright-internal/src/tests/samples/paramSpec3.py @@ -113,7 +113,7 @@ def func8(cb1: Callback1, cb2: Callback2, cb3: Callback3): reveal_type(v1, expected_text="(x: int, /) -> None") v2 = func7(cb1, cb3) - reveal_type(v2, expected_text="(x: int | str, y: int = ...) -> None") + reveal_type(v2, expected_text="(x: int | str, y: int = 3) -> None") def func9(f: Callable[P, object], *args: P.args, **kwargs: P.kwargs) -> object: diff --git a/packages/pyright-internal/src/tests/samples/paramSpec52.py b/packages/pyright-internal/src/tests/samples/paramSpec52.py new file mode 100644 index 0000000000..e73e716142 --- /dev/null +++ b/packages/pyright-internal/src/tests/samples/paramSpec52.py @@ -0,0 +1,20 @@ +# This sample tests an illegal use of a ParamSpec that resulted in +# a crash. + +from typing import Callable, Generic, ParamSpec + +P = ParamSpec("P") + + +class A(Generic[P]): + def __call__(self, a: int, b: int, *args: P.args, **kwargs: P.kwargs) -> None: + ... + + +class B: + # This should generate an error. + x: A[P] + + +# This should generate an error, not crash. +B().x(1) diff --git a/packages/pyright-internal/src/tests/samples/typeGuard1.py b/packages/pyright-internal/src/tests/samples/typeGuard1.py index c37bd33596..5af0dc2797 100644 --- a/packages/pyright-internal/src/tests/samples/typeGuard1.py +++ b/packages/pyright-internal/src/tests/samples/typeGuard1.py @@ -6,6 +6,7 @@ import os from typing import Any, Callable, TypeVar + from typing_extensions import TypeGuard # pyright: ignore[reportMissingModuleSource] _T = TypeVar("_T") @@ -124,3 +125,9 @@ def str_typeguard(val: object) -> TypeGuard[str]: # This should generate an error because TypeGuard is covariant. takes_int_typeguard(str_typeguard) + + +v0 = is_int(int) +v1: bool = v0 +v2: int = v0 +v3 = v0 & v0 diff --git a/packages/pyright-internal/src/tests/samples/typeIs1.py b/packages/pyright-internal/src/tests/samples/typeIs1.py index d9a4cec6e3..d6bedd7e0a 100644 --- a/packages/pyright-internal/src/tests/samples/typeIs1.py +++ b/packages/pyright-internal/src/tests/samples/typeIs1.py @@ -172,3 +172,9 @@ def func10( def func10(v: tuple[int | str, ...], b: bool = True) -> bool: ... + + +v0 = is_int(int) +v1: bool = v0 +v2: int = v0 +v3 = v0 & v0 diff --git a/packages/pyright-internal/src/tests/typeEvaluator4.test.ts b/packages/pyright-internal/src/tests/typeEvaluator4.test.ts index a8e1236e6e..f9dda59c0d 100644 --- a/packages/pyright-internal/src/tests/typeEvaluator4.test.ts +++ b/packages/pyright-internal/src/tests/typeEvaluator4.test.ts @@ -821,3 +821,8 @@ test('ParamSpec51', () => { const results = TestUtils.typeAnalyzeSampleFiles(['paramSpec51.py']); TestUtils.validateResults(results, 0); }); + +test('ParamSpec52', () => { + const results = TestUtils.typeAnalyzeSampleFiles(['paramSpec52.py']); + TestUtils.validateResults(results, 2); +}); diff --git a/packages/pyright-internal/typeshed-fallback/commit.txt b/packages/pyright-internal/typeshed-fallback/commit.txt index dded587d03..0f5926abb1 100644 --- a/packages/pyright-internal/typeshed-fallback/commit.txt +++ b/packages/pyright-internal/typeshed-fallback/commit.txt @@ -1 +1 @@ -7eac47455ae5c9cec6edea0b8496d50299439ae2 +a7ff1be4394cef089dd62090a2e2ad10cc77cfe6 diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/_ast.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/_ast.pyi index d14c6d39a1..5431f31cd2 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/_ast.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/_ast.pyi @@ -753,9 +753,11 @@ class Constant(expr): __match_args__ = ("value", "kind") value: Any # None, str, bytes, bool, int, float, complex, Ellipsis kind: str | None - # Aliases for value, for backwards compatibility - s: Any - n: int | float | complex + if sys.version_info < (3, 14): + # Aliases for value, for backwards compatibility + s: Any + n: int | float | complex + def __init__(self, value: Any, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... class NamedExpr(expr): diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/_collections_abc.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/_collections_abc.pyi index 127488ee38..8b1ac9c7eb 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/_collections_abc.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/_collections_abc.pyi @@ -1,13 +1,12 @@ import sys from abc import abstractmethod from types import MappingProxyType -from typing import ( # noqa: Y022,Y038,Y057 +from typing import ( # noqa: Y022,Y038 AbstractSet as Set, AsyncGenerator as AsyncGenerator, AsyncIterable as AsyncIterable, AsyncIterator as AsyncIterator, Awaitable as Awaitable, - ByteString as ByteString, Callable as Callable, Collection as Collection, Container as Container, @@ -59,8 +58,12 @@ __all__ = [ "ValuesView", "Sequence", "MutableSequence", - "ByteString", ] +if sys.version_info < (3, 14): + from typing import ByteString as ByteString # noqa: Y057 + + __all__ += ["ByteString"] + if sys.version_info >= (3, 12): __all__ += ["Buffer"] diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/_ctypes.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/_ctypes.pyi index c1fb86193b..5313195a0b 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/_ctypes.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/_ctypes.pyi @@ -51,8 +51,8 @@ class _CDataMeta(type): # By default mypy complains about the following two methods, because strictly speaking cls # might not be a Type[_CT]. However this can never actually happen, because the only class that # uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here. - def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] - def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] + def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] + def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] class _CData(metaclass=_CDataMeta): _b_base_: int diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/_operator.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/_operator.pyi index 69ee563b5c..1b0083f4e2 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/_operator.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/_operator.pyi @@ -2,7 +2,7 @@ import sys from _typeshed import SupportsGetItem from collections.abc import Callable, Container, Iterable, MutableMapping, MutableSequence, Sequence from typing import Any, AnyStr, Generic, Protocol, SupportsAbs, SupportsIndex, TypeVar, final, overload -from typing_extensions import ParamSpec, TypeAlias, TypeVarTuple, Unpack +from typing_extensions import ParamSpec, TypeAlias, TypeIs, TypeVarTuple, Unpack _R = TypeVar("_R") _T = TypeVar("_T") @@ -145,3 +145,7 @@ 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]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/_stat.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/_stat.pyi index 903571a64b..7129a282b5 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/_stat.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/_stat.pyi @@ -28,9 +28,9 @@ 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: int -S_IFPORT: int -S_IFWHT: int +S_IFDOOR: Final[int] +S_IFPORT: Final[int] +S_IFWHT: Final[int] S_ISUID: Final = 0o4000 S_ISGID: Final = 0o2000 @@ -79,9 +79,9 @@ def S_ISWHT(mode: int, /) -> bool: ... def filemode(mode: int, /) -> str: ... if sys.platform == "win32": - IO_REPARSE_TAG_SYMLINK: int - IO_REPARSE_TAG_MOUNT_POINT: int - IO_REPARSE_TAG_APPEXECLINK: int + 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 diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/_tkinter.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/_tkinter.pyi index a7293054d2..63b1e7ca7c 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/_tkinter.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/_tkinter.pyi @@ -106,8 +106,8 @@ EXCEPTION: Final = 8 READABLE: Final = 2 WRITABLE: Final = 4 -TCL_VERSION: str -TK_VERSION: str +TCL_VERSION: Final[str] +TK_VERSION: Final[str] @final class TkttType: diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/argparse.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/argparse.pyi index 66fa4e1529..2526322ac8 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/argparse.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/argparse.pyi @@ -357,7 +357,17 @@ class Action(_AttributeHolder): if sys.version_info >= (3, 12): class BooleanOptionalAction(Action): - if sys.version_info >= (3, 13): + if sys.version_info >= (3, 14): + def __init__( + self, + option_strings: Sequence[str], + dest: str, + default: bool | None = None, + required: bool = False, + help: str | None = None, + deprecated: bool = False, + ) -> None: ... + elif sys.version_info >= (3, 13): @overload def __init__( self, diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/ast.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/ast.pyi index 90ede461fe..80049cff4c 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/ast.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/ast.pyi @@ -10,27 +10,28 @@ class _ABC(type): if sys.version_info >= (3, 9): def __init__(cls, *args: Unused) -> None: ... -@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") -class Num(Constant, metaclass=_ABC): - value: int | float | complex +if sys.version_info < (3, 14): + @deprecated("Replaced by ast.Constant; removed in Python 3.14") + class Num(Constant, metaclass=_ABC): + value: int | float | complex -@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") -class Str(Constant, metaclass=_ABC): - value: str - # Aliases for value, for backwards compatibility - s: str + @deprecated("Replaced by ast.Constant; removed in Python 3.14") + class Str(Constant, metaclass=_ABC): + value: str + # Aliases for value, for backwards compatibility + s: str -@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") -class Bytes(Constant, metaclass=_ABC): - value: bytes - # Aliases for value, for backwards compatibility - s: bytes + @deprecated("Replaced by ast.Constant; removed in Python 3.14") + class Bytes(Constant, metaclass=_ABC): + value: bytes + # Aliases for value, for backwards compatibility + s: bytes -@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") -class NameConstant(Constant, metaclass=_ABC): ... + @deprecated("Replaced by ast.Constant; removed in Python 3.14") + class NameConstant(Constant, metaclass=_ABC): ... -@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14") -class Ellipsis(Constant, metaclass=_ABC): ... + @deprecated("Replaced by ast.Constant; removed in Python 3.14") + class Ellipsis(Constant, metaclass=_ABC): ... if sys.version_info >= (3, 9): class slice(AST): ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/builtins.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/builtins.pyi index dc821de1d3..95335d241e 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/builtins.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/builtins.pyi @@ -33,7 +33,8 @@ from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from types import CellType, CodeType, TracebackType -# mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping} are imported from collections.abc in builtins.pyi +# mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping} +# are imported from collections.abc in builtins.pyi from typing import ( # noqa: Y022 IO, Any, @@ -1084,7 +1085,8 @@ class dict(MutableMapping[_KT, _VT]): def keys(self) -> dict_keys[_KT, _VT]: ... def values(self) -> dict_values[_KT, _VT]: ... def items(self) -> dict_items[_KT, _VT]: ... - # Signature of `dict.fromkeys` should be kept identical to `fromkeys` methods of `OrderedDict`/`ChainMap`/`UserDict` in `collections` + # Signature of `dict.fromkeys` should be kept identical to + # `fromkeys` methods of `OrderedDict`/`ChainMap`/`UserDict` in `collections` # TODO: the true signature of `dict.fromkeys` is not expressible in the current type system. # See #3800 & https://github.com/python/typing/issues/548#issuecomment-683336963. @classmethod diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/cmd.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/cmd.pyi index 0733857433..6e84133572 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/cmd.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/cmd.pyi @@ -1,10 +1,11 @@ from collections.abc import Callable from typing import IO, Any, Final +from typing_extensions import LiteralString __all__ = ["Cmd"] PROMPT: Final = "(Cmd) " -IDENTCHARS: str # Too big to be `Literal` +IDENTCHARS: Final[LiteralString] # Too big to be `Literal` class Cmd: prompt: str diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/collections/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/collections/__init__.pyi index 71e3c564dd..9097287cea 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/collections/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/collections/__init__.pyi @@ -475,7 +475,8 @@ class ChainMap(MutableMapping[_KT, _VT]): def pop(self, key: _KT, default: _T) -> _VT | _T: ... def copy(self) -> Self: ... __copy__ = copy - # All arguments to `fromkeys` are passed to `dict.fromkeys` at runtime, so the signature should be kept in line with `dict.fromkeys`. + # All arguments to `fromkeys` are passed to `dict.fromkeys` at runtime, + # so the signature should be kept in line with `dict.fromkeys`. @classmethod @overload def fromkeys(cls, iterable: Iterable[_T]) -> ChainMap[_T, Any | None]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/contextlib.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/contextlib.pyi index 29ac7cde56..daf218d5a1 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/contextlib.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/contextlib.pyi @@ -55,6 +55,7 @@ class AbstractAsyncContextManager(Protocol[_T_co, _ExitT_co]): ) -> _ExitT_co: ... class ContextDecorator: + def _recreate_cm(self) -> Self: ... def __call__(self, func: _F) -> _F: ... class _GeneratorContextManager(AbstractContextManager[_T_co, bool | None], ContextDecorator): @@ -80,6 +81,7 @@ if sys.version_info >= (3, 10): _AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]]) class AsyncContextDecorator: + def _recreate_cm(self) -> Self: ... def __call__(self, func: _AF) -> _AF: ... class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co, bool | None], AsyncContextDecorator): diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/crypt.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/crypt.pyi index 1ad0a384ea..2940038592 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/crypt.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/crypt.pyi @@ -1,12 +1,13 @@ import sys +from typing import Final if sys.platform != "win32": class _Method: ... - METHOD_CRYPT: _Method - METHOD_MD5: _Method - METHOD_SHA256: _Method - METHOD_SHA512: _Method - METHOD_BLOWFISH: _Method + METHOD_CRYPT: Final[_Method] + METHOD_MD5: Final[_Method] + METHOD_SHA256: Final[_Method] + METHOD_SHA512: Final[_Method] + METHOD_BLOWFISH: Final[_Method] methods: list[_Method] def mksalt(method: _Method | None = None, *, rounds: int | None = None) -> str: ... def crypt(word: str, salt: str | _Method | None = None) -> str: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/dataclasses.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/dataclasses.pyi index 626608e8a5..f93797583a 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/dataclasses.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/dataclasses.pyi @@ -5,7 +5,7 @@ from _typeshed import DataclassInstance from builtins import type as Type # alias to avoid name clashes with fields named "type" from collections.abc import Callable, Iterable, Mapping from typing import Any, Generic, Literal, Protocol, TypeVar, overload -from typing_extensions import TypeAlias, TypeIs +from typing_extensions import Never, TypeAlias, TypeIs if sys.version_info >= (3, 9): from types import GenericAlias @@ -213,6 +213,10 @@ else: ) -> Any: ... def fields(class_or_instance: DataclassInstance | type[DataclassInstance]) -> tuple[Field[Any], ...]: ... + +# HACK: `obj: Never` typing matches if object argument is using `Any` type. +@overload +def is_dataclass(obj: Never) -> TypeIs[DataclassInstance | type[DataclassInstance]]: ... # type: ignore[narrowed-type-not-subtype] # pyright: ignore[reportGeneralTypeIssues] @overload def is_dataclass(obj: type) -> TypeIs[type[DataclassInstance]]: ... @overload diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/datetime.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/datetime.pyi index 38d5ac4c08..e8a4efdc61 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/datetime.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/datetime.pyi @@ -265,12 +265,12 @@ class datetime(date): def fromtimestamp(cls, timestamp: float, /, tz: _TzInfo | None = ...) -> Self: ... @classmethod - @deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.UTC)") + @deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.timezone.utc)") def utcfromtimestamp(cls, t: float, /) -> Self: ... @classmethod def now(cls, tz: _TzInfo | None = None) -> Self: ... @classmethod - @deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.UTC)") + @deprecated("Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)") def utcnow(cls) -> Self: ... @classmethod def combine(cls, date: _Date, time: _Time, tzinfo: _TzInfo | None = ...) -> Self: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/cmd.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/cmd.pyi index ca4fb32653..1f3f31c9c4 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/cmd.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/cmd.pyi @@ -1,6 +1,26 @@ from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused from abc import abstractmethod from collections.abc import Callable, Iterable +from distutils.command.bdist import bdist +from distutils.command.bdist_dumb import bdist_dumb +from distutils.command.bdist_rpm import bdist_rpm +from distutils.command.build import build +from distutils.command.build_clib import build_clib +from distutils.command.build_ext import build_ext +from distutils.command.build_py import build_py +from distutils.command.build_scripts import build_scripts +from distutils.command.check import check +from distutils.command.clean import clean +from distutils.command.config import config +from distutils.command.install import install +from distutils.command.install_data import install_data +from distutils.command.install_egg_info import install_egg_info +from distutils.command.install_headers import install_headers +from distutils.command.install_lib import install_lib +from distutils.command.install_scripts import install_scripts +from distutils.command.register import register +from distutils.command.sdist import sdist +from distutils.command.upload import upload from distutils.dist import Distribution from distutils.file_util import _BytesPathT, _StrPathT from typing import Any, ClassVar, Literal, TypeVar, overload @@ -28,8 +48,108 @@ class Command: def ensure_dirname(self, option: str) -> None: ... def get_command_name(self) -> str: ... def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ... + # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. + @overload + def get_finalized_command(self, command: Literal["bdist"], create: bool | Literal[0, 1] = 1) -> bdist: ... + @overload + def get_finalized_command(self, command: Literal["bdist_dumb"], create: bool | Literal[0, 1] = 1) -> bdist_dumb: ... + @overload + def get_finalized_command(self, command: Literal["bdist_rpm"], create: bool | Literal[0, 1] = 1) -> bdist_rpm: ... + @overload + def get_finalized_command(self, command: Literal["build"], create: bool | Literal[0, 1] = 1) -> build: ... + @overload + def get_finalized_command(self, command: Literal["build_clib"], create: bool | Literal[0, 1] = 1) -> build_clib: ... + @overload + def get_finalized_command(self, command: Literal["build_ext"], create: bool | Literal[0, 1] = 1) -> build_ext: ... + @overload + def get_finalized_command(self, command: Literal["build_py"], create: bool | Literal[0, 1] = 1) -> build_py: ... + @overload + def get_finalized_command(self, command: Literal["build_scripts"], create: bool | Literal[0, 1] = 1) -> build_scripts: ... + @overload + def get_finalized_command(self, command: Literal["check"], create: bool | Literal[0, 1] = 1) -> check: ... + @overload + def get_finalized_command(self, command: Literal["clean"], create: bool | Literal[0, 1] = 1) -> clean: ... + @overload + def get_finalized_command(self, command: Literal["config"], create: bool | Literal[0, 1] = 1) -> config: ... + @overload + def get_finalized_command(self, command: Literal["install"], create: bool | Literal[0, 1] = 1) -> install: ... + @overload + def get_finalized_command(self, command: Literal["install_data"], create: bool | Literal[0, 1] = 1) -> install_data: ... + @overload + def get_finalized_command( + self, command: Literal["install_egg_info"], create: bool | Literal[0, 1] = 1 + ) -> install_egg_info: ... + @overload + def get_finalized_command(self, command: Literal["install_headers"], create: bool | Literal[0, 1] = 1) -> install_headers: ... + @overload + def get_finalized_command(self, command: Literal["install_lib"], create: bool | Literal[0, 1] = 1) -> install_lib: ... + @overload + def get_finalized_command(self, command: Literal["install_scripts"], create: bool | Literal[0, 1] = 1) -> install_scripts: ... + @overload + def get_finalized_command(self, command: Literal["register"], create: bool | Literal[0, 1] = 1) -> register: ... + @overload + def get_finalized_command(self, command: Literal["sdist"], create: bool | Literal[0, 1] = 1) -> sdist: ... + @overload + def get_finalized_command(self, command: Literal["upload"], create: bool | Literal[0, 1] = 1) -> upload: ... + @overload def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ... @overload + def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist: ... + @overload + def reinitialize_command( + self, command: Literal["bdist_dumb"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> bdist_dumb: ... + @overload + def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist_rpm: ... + @overload + def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build: ... + @overload + def reinitialize_command( + self, command: Literal["build_clib"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> build_clib: ... + @overload + def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_ext: ... + @overload + def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_py: ... + @overload + def reinitialize_command( + self, command: Literal["build_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> build_scripts: ... + @overload + def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool | Literal[0, 1] = 0) -> check: ... + @overload + def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool | Literal[0, 1] = 0) -> clean: ... + @overload + def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool | Literal[0, 1] = 0) -> config: ... + @overload + def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool | Literal[0, 1] = 0) -> install: ... + @overload + def reinitialize_command( + self, command: Literal["install_data"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_data: ... + @overload + def reinitialize_command( + self, command: Literal["install_egg_info"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_egg_info: ... + @overload + def reinitialize_command( + self, command: Literal["install_headers"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_headers: ... + @overload + def reinitialize_command( + self, command: Literal["install_lib"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_lib: ... + @overload + def reinitialize_command( + self, command: Literal["install_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_scripts: ... + @overload + def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool | Literal[0, 1] = 0) -> register: ... + @overload + def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> sdist: ... + @overload + def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool | Literal[0, 1] = 0) -> upload: ... + @overload def reinitialize_command(self, command: str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ... @overload def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool | Literal[0, 1] = 0) -> _CommandT: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/__init__.pyi index e69de29bb2..4d7372858a 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/__init__.pyi @@ -0,0 +1,48 @@ +import sys + +from . import ( + bdist, + bdist_dumb, + bdist_rpm, + build, + build_clib, + build_ext, + build_py, + build_scripts, + check, + clean, + install, + install_data, + install_headers, + install_lib, + install_scripts, + register, + sdist, + upload, +) + +__all__ = [ + "build", + "build_py", + "build_ext", + "build_clib", + "build_scripts", + "clean", + "install", + "install_lib", + "install_headers", + "install_scripts", + "install_data", + "sdist", + "register", + "bdist", + "bdist_dumb", + "bdist_rpm", + "check", + "upload", +] + +if sys.version_info < (3, 10): + from . import bdist_wininst + + __all__ += ["bdist_wininst"] diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/check.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/check.pyi index c67e4cbfdf..e69627d20c 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/check.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/check.pyi @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Literal +from typing import Any, ClassVar, Final, Literal from typing_extensions import TypeAlias from ..cmd import Command @@ -22,7 +22,7 @@ class SilentReporter(_Reporter): ) -> None: ... def system_message(self, level, message, *children, **kwargs): ... -HAS_DOCUTILS: bool +HAS_DOCUTILS: Final[bool] class check(Command): description: str diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/config.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/config.pyi index 2f528c2c29..b0910091d5 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/config.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/config.pyi @@ -1,12 +1,12 @@ from _typeshed import StrOrBytesPath from collections.abc import Sequence from re import Pattern -from typing import Any, ClassVar, Literal +from typing import Any, ClassVar, Final, Literal from ..ccompiler import CCompiler from ..cmd import Command -LANG_EXT: dict[str, str] +LANG_EXT: Final[dict[str, str]] class config(Command): description: str diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/install.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/install.pyi index b0a5a82fc3..24a4eff2fb 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/install.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/install.pyi @@ -1,11 +1,16 @@ +import sys from collections.abc import Callable -from typing import Any, ClassVar +from typing import Any, ClassVar, Final, Literal from ..cmd import Command -HAS_USER_SITE: bool -SCHEME_KEYS: tuple[str, ...] -INSTALL_SCHEMES: dict[str, dict[Any, Any]] +HAS_USER_SITE: Final[bool] + +SCHEME_KEYS: Final[tuple[Literal["purelib"], Literal["platlib"], Literal["headers"], Literal["scripts"], Literal["data"]]] +INSTALL_SCHEMES: Final[dict[str, dict[str, str]]] + +if sys.version_info < (3, 10): + WINDOWS_SCHEME: Final[dict[str, str]] class install(Command): description: str diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/install_lib.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/install_lib.pyi index 718d082b7b..149ecae897 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/install_lib.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/command/install_lib.pyi @@ -1,8 +1,8 @@ -from typing import Any, ClassVar +from typing import Any, ClassVar, Final from ..cmd import Command -PYTHON_SOURCE_EXTENSION: str +PYTHON_SOURCE_EXTENSION: Final = ".py" class install_lib(Command): description: str diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/core.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/core.pyi index f3c434df0b..a4d21f8ddd 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/core.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/core.pyi @@ -3,9 +3,9 @@ from collections.abc import Mapping from distutils.cmd import Command as Command from distutils.dist import Distribution as Distribution from distutils.extension import Extension as Extension -from typing import Any, Literal +from typing import Any, Final, Literal -USAGE: str +USAGE: Final[str] def gen_usage(script_name: StrOrBytesPath) -> str: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/cygwinccompiler.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/cygwinccompiler.pyi index 5f2e623eef..80924d63e4 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/cygwinccompiler.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/cygwinccompiler.pyi @@ -1,20 +1,20 @@ from distutils.unixccompiler import UnixCCompiler from distutils.version import LooseVersion from re import Pattern -from typing import Literal +from typing import Final, Literal def get_msvcr() -> list[str] | None: ... class CygwinCCompiler(UnixCCompiler): ... class Mingw32CCompiler(CygwinCCompiler): ... -CONFIG_H_OK: str -CONFIG_H_NOTOK: str -CONFIG_H_UNCERTAIN: str +CONFIG_H_OK: Final = "ok" +CONFIG_H_NOTOK: Final = "not ok" +CONFIG_H_UNCERTAIN: Final = "uncertain" def check_config_h() -> tuple[Literal["ok", "not ok", "uncertain"], str]: ... -RE_VERSION: Pattern[bytes] +RE_VERSION: Final[Pattern[bytes]] def get_versions() -> tuple[LooseVersion | None, ...]: ... def is_cygwingcc() -> bool: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/debug.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/debug.pyi index 11f28a8bc8..30095883b0 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/debug.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/debug.pyi @@ -1 +1,3 @@ -DEBUG: bool | None +from typing import Final + +DEBUG: Final[str | None] diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/dist.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/dist.pyi index 21ddbc4259..e32fd70f7b 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/dist.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/dist.pyi @@ -1,6 +1,26 @@ from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite from collections.abc import Iterable, MutableMapping from distutils.cmd import Command +from distutils.command.bdist import bdist +from distutils.command.bdist_dumb import bdist_dumb +from distutils.command.bdist_rpm import bdist_rpm +from distutils.command.build import build +from distutils.command.build_clib import build_clib +from distutils.command.build_ext import build_ext +from distutils.command.build_py import build_py +from distutils.command.build_scripts import build_scripts +from distutils.command.check import check +from distutils.command.clean import clean +from distutils.command.config import config +from distutils.command.install import install +from distutils.command.install_data import install_data +from distutils.command.install_egg_info import install_egg_info +from distutils.command.install_headers import install_headers +from distutils.command.install_lib import install_lib +from distutils.command.install_scripts import install_scripts +from distutils.command.register import register +from distutils.command.sdist import sdist +from distutils.command.upload import upload from re import Pattern from typing import IO, ClassVar, Literal, TypeVar, overload from typing_extensions import TypeAlias @@ -63,10 +83,6 @@ class Distribution: def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ... def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ... - @overload - def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ... - @overload - def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ... global_options: ClassVar[_OptionsList] common_usage: ClassVar[str] display_options: ClassVar[_OptionsList] @@ -108,8 +124,137 @@ class Distribution: def print_commands(self) -> None: ... def get_command_list(self): ... def get_command_packages(self): ... + # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. + @overload + def get_command_obj(self, command: Literal["bdist"], create: Literal[1, True] = 1) -> bdist: ... + @overload + def get_command_obj(self, command: Literal["bdist_dumb"], create: Literal[1, True] = 1) -> bdist_dumb: ... + @overload + def get_command_obj(self, command: Literal["bdist_rpm"], create: Literal[1, True] = 1) -> bdist_rpm: ... + @overload + def get_command_obj(self, command: Literal["build"], create: Literal[1, True] = 1) -> build: ... + @overload + def get_command_obj(self, command: Literal["build_clib"], create: Literal[1, True] = 1) -> build_clib: ... + @overload + def get_command_obj(self, command: Literal["build_ext"], create: Literal[1, True] = 1) -> build_ext: ... + @overload + def get_command_obj(self, command: Literal["build_py"], create: Literal[1, True] = 1) -> build_py: ... + @overload + def get_command_obj(self, command: Literal["build_scripts"], create: Literal[1, True] = 1) -> build_scripts: ... + @overload + def get_command_obj(self, command: Literal["check"], create: Literal[1, True] = 1) -> check: ... + @overload + def get_command_obj(self, command: Literal["clean"], create: Literal[1, True] = 1) -> clean: ... + @overload + def get_command_obj(self, command: Literal["config"], create: Literal[1, True] = 1) -> config: ... + @overload + def get_command_obj(self, command: Literal["install"], create: Literal[1, True] = 1) -> install: ... + @overload + def get_command_obj(self, command: Literal["install_data"], create: Literal[1, True] = 1) -> install_data: ... + @overload + def get_command_obj(self, command: Literal["install_egg_info"], create: Literal[1, True] = 1) -> install_egg_info: ... + @overload + def get_command_obj(self, command: Literal["install_headers"], create: Literal[1, True] = 1) -> install_headers: ... + @overload + def get_command_obj(self, command: Literal["install_lib"], create: Literal[1, True] = 1) -> install_lib: ... + @overload + def get_command_obj(self, command: Literal["install_scripts"], create: Literal[1, True] = 1) -> install_scripts: ... + @overload + def get_command_obj(self, command: Literal["register"], create: Literal[1, True] = 1) -> register: ... + @overload + def get_command_obj(self, command: Literal["sdist"], create: Literal[1, True] = 1) -> sdist: ... + @overload + def get_command_obj(self, command: Literal["upload"], create: Literal[1, True] = 1) -> upload: ... + @overload + def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ... + # Not replicating the overloads for "Command | None", user may use "isinstance" + @overload + def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ... + @overload + def get_command_class(self, command: Literal["bdist"]) -> type[bdist]: ... + @overload + def get_command_class(self, command: Literal["bdist_dumb"]) -> type[bdist_dumb]: ... + @overload + def get_command_class(self, command: Literal["bdist_rpm"]) -> type[bdist_rpm]: ... + @overload + def get_command_class(self, command: Literal["build"]) -> type[build]: ... + @overload + def get_command_class(self, command: Literal["build_clib"]) -> type[build_clib]: ... + @overload + def get_command_class(self, command: Literal["build_ext"]) -> type[build_ext]: ... + @overload + def get_command_class(self, command: Literal["build_py"]) -> type[build_py]: ... + @overload + def get_command_class(self, command: Literal["build_scripts"]) -> type[build_scripts]: ... + @overload + def get_command_class(self, command: Literal["check"]) -> type[check]: ... + @overload + def get_command_class(self, command: Literal["clean"]) -> type[clean]: ... + @overload + def get_command_class(self, command: Literal["config"]) -> type[config]: ... + @overload + def get_command_class(self, command: Literal["install"]) -> type[install]: ... + @overload + def get_command_class(self, command: Literal["install_data"]) -> type[install_data]: ... + @overload + def get_command_class(self, command: Literal["install_egg_info"]) -> type[install_egg_info]: ... + @overload + def get_command_class(self, command: Literal["install_headers"]) -> type[install_headers]: ... + @overload + def get_command_class(self, command: Literal["install_lib"]) -> type[install_lib]: ... + @overload + def get_command_class(self, command: Literal["install_scripts"]) -> type[install_scripts]: ... + @overload + def get_command_class(self, command: Literal["register"]) -> type[register]: ... + @overload + def get_command_class(self, command: Literal["sdist"]) -> type[sdist]: ... + @overload + def get_command_class(self, command: Literal["upload"]) -> type[upload]: ... + @overload def get_command_class(self, command: str) -> type[Command]: ... @overload + def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool = False) -> bdist: ... + @overload + def reinitialize_command(self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False) -> bdist_dumb: ... + @overload + def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False) -> bdist_rpm: ... + @overload + def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool = False) -> build: ... + @overload + def reinitialize_command(self, command: Literal["build_clib"], reinit_subcommands: bool = False) -> build_clib: ... + @overload + def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool = False) -> build_ext: ... + @overload + def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool = False) -> build_py: ... + @overload + def reinitialize_command(self, command: Literal["build_scripts"], reinit_subcommands: bool = False) -> build_scripts: ... + @overload + def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool = False) -> check: ... + @overload + def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool = False) -> clean: ... + @overload + def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool = False) -> config: ... + @overload + def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool = False) -> install: ... + @overload + def reinitialize_command(self, command: Literal["install_data"], reinit_subcommands: bool = False) -> install_data: ... + @overload + def reinitialize_command( + self, command: Literal["install_egg_info"], reinit_subcommands: bool = False + ) -> install_egg_info: ... + @overload + def reinitialize_command(self, command: Literal["install_headers"], reinit_subcommands: bool = False) -> install_headers: ... + @overload + def reinitialize_command(self, command: Literal["install_lib"], reinit_subcommands: bool = False) -> install_lib: ... + @overload + def reinitialize_command(self, command: Literal["install_scripts"], reinit_subcommands: bool = False) -> install_scripts: ... + @overload + def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool = False) -> register: ... + @overload + def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool = False) -> sdist: ... + @overload + def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool = False) -> upload: ... + @overload def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... @overload def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/fancy_getopt.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/fancy_getopt.pyi index f9916d4511..c4d37419ed 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/fancy_getopt.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/fancy_getopt.pyi @@ -1,15 +1,15 @@ from collections.abc import Iterable, Mapping from re import Pattern -from typing import Any, overload +from typing import Any, Final, overload from typing_extensions import TypeAlias _Option: TypeAlias = tuple[str, str | None, str] _GR: TypeAlias = tuple[list[str], OptionDummy] -longopt_pat: str -longopt_re: Pattern[str] -neg_alias_re: Pattern[str] -longopt_xlate: dict[int, int] +longopt_pat: Final = r"[a-zA-Z](?:[a-zA-Z0-9-]*)" +longopt_re: Final[Pattern[str]] +neg_alias_re: Final[Pattern[str]] +longopt_xlate: Final[dict[int, int]] class FancyGetopt: def __init__(self, option_table: list[_Option] | None = None) -> None: ... @@ -25,7 +25,7 @@ def fancy_getopt( options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None ) -> list[str] | _GR: ... -WS_TRANS: dict[int, str] +WS_TRANS: Final[dict[int, str]] def wrap_text(text: str, width: int) -> list[str]: ... def translate_longopt(opt: str) -> str: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/log.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/log.pyi index 14ed8d8aef..0ea135c283 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/log.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/log.pyi @@ -1,10 +1,10 @@ -from typing import Any +from typing import Any, Final -DEBUG: int -INFO: int -WARN: int -ERROR: int -FATAL: int +DEBUG: Final = 1 +INFO: Final = 2 +WARN: Final = 3 +ERROR: Final = 4 +FATAL: Final = 5 class Log: def __init__(self, threshold: int = 3) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/sysconfig.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/sysconfig.pyi index da72e3275f..4a9c45eb56 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/distutils/sysconfig.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/distutils/sysconfig.pyi @@ -1,15 +1,15 @@ import sys from collections.abc import Mapping from distutils.ccompiler import CCompiler -from typing import Literal, overload +from typing import Final, Literal, overload from typing_extensions import deprecated -PREFIX: str -EXEC_PREFIX: str -BASE_PREFIX: str -BASE_EXEC_PREFIX: str -project_base: str -python_build: bool +PREFIX: Final[str] +EXEC_PREFIX: Final[str] +BASE_PREFIX: Final[str] +BASE_EXEC_PREFIX: Final[str] +project_base: Final[str] +python_build: Final[bool] def expand_makefile_vars(s: str, vars: Mapping[str, str]) -> str: ... @overload diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/email/message.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/email/message.pyi index 4032bc6136..e5b46fbf8e 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/email/message.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/email/message.pyi @@ -50,7 +50,8 @@ class Message(Generic[_HeaderT, _HeaderParamT]): def get_payload(self, i: None = None, *, decode: Literal[True]) -> _EncodedPayloadType | Any: ... @overload # not multipart, IDEM but w/o kwarg def get_payload(self, i: None, decode: Literal[True]) -> _EncodedPayloadType | Any: ... - # If `charset=None` and payload supports both `encode` AND `decode`, then an invalid payload could be passed, but this is unlikely + # If `charset=None` and payload supports both `encode` AND `decode`, + # then an invalid payload could be passed, but this is unlikely # Not[_SupportsEncodeToPayload] @overload def set_payload( diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/email/utils.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/email/utils.pyi index 2724dbf6ec..9dab22c18f 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/email/utils.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/email/utils.pyi @@ -66,7 +66,10 @@ def mktime_tz(data: _PDTZ) -> int: ... def formatdate(timeval: float | None = None, localtime: bool = False, usegmt: bool = False) -> str: ... def format_datetime(dt: datetime.datetime, usegmt: bool = False) -> str: ... -if sys.version_info >= (3, 12): +if sys.version_info >= (3, 14): + def localtime(dt: datetime.datetime | None = None) -> datetime.datetime: ... + +elif sys.version_info >= (3, 12): @overload def localtime(dt: datetime.datetime | None = None) -> datetime.datetime: ... @overload diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/filecmp.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/filecmp.pyi index dfec2da723..cb7b945960 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/filecmp.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/filecmp.pyi @@ -17,13 +17,24 @@ def cmpfiles( ) -> tuple[list[AnyStr], list[AnyStr], list[AnyStr]]: ... class dircmp(Generic[AnyStr]): - def __init__( - self, - a: GenericPath[AnyStr], - b: GenericPath[AnyStr], - ignore: Sequence[AnyStr] | None = None, - hide: Sequence[AnyStr] | None = None, - ) -> None: ... + if sys.version_info >= (3, 13): + def __init__( + self, + a: GenericPath[AnyStr], + b: GenericPath[AnyStr], + ignore: Sequence[AnyStr] | None = None, + hide: Sequence[AnyStr] | None = None, + *, + shallow: bool = True, + ) -> None: ... + else: + def __init__( + self, + a: GenericPath[AnyStr], + b: GenericPath[AnyStr], + ignore: Sequence[AnyStr] | None = None, + hide: Sequence[AnyStr] | None = None, + ) -> None: ... left: AnyStr right: AnyStr hide: Sequence[AnyStr] diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/ftplib.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/ftplib.pyi index 1b96e0d504..3693d7c52a 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/ftplib.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/ftplib.pyi @@ -86,7 +86,7 @@ class FTP: def makeport(self) -> socket: ... def makepasv(self) -> tuple[str, int]: ... def login(self, user: str = "", passwd: str = "", acct: str = "") -> str: ... - # In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers. + # In practice, `rest` can actually be anything whose str() is an integer sequence, so to make it simple we allow integers def ntransfercmd(self, cmd: str, rest: int | str | None = None) -> tuple[socket, int | None]: ... def transfercmd(self, cmd: str, rest: int | str | None = None) -> socket: ... def retrbinary( diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/json/encoder.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/json/encoder.pyi index 473398a60b..aa4a3bdf61 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/json/encoder.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/json/encoder.pyi @@ -1,12 +1,12 @@ from collections.abc import Callable, Iterator from re import Pattern -from typing import Any +from typing import Any, Final -ESCAPE: Pattern[str] -ESCAPE_ASCII: Pattern[str] -HAS_UTF8: Pattern[bytes] -ESCAPE_DCT: dict[str, str] -INFINITY: float +ESCAPE: Final[Pattern[str]] +ESCAPE_ASCII: Final[Pattern[str]] +HAS_UTF8: Final[Pattern[bytes]] +ESCAPE_DCT: Final[dict[str, str]] +INFINITY: Final[float] def py_encode_basestring(s: str) -> str: ... # undocumented def py_encode_basestring_ascii(s: str) -> str: ... # undocumented diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/logging/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/logging/__init__.pyi index e6e6e8f645..9a4827a8f6 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/logging/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/logging/__init__.pyi @@ -55,10 +55,9 @@ __all__ = [ "setLogRecordFactory", "lastResort", "raiseExceptions", + "warn", ] -if sys.version_info < (3, 13): - __all__ += ["warn"] if sys.version_info >= (3, 11): __all__ += ["getLevelNamesMapping"] if sys.version_info >= (3, 12): @@ -157,17 +156,16 @@ class Logger(Filterer): stacklevel: int = 1, extra: Mapping[str, object] | None = None, ) -> None: ... - if sys.version_info < (3, 13): - def warn( - self, - msg: object, - *args: object, - exc_info: _ExcInfoType = None, - stack_info: bool = False, - stacklevel: int = 1, - extra: Mapping[str, object] | None = None, - ) -> None: ... - + @deprecated("Deprecated; use warning() instead.") + def warn( + self, + msg: object, + *args: object, + exc_info: _ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + ) -> None: ... def error( self, msg: object, @@ -412,18 +410,17 @@ class LoggerAdapter(Generic[_L]): extra: Mapping[str, object] | None = None, **kwargs: object, ) -> None: ... - if sys.version_info < (3, 13): - def warn( - self, - msg: object, - *args: object, - exc_info: _ExcInfoType = None, - stack_info: bool = False, - stacklevel: int = 1, - extra: Mapping[str, object] | None = None, - **kwargs: object, - ) -> None: ... - + @deprecated("Deprecated; use warning() instead.") + def warn( + self, + msg: object, + *args: object, + exc_info: _ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, + **kwargs: object, + ) -> None: ... def error( self, msg: object, @@ -523,17 +520,15 @@ def warning( stacklevel: int = 1, extra: Mapping[str, object] | None = None, ) -> None: ... - -if sys.version_info < (3, 13): - def warn( - msg: object, - *args: object, - exc_info: _ExcInfoType = None, - stack_info: bool = False, - stacklevel: int = 1, - extra: Mapping[str, object] | None = None, - ) -> None: ... - +@deprecated("Deprecated; use warning() instead.") +def warn( + msg: object, + *args: object, + exc_info: _ExcInfoType = None, + stack_info: bool = False, + stacklevel: int = 1, + extra: Mapping[str, object] | None = None, +) -> None: ... def error( msg: object, *args: object, diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/operator.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/operator.pyi index a0e5df7977..1a817f00f3 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/operator.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/operator.pyi @@ -61,6 +61,9 @@ __all__ = [ if sys.version_info >= (3, 11): __all__ += ["call"] +if sys.version_info >= (3, 14): + __all__ += ["is_none", "is_not_none"] + __lt__ = lt __le__ = le __eq__ = eq diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/os/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/os/__init__.pyi index e2d272cb41..700e0e9df3 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/os/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/os/__init__.pyi @@ -365,7 +365,9 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo if sys.version_info >= (3, 12) and sys.platform == "win32": @property @deprecated( - "Use st_birthtime instead to retrieve the file creation time. In the future, this property will contain the last metadata change time." + """\ +Use st_birthtime instead to retrieve the file creation time. \ +In the future, this property will contain the last metadata change time.""" ) def st_ctime(self) -> float: ... else: diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/pathlib.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/pathlib.pyi index fd05c937d4..bdca375f62 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/pathlib.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/pathlib.pyi @@ -159,6 +159,20 @@ class Path(PurePath): def lchmod(self, mode: int) -> None: ... def lstat(self) -> stat_result: ... def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ... + + if sys.version_info >= (3, 14): + def copy(self, target: StrPath, *, follow_symlinks: bool = True, preserve_metadata: bool = False) -> None: ... + def copytree( + self, + target: StrPath, + *, + follow_symlinks: bool = True, + preserve_metadata: bool = False, + dirs_exist_ok: bool = False, + ignore: Callable[[Self], bool] | None = None, + on_error: Callable[[OSError], object] | None = None, + ) -> None: ... + # Adapted from builtins.open # Text mode: always returns a TextIOWrapper # The Traversable .open in stdlib/importlib/abc.pyi should be kept in sync with this. @@ -232,10 +246,18 @@ class Path(PurePath): if sys.version_info >= (3, 9): def readlink(self) -> Self: ... - def rename(self, target: str | PurePath) -> Self: ... - def replace(self, target: str | PurePath) -> Self: ... + if sys.version_info >= (3, 10): + def rename(self, target: StrPath) -> Self: ... + def replace(self, target: StrPath) -> Self: ... + else: + def rename(self, target: str | PurePath) -> Self: ... + def replace(self, target: str | PurePath) -> Self: ... + def resolve(self, strict: bool = False) -> Self: ... def rmdir(self) -> None: ... + if sys.version_info >= (3, 14): + def delete(self, ignore_errors: bool = False, on_error: Callable[[OSError], object] | None = None) -> None: ... + def symlink_to(self, target: StrOrBytesPath, target_is_directory: bool = False) -> None: ... if sys.version_info >= (3, 10): def hardlink_to(self, target: StrOrBytesPath) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/poplib.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/poplib.pyi index 7476f29919..a1e41be86a 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/poplib.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/poplib.pyi @@ -67,5 +67,6 @@ class POP3_SSL(POP3): timeout: float = ..., context: ssl.SSLContext | None = None, ) -> None: ... - # "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored + # "context" is actually the last argument, + # but that breaks LSP and it doesn't really matter because all the arguments are ignored def stls(self, context: Any = None, keyfile: Any = None, certfile: Any = None) -> NoReturn: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/pty.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/pty.pyi index 4c9e42b4ec..941915179c 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/pty.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/pty.pyi @@ -1,7 +1,7 @@ import sys from collections.abc import Callable, Iterable from typing import Final -from typing_extensions import TypeAlias +from typing_extensions import TypeAlias, deprecated if sys.platform != "win32": __all__ = ["openpty", "fork", "spawn"] @@ -13,7 +13,12 @@ if sys.platform != "win32": CHILD: Final = 0 def openpty() -> tuple[int, int]: ... - def master_open() -> tuple[int, str]: ... # deprecated, use openpty() - def slave_open(tty_name: str) -> int: ... # deprecated, use openpty() + + if sys.version_info < (3, 14): + @deprecated("Deprecated in 3.12, to be removed in 3.14; use openpty() instead") + def master_open() -> tuple[int, str]: ... + @deprecated("Deprecated in 3.12, to be removed in 3.14; use openpty() instead") + def slave_open(tty_name: str) -> int: ... + def fork() -> tuple[int, int]: ... def spawn(argv: str | Iterable[str], master_read: _Reader = ..., stdin_read: _Reader = ...) -> int: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/__init__.pyi index 64decd56be..dc0156ef13 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/__init__.pyi @@ -15,9 +15,9 @@ class ExpatError(Exception): offset: int error = ExpatError -XML_PARAM_ENTITY_PARSING_NEVER: int -XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int -XML_PARAM_ENTITY_PARSING_ALWAYS: int +XML_PARAM_ENTITY_PARSING_NEVER: Final = 0 +XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: Final = 1 +XML_PARAM_ENTITY_PARSING_ALWAYS: Final = 2 _Model: TypeAlias = tuple[int, int, str | None, tuple[Any, ...]] diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/errors.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/errors.pyi index 2e512eb129..cae4da0891 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/errors.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/errors.pyi @@ -1,49 +1,51 @@ import sys +from typing import Final +from typing_extensions import LiteralString codes: dict[str, int] messages: dict[int, str] -XML_ERROR_ABORTED: str -XML_ERROR_ASYNC_ENTITY: str -XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: str -XML_ERROR_BAD_CHAR_REF: str -XML_ERROR_BINARY_ENTITY_REF: str -XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING: str -XML_ERROR_DUPLICATE_ATTRIBUTE: str -XML_ERROR_ENTITY_DECLARED_IN_PE: str -XML_ERROR_EXTERNAL_ENTITY_HANDLING: str -XML_ERROR_FEATURE_REQUIRES_XML_DTD: str -XML_ERROR_FINISHED: str -XML_ERROR_INCOMPLETE_PE: str -XML_ERROR_INCORRECT_ENCODING: str -XML_ERROR_INVALID_TOKEN: str -XML_ERROR_JUNK_AFTER_DOC_ELEMENT: str -XML_ERROR_MISPLACED_XML_PI: str -XML_ERROR_NOT_STANDALONE: str -XML_ERROR_NOT_SUSPENDED: str -XML_ERROR_NO_ELEMENTS: str -XML_ERROR_NO_MEMORY: str -XML_ERROR_PARAM_ENTITY_REF: str -XML_ERROR_PARTIAL_CHAR: str -XML_ERROR_PUBLICID: str -XML_ERROR_RECURSIVE_ENTITY_REF: str -XML_ERROR_SUSPENDED: str -XML_ERROR_SUSPEND_PE: str -XML_ERROR_SYNTAX: str -XML_ERROR_TAG_MISMATCH: str -XML_ERROR_TEXT_DECL: str -XML_ERROR_UNBOUND_PREFIX: str -XML_ERROR_UNCLOSED_CDATA_SECTION: str -XML_ERROR_UNCLOSED_TOKEN: str -XML_ERROR_UNDECLARING_PREFIX: str -XML_ERROR_UNDEFINED_ENTITY: str -XML_ERROR_UNEXPECTED_STATE: str -XML_ERROR_UNKNOWN_ENCODING: str -XML_ERROR_XML_DECL: str +XML_ERROR_ABORTED: Final[LiteralString] +XML_ERROR_ASYNC_ENTITY: Final[LiteralString] +XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: Final[LiteralString] +XML_ERROR_BAD_CHAR_REF: Final[LiteralString] +XML_ERROR_BINARY_ENTITY_REF: Final[LiteralString] +XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING: Final[LiteralString] +XML_ERROR_DUPLICATE_ATTRIBUTE: Final[LiteralString] +XML_ERROR_ENTITY_DECLARED_IN_PE: Final[LiteralString] +XML_ERROR_EXTERNAL_ENTITY_HANDLING: Final[LiteralString] +XML_ERROR_FEATURE_REQUIRES_XML_DTD: Final[LiteralString] +XML_ERROR_FINISHED: Final[LiteralString] +XML_ERROR_INCOMPLETE_PE: Final[LiteralString] +XML_ERROR_INCORRECT_ENCODING: Final[LiteralString] +XML_ERROR_INVALID_TOKEN: Final[LiteralString] +XML_ERROR_JUNK_AFTER_DOC_ELEMENT: Final[LiteralString] +XML_ERROR_MISPLACED_XML_PI: Final[LiteralString] +XML_ERROR_NOT_STANDALONE: Final[LiteralString] +XML_ERROR_NOT_SUSPENDED: Final[LiteralString] +XML_ERROR_NO_ELEMENTS: Final[LiteralString] +XML_ERROR_NO_MEMORY: Final[LiteralString] +XML_ERROR_PARAM_ENTITY_REF: Final[LiteralString] +XML_ERROR_PARTIAL_CHAR: Final[LiteralString] +XML_ERROR_PUBLICID: Final[LiteralString] +XML_ERROR_RECURSIVE_ENTITY_REF: Final[LiteralString] +XML_ERROR_SUSPENDED: Final[LiteralString] +XML_ERROR_SUSPEND_PE: Final[LiteralString] +XML_ERROR_SYNTAX: Final[LiteralString] +XML_ERROR_TAG_MISMATCH: Final[LiteralString] +XML_ERROR_TEXT_DECL: Final[LiteralString] +XML_ERROR_UNBOUND_PREFIX: Final[LiteralString] +XML_ERROR_UNCLOSED_CDATA_SECTION: Final[LiteralString] +XML_ERROR_UNCLOSED_TOKEN: Final[LiteralString] +XML_ERROR_UNDECLARING_PREFIX: Final[LiteralString] +XML_ERROR_UNDEFINED_ENTITY: Final[LiteralString] +XML_ERROR_UNEXPECTED_STATE: Final[LiteralString] +XML_ERROR_UNKNOWN_ENCODING: Final[LiteralString] +XML_ERROR_XML_DECL: Final[LiteralString] if sys.version_info >= (3, 11): - XML_ERROR_RESERVED_PREFIX_XML: str - XML_ERROR_RESERVED_PREFIX_XMLNS: str - XML_ERROR_RESERVED_NAMESPACE_URI: str - XML_ERROR_INVALID_ARGUMENT: str - XML_ERROR_NO_BUFFER: str - XML_ERROR_AMPLIFICATION_LIMIT_BREACH: str + XML_ERROR_RESERVED_PREFIX_XML: Final[LiteralString] + XML_ERROR_RESERVED_PREFIX_XMLNS: Final[LiteralString] + XML_ERROR_RESERVED_NAMESPACE_URI: Final[LiteralString] + XML_ERROR_INVALID_ARGUMENT: Final[LiteralString] + XML_ERROR_NO_BUFFER: Final[LiteralString] + XML_ERROR_AMPLIFICATION_LIMIT_BREACH: Final[LiteralString] diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/model.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/model.pyi index f357cf6511..bac8f3692c 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/model.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/pyexpat/model.pyi @@ -1,11 +1,13 @@ -XML_CTYPE_ANY: int -XML_CTYPE_CHOICE: int -XML_CTYPE_EMPTY: int -XML_CTYPE_MIXED: int -XML_CTYPE_NAME: int -XML_CTYPE_SEQ: int +from typing import Final -XML_CQUANT_NONE: int -XML_CQUANT_OPT: int -XML_CQUANT_PLUS: int -XML_CQUANT_REP: int +XML_CTYPE_ANY: Final = 2 +XML_CTYPE_EMPTY: Final = 1 +XML_CTYPE_MIXED: Final = 3 +XML_CTYPE_NAME: Final = 4 +XML_CTYPE_CHOICE: Final = 5 +XML_CTYPE_SEQ: Final = 6 + +XML_CQUANT_NONE: Final = 0 +XML_CQUANT_OPT: Final = 1 +XML_CQUANT_REP: Final = 2 +XML_CQUANT_PLUS: Final = 3 diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/sqlite3/dbapi2.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/sqlite3/dbapi2.pyi index 9e46012ee7..0ee511df4e 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/sqlite3/dbapi2.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/sqlite3/dbapi2.pyi @@ -29,7 +29,10 @@ def DateFromTicks(ticks: float) -> Date: ... def TimeFromTicks(ticks: float) -> Time: ... def TimestampFromTicks(ticks: float) -> Timestamp: ... -version_info: tuple[int, int, int] +if sys.version_info < (3, 14): + # Deprecated in 3.12, removed in 3.14. + version_info: tuple[int, int, int] + sqlite_version_info: tuple[int, int, int] Binary = memoryview @@ -90,7 +93,10 @@ SQLITE_UPDATE: Final[int] adapters: dict[tuple[type[Any], type[Any]], _Adapter[Any]] converters: dict[str, _Converter] sqlite_version: str -version: str + +if sys.version_info < (3, 14): + # Deprecated in 3.12, removed in 3.14. + version: str if sys.version_info >= (3, 11): SQLITE_ABORT: Final[int] diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/tarfile.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/tarfile.pyi index d6adf21c19..e46903bf61 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/tarfile.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/tarfile.pyi @@ -423,7 +423,7 @@ class TarInfo: name: str path: str size: int - mtime: int + mtime: int | float chksum: int devmajor: int devminor: int diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/__init__.pyi index 0931b43f1b..2a42eb7897 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/__init__.pyi @@ -2148,11 +2148,12 @@ class Listbox(Widget, XView, YView): selectborderwidth: _ScreenUnits = 0, selectforeground: str = ..., # from listbox man page: "The value of the [selectmode] option may be - # arbitrary, but the default bindings expect it to be ..." + # arbitrary, but the default bindings expect it to be either single, + # browse, multiple, or extended" # # I have never seen anyone setting this to something else than what # "the default bindings expect", but let's support it anyway. - selectmode: str = "browse", + selectmode: str | Literal["single", "browse", "multiple", "extended"] = "browse", # noqa: Y051 setgrid: bool = False, state: Literal["normal", "disabled"] = "normal", takefocus: _TakeFocusValue = "", @@ -2187,7 +2188,7 @@ class Listbox(Widget, XView, YView): selectbackground: str = ..., selectborderwidth: _ScreenUnits = ..., selectforeground: str = ..., - selectmode: str = ..., + selectmode: str | Literal["single", "browse", "multiple", "extended"] = ..., # noqa: Y051 setgrid: bool = ..., state: Literal["normal", "disabled"] = ..., takefocus: _TakeFocusValue = ..., @@ -2907,6 +2908,9 @@ class Scrollbar(Widget): def set(self, first: float | str, last: float | str) -> None: ... _TextIndex: TypeAlias = _tkinter.Tcl_Obj | str | float | Misc +_WhatToCount: TypeAlias = Literal[ + "chars", "displaychars", "displayindices", "displaylines", "indices", "lines", "xpixels", "ypixels" +] class Text(Widget, XView, YView): def __init__( @@ -3021,7 +3025,27 @@ class Text(Widget, XView, YView): config = configure def bbox(self, index: _TextIndex) -> tuple[int, int, int, int] | None: ... # type: ignore[override] def compare(self, index1: _TextIndex, op: Literal["<", "<=", "==", ">=", ">", "!="], index2: _TextIndex) -> bool: ... - def count(self, index1, index2, *args): ... # TODO + @overload + def count(self, index1: _TextIndex, index2: _TextIndex) -> tuple[int] | None: ... + @overload + def count(self, index1: _TextIndex, index2: _TextIndex, arg: _WhatToCount | Literal["update"], /) -> tuple[int] | None: ... + @overload + def count(self, index1: _TextIndex, index2: _TextIndex, arg1: Literal["update"], arg2: _WhatToCount, /) -> int | None: ... + @overload + def count(self, index1: _TextIndex, index2: _TextIndex, arg1: _WhatToCount, arg2: Literal["update"], /) -> int | None: ... + @overload + def count(self, index1: _TextIndex, index2: _TextIndex, arg1: _WhatToCount, arg2: _WhatToCount, /) -> tuple[int, int]: ... + @overload + def count( + self, + index1: _TextIndex, + index2: _TextIndex, + arg1: _WhatToCount | Literal["update"], + arg2: _WhatToCount | Literal["update"], + arg3: _WhatToCount | Literal["update"], + /, + *args: _WhatToCount | Literal["update"], + ) -> tuple[int, ...]: ... @overload def debug(self, boolean: None = None) -> bool: ... @overload diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/constants.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/constants.pyi index 0b497f3a42..fbfe8b49b9 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/constants.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/constants.pyi @@ -1,12 +1,12 @@ from typing import Final # These are not actually bools. See #4669 -NO: bool -YES: bool -TRUE: bool -FALSE: bool -ON: bool -OFF: bool +NO: Final[bool] +YES: Final[bool] +TRUE: Final[bool] +FALSE: Final[bool] +ON: Final[bool] +OFF: Final[bool] N: Final = "n" S: Final = "s" W: Final = "w" diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/dialog.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/dialog.pyi index f76732a254..b7d74c0fa7 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/dialog.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/dialog.pyi @@ -2,12 +2,12 @@ import sys from _typeshed import Incomplete from collections.abc import Mapping from tkinter import Widget -from typing import Any +from typing import Any, Final if sys.version_info >= (3, 9): __all__ = ["Dialog"] -DIALOG_ICON: str +DIALOG_ICON: Final = "questhead" class Dialog(Widget): widgetName: str diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/messagebox.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/messagebox.pyi index 5a04b66d78..5cdfe512f9 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/messagebox.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/messagebox.pyi @@ -1,6 +1,6 @@ import sys from tkinter.commondialog import Dialog -from typing import ClassVar +from typing import ClassVar, Final if sys.version_info >= (3, 9): __all__ = [ @@ -14,22 +14,22 @@ if sys.version_info >= (3, 9): "askretrycancel", ] -ERROR: str -INFO: str -QUESTION: str -WARNING: str -ABORTRETRYIGNORE: str -OK: str -OKCANCEL: str -RETRYCANCEL: str -YESNO: str -YESNOCANCEL: str -ABORT: str -RETRY: str -IGNORE: str -CANCEL: str -YES: str -NO: str +ERROR: Final = "error" +INFO: Final = "info" +QUESTION: Final = "question" +WARNING: Final = "warning" +ABORTRETRYIGNORE: Final = "abortretryignore" +OK: Final = "ok" +OKCANCEL: Final = "okcancel" +RETRYCANCEL: Final = "retrycancel" +YESNO: Final = "yesno" +YESNOCANCEL: Final = "yesnocancel" +ABORT: Final = "abort" +RETRY: Final = "retry" +IGNORE: Final = "ignore" +CANCEL: Final = "cancel" +YES: Final = "yes" +NO: Final = "no" class Message(Dialog): command: ClassVar[str] diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/ttk.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/ttk.pyi index b3d681c930..b851f47814 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/ttk.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/tkinter/ttk.pyi @@ -556,7 +556,9 @@ class Notebook(Widget): sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', no repeats, may be empty padding: _Padding = ..., text: str = ..., - image=..., # Sequence of an image name, followed by zero or more (sequences of one or more state names followed by an image name) + # `image` is a sequence of an image name, followed by zero or more + # (sequences of one or more state names followed by an image name) + image=..., compound: tkinter._Compound = ..., underline: int = ..., ) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/typing.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/typing.pyi index f4de1fa86d..f6fb00e4b2 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/typing.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/typing.pyi @@ -846,7 +846,8 @@ class TextIO(IO[str]): @abstractmethod def __enter__(self) -> TextIO: ... -ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview +if sys.version_info < (3, 14): + ByteString: typing_extensions.TypeAlias = bytes | bytearray | memoryview # Functions diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/urllib/request.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/urllib/request.pyi index 2a6476f9e6..ad4f91fc31 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/urllib/request.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/urllib/request.pyi @@ -79,6 +79,7 @@ else: def pathname2url(pathname: str) -> str: ... def getproxies() -> dict[str, str]: ... +def getproxies_environment() -> dict[str, str]: ... def parse_http_list(s: str) -> list[str]: ... def parse_keqv_list(l: list[str]) -> dict[str, str]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/zipfile/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/zipfile/__init__.pyi index 57a8a6aaa4..5b8f02f61b 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/zipfile/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/zipfile/__init__.pyi @@ -94,6 +94,20 @@ class ZipExtFile(io.BufferedIOBase): class _Writer(Protocol): def write(self, s: str, /) -> object: ... +class _ZipReadable(Protocol): + def seek(self, offset: int, whence: int = 0, /) -> int: ... + def read(self, n: int = -1, /) -> bytes: ... + +class _ZipTellable(Protocol): + def tell(self) -> int: ... + +class _ZipReadableTellable(_ZipReadable, _ZipTellable, Protocol): ... + +class _ZipWritable(Protocol): + def flush(self) -> None: ... + def close(self) -> None: ... + def write(self, b: bytes, /) -> int: ... + class ZipFile: filename: str | None debug: int @@ -106,24 +120,50 @@ class ZipFile: compresslevel: int | None # undocumented mode: _ZipFileMode # undocumented pwd: bytes | None # undocumented + # metadata_encoding is new in 3.11 if sys.version_info >= (3, 11): @overload def __init__( self, file: StrPath | IO[bytes], + mode: _ZipFileMode = "r", + compression: int = 0, + allowZip64: bool = True, + compresslevel: int | None = None, + *, + strict_timestamps: bool = True, + metadata_encoding: str | None = None, + ) -> None: ... + # metadata_encoding is only allowed for read mode + @overload + def __init__( + self, + file: StrPath | _ZipReadable, mode: Literal["r"] = "r", compression: int = 0, allowZip64: bool = True, compresslevel: int | None = None, *, strict_timestamps: bool = True, - metadata_encoding: str | None, + metadata_encoding: str | None = None, ) -> None: ... @overload def __init__( self, - file: StrPath | IO[bytes], - mode: _ZipFileMode = "r", + file: StrPath | _ZipWritable, + mode: Literal["w", "x"] = ..., + compression: int = 0, + allowZip64: bool = True, + compresslevel: int | None = None, + *, + strict_timestamps: bool = True, + metadata_encoding: None = None, + ) -> None: ... + @overload + def __init__( + self, + file: StrPath | _ZipReadableTellable, + mode: Literal["a"] = ..., compression: int = 0, allowZip64: bool = True, compresslevel: int | None = None, @@ -132,6 +172,7 @@ class ZipFile: metadata_encoding: None = None, ) -> None: ... else: + @overload def __init__( self, file: StrPath | IO[bytes], @@ -142,6 +183,39 @@ class ZipFile: *, strict_timestamps: bool = True, ) -> None: ... + @overload + def __init__( + self, + file: StrPath | _ZipReadable, + mode: Literal["r"] = "r", + compression: int = 0, + allowZip64: bool = True, + compresslevel: int | None = None, + *, + strict_timestamps: bool = True, + ) -> None: ... + @overload + def __init__( + self, + file: StrPath | _ZipWritable, + mode: Literal["w", "x"] = ..., + compression: int = 0, + allowZip64: bool = True, + compresslevel: int | None = None, + *, + strict_timestamps: bool = True, + ) -> None: ... + @overload + def __init__( + self, + file: StrPath | _ZipReadableTellable, + mode: Literal["a"] = ..., + compression: int = 0, + allowZip64: bool = True, + compresslevel: int | None = None, + *, + strict_timestamps: bool = True, + ) -> None: ... def __enter__(self) -> Self: ... def __exit__( @@ -230,6 +304,7 @@ else: class Path: root: CompleteDirs + at: str def __init__(self, root: ZipFile | StrPath | IO[bytes], at: str = "") -> None: ... @property def name(self) -> str: ... diff --git a/packages/pyright-internal/typeshed-fallback/stdlib/zipfile/_path.pyi b/packages/pyright-internal/typeshed-fallback/stdlib/zipfile/_path.pyi index bafbbeeb0d..933acf2c48 100644 --- a/packages/pyright-internal/typeshed-fallback/stdlib/zipfile/_path.pyi +++ b/packages/pyright-internal/typeshed-fallback/stdlib/zipfile/_path.pyi @@ -31,6 +31,7 @@ if sys.version_info >= (3, 12): class Path: root: CompleteDirs + at: str def __init__(self, root: ZipFile | StrPath | IO[bytes], at: str = "") -> None: ... @property def name(self) -> str: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/JACK-Client/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/JACK-Client/METADATA.toml index bd070e6d04..1660b2aae1 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/JACK-Client/METADATA.toml +++ b/packages/pyright-internal/typeshed-fallback/stubs/JACK-Client/METADATA.toml @@ -1,7 +1,9 @@ version = "0.5.*" upstream_repository = "https://github.com/spatialaudio/jackclient-python" # Requires a version of numpy with a `py.typed` file -requires = ["numpy>=1.20", "types-cffi"] +# see https://github.com/python/typeshed/issues/12551 +# on why we need the upper bound for numpy +requires = ["numpy>=1.20,<2.1.0", "types-cffi"] [tool.stubtest] # darwin and win32 are equivalent diff --git a/packages/pyright-internal/typeshed-fallback/stubs/cachetools/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/cachetools/METADATA.toml index cb33580d4a..de2f997c76 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/cachetools/METADATA.toml +++ b/packages/pyright-internal/typeshed-fallback/stubs/cachetools/METADATA.toml @@ -1,2 +1,2 @@ -version = "5.4.*" +version = "5.5.*" upstream_repository = "https://github.com/tkem/cachetools" diff --git a/packages/pyright-internal/typeshed-fallback/stubs/cachetools/cachetools/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/cachetools/cachetools/__init__.pyi index 2b4990efc8..a7c0906e0e 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/cachetools/cachetools/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/cachetools/cachetools/__init__.pyi @@ -85,7 +85,7 @@ class TTLCache(_TimedCache[_KT, _VT]): ) -> None: ... @property def ttl(self) -> float: ... - def expire(self, time: float | None = None) -> None: ... + def expire(self, time: float | None = None) -> list[tuple[_KT, _VT]]: ... class TLRUCache(_TimedCache[_KT, _VT]): def __init__( @@ -97,7 +97,7 @@ class TLRUCache(_TimedCache[_KT, _VT]): ) -> None: ... @property def ttu(self) -> Callable[[_KT, _VT, float], float]: ... - def expire(self, time: float | None = None) -> None: ... + def expire(self, time: float | None = None) -> list[tuple[_KT, _VT]]: ... def cached( cache: MutableMapping[_KT, Any] | None, diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/corus/METADATA.toml new file mode 100644 index 0000000000..f966ab4569 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/METADATA.toml @@ -0,0 +1,2 @@ +version = "0.10.*" +upstream_repository = "https://github.com/natasha/corus" diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/__init__.pyi new file mode 100644 index 0000000000..78b35349b2 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/__init__.pyi @@ -0,0 +1 @@ +from .sources import * diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/io.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/io.pyi new file mode 100644 index 0000000000..0dfb4f6ea6 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/io.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def match_names(records, pattern) -> Generator[Incomplete]: ... +def rstrip(text): ... +def load_text(path): ... +def dump_text(text, path) -> None: ... +def load_lines(path, encoding: str = "utf-8") -> Generator[Incomplete]: ... +def parse_xml(text): ... +def load_z_lines(path, open, encoding: str = "utf8") -> Generator[Incomplete]: ... +def load_gz_lines(path): ... +def load_bz2_lines(path): ... +def load_xz_lines(path): ... +def list_zip(path): ... +def load_zip_lines(path, name, encoding: str = "utf8") -> Generator[Incomplete]: ... +def load_zip_texts(path, names, encoding: str = "utf8") -> Generator[Incomplete]: ... +def parse_csv(lines, delimiter: str = ",", max_field: Incomplete | None = None): ... +def parse_tsv(lines): ... +def skip_header(rows): ... +def dict_csv(rows) -> Generator[Incomplete]: ... +def parse_jsonl(lines) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/path.pyi similarity index 100% rename from packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/__init__.pyi rename to packages/pyright-internal/typeshed-fallback/stubs/corus/corus/path.pyi diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/readme.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/readme.pyi new file mode 100644 index 0000000000..dd02343ee0 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/readme.pyi @@ -0,0 +1,17 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +COMMANDS: Incomplete +KB: int +MB: Incomplete +GB: Incomplete +LABELS: Incomplete + +def is_command(step, commands=("wget", "unzip", "unrar", "rm", "mv", "tar")): ... +def format_bytes(value): ... +def format_count(value): ... +def unfold_metas(items) -> Generator[Incomplete]: ... +def format_metas_(metas, nbviewer: Incomplete | None = None) -> Generator[Incomplete]: ... +def format_metas(metas, url: Incomplete | None = None): ... +def show_html(html) -> None: ... +def patch_readme(html, path) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/record.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/record.pyi new file mode 100644 index 0000000000..a15b7c9fef --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/record.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +class Record: + __attributes__: Incomplete + def __eq__(self, other): ... + def __ne__(self, other): ... + def __iter__(self): ... + def __hash__(self): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/__init__.pyi new file mode 100644 index 0000000000..a494e31c70 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/__init__.pyi @@ -0,0 +1,23 @@ +from .bsnlp import load_bsnlp as load_bsnlp +from .buriy import * +from .corpora import load_corpora as load_corpora +from .factru import load_factru as load_factru +from .gareev import load_gareev as load_gareev +from .gramru import load_gramru as load_gramru +from .lenta import load_lenta as load_lenta, load_lenta2 as load_lenta2 +from .librusec import load_librusec as load_librusec +from .mokoron import * +from .morphoru import * +from .ne5 import load_ne5 as load_ne5 +from .ods import * +from .omnia import load_omnia as load_omnia +from .persons import load_persons as load_persons +from .ria import * +from .rudrec import load_rudrec as load_rudrec +from .russe import * +from .simlex import load_simlex as load_simlex +from .taiga import * +from .toloka import load_ruadrect as load_ruadrect, load_toloka_lrwc as load_toloka_lrwc +from .ud import * +from .wiki import load_wiki as load_wiki +from .wikiner import load_wikiner as load_wikiner diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/bsnlp.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/bsnlp.pyi new file mode 100644 index 0000000000..363c209ad9 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/bsnlp.pyi @@ -0,0 +1,75 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +RU: str +BG: str +CS: str +PL: str +LANGS: Incomplete +ANNOTATED: str +RAW: str +TXT: str +OUT: str + +class BsnlpId(Record): + __attributes__: Incomplete + lang: Incomplete + type: Incomplete + name: Incomplete + path: Incomplete + def __init__(self, lang, type, name, path) -> None: ... + +class BsnlpRaw(Record): + __attributes__: Incomplete + id: Incomplete + name: Incomplete + lang: Incomplete + date: Incomplete + url: Incomplete + text: Incomplete + def __init__(self, id, name, lang, date, url, text) -> None: ... + +class BsnlpAnnotated(Record): + __attributes__: Incomplete + id: Incomplete + name: Incomplete + substrings: Incomplete + def __init__(self, id, name, substrings) -> None: ... + +class BsnlpSubstring(Record): + __attributes__: Incomplete + text: Incomplete + normal: Incomplete + type: Incomplete + id: Incomplete + def __init__(self, text, normal, type, id) -> None: ... + +class BsnlpMarkup(Record): + __attributes__: Incomplete + id: Incomplete + name: Incomplete + lang: Incomplete + date: Incomplete + url: Incomplete + text: Incomplete + substrings: Incomplete + def __init__(self, id, name, lang, date, url, text, substrings) -> None: ... + +def walk(dir): ... +def load_ids(dir, langs) -> Generator[Incomplete]: ... +def select_type(ids, type) -> Generator[Incomplete]: ... + +RAW_PATTERN: Incomplete + +def parse_raw(name, text): ... +def load_raw(records) -> Generator[Incomplete]: ... + +ANNOTATED_PATTERN: Incomplete + +def parse_substrings(lines) -> Generator[Incomplete]: ... +def parse_annotated(name, lines): ... +def load_annotated(records) -> Generator[Incomplete]: ... +def merge(raw, annotated) -> Generator[Incomplete]: ... +def load_bsnlp(dir, langs=["ru"]): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/buriy.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/buriy.pyi new file mode 100644 index 0000000000..7cb3e38f5b --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/buriy.pyi @@ -0,0 +1,18 @@ +from _typeshed import Incomplete + +from corus.record import Record + +__all__ = ["load_buriy_news", "load_buriy_webhose"] + +class BuriyRecord(Record): + __attributes__: Incomplete + timestamp: Incomplete + url: Incomplete + edition: Incomplete + topics: Incomplete + title: Incomplete + text: Incomplete + def __init__(self, timestamp, url, edition, topics, title, text) -> None: ... + +def load_buriy_news(path): ... +def load_buriy_webhose(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/corpora.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/corpora.pyi new file mode 100644 index 0000000000..fd2603f4c3 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/corpora.pyi @@ -0,0 +1,50 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class CorporaText(Record): + __attributes__: Incomplete + id: Incomplete + parent_id: Incomplete + name: Incomplete + tags: Incomplete + pars: Incomplete + def __init__(self, id, parent_id, name, tags, pars) -> None: ... + +class CorporaPar(Record): + __attributes__: Incomplete + id: Incomplete + sents: Incomplete + def __init__(self, id, sents) -> None: ... + +class CorporaSent(Record): + __attributes__: Incomplete + id: Incomplete + text: Incomplete + tokens: Incomplete + def __init__(self, id, text, tokens) -> None: ... + +class CorporaToken(Record): + __attributes__: Incomplete + id: Incomplete + rev_id: Incomplete + text: Incomplete + forms: Incomplete + def __init__(self, id, rev_id, text, forms) -> None: ... + +class CorporaForm(Record): + __attributes__: Incomplete + id: Incomplete + text: Incomplete + grams: Incomplete + def __init__(self, id, text, grams) -> None: ... + +def parse_grams(xml) -> Generator[Incomplete]: ... +def parse_forms(xml) -> Generator[Incomplete]: ... +def parse_tokens(xml) -> Generator[Incomplete]: ... +def parse_sents(xml) -> Generator[Incomplete]: ... +def parse_pars(xml) -> Generator[Incomplete]: ... +def parse_tags(xml) -> Generator[Incomplete]: ... +def parse_text(xml): ... +def load_corpora(path) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/factru.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/factru.pyi new file mode 100644 index 0000000000..5c7da26131 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/factru.pyi @@ -0,0 +1,74 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +DEVSET: str +TESTSET: str +TXT: str +SPANS: str +OBJECTS: str +COREF: str +FACTS: str + +class FactruSpan(Record): + __attributes__: Incomplete + id: Incomplete + type: Incomplete + start: Incomplete + stop: Incomplete + def __init__(self, id, type, start, stop) -> None: ... + +class FactruObject(Record): + __attributes__: Incomplete + id: Incomplete + type: Incomplete + spans: Incomplete + def __init__(self, id, type, spans) -> None: ... + +class FactruCorefSlot(Record): + __attributes__: Incomplete + type: Incomplete + value: Incomplete + def __init__(self, type, value) -> None: ... + +class FactruCoref(Record): + __attributes__: Incomplete + id: Incomplete + objects: Incomplete + slots: Incomplete + def __init__(self, id, objects, slots) -> None: ... + +class FactruFactSlot(Record): + __attributes__: Incomplete + type: Incomplete + ref: Incomplete + value: Incomplete + def __init__(self, type, ref, value) -> None: ... + +class FactruFact(Record): + __attributes__: Incomplete + id: Incomplete + type: Incomplete + slots: Incomplete + def __init__(self, id, type, slots) -> None: ... + +class FactruMarkup(Record): + __attributes__: Incomplete + id: Incomplete + text: Incomplete + objects: Incomplete + corefs: Incomplete + facts: Incomplete + def __init__(self, id, text, objects, corefs, facts) -> None: ... + +def list_ids(dir, set) -> Generator[Incomplete]: ... +def part_path(id, dir, set, part): ... +def parse_spans(lines) -> Generator[Incomplete]: ... +def parse_objects(lines, spans) -> Generator[Incomplete]: ... +def parse_coref_slots(lines) -> Generator[Incomplete]: ... +def parse_corefs(lines, objects) -> Generator[Incomplete]: ... +def parse_facts_slots(lines, id_corefs, id_spans) -> Generator[Incomplete]: ... +def parse_facts(lines, corefs, spans) -> Generator[Incomplete]: ... +def load_id(id, dir, set): ... +def load_factru(dir, sets=["devset", "testset"]) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/gareev.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/gareev.pyi new file mode 100644 index 0000000000..f957af98a3 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/gareev.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class GareevToken(Record): + __attributes__: Incomplete + text: Incomplete + tag: Incomplete + def __init__(self, text, tag) -> None: ... + +class GareevRecord(Record): + __attributes__: Incomplete + tokens: Incomplete + def __init__(self, tokens) -> None: ... + +def parse_conll(lines) -> Generator[Incomplete]: ... +def parse_gareev(lines): ... +def load_id(id, dir): ... +def list_ids(dir) -> Generator[Incomplete]: ... +def load_gareev(dir) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/gramru.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/gramru.pyi new file mode 100644 index 0000000000..5b0f2e7024 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/gramru.pyi @@ -0,0 +1 @@ +def load_gramru(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/lenta.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/lenta.pyi new file mode 100644 index 0000000000..58aff5b5df --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/lenta.pyi @@ -0,0 +1,19 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class LentaRecord(Record): + __attributes__: Incomplete + url: Incomplete + title: Incomplete + text: Incomplete + topic: Incomplete + tags: Incomplete + date: Incomplete + def __init__(self, url, title, text, topic, tags, date: Incomplete | None = None) -> None: ... + +def parse_lenta(lines) -> Generator[Incomplete]: ... +def parse_lenta2(lines) -> Generator[Incomplete]: ... +def load_lenta(path): ... +def load_lenta2(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/librusec.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/librusec.pyi new file mode 100644 index 0000000000..5dac8e6e9b --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/librusec.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class LibrusecRecord(Record): + __attributes__: Incomplete + id: Incomplete + text: Incomplete + def __init__(self, id, text) -> None: ... + +def flush(id, buffer): ... +def parse_librusec(lines) -> Generator[Incomplete]: ... +def load_librusec(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/meta.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/meta.pyi new file mode 100644 index 0000000000..c8b50c267f --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/meta.pyi @@ -0,0 +1,54 @@ +from _typeshed import Incomplete + +from corus.record import Record + +class Meta(Record): + __attributes__: Incomplete + title: Incomplete + url: Incomplete + description: Incomplete + stats: Incomplete + instruction: Incomplete + tags: Incomplete + functions: Incomplete + def __init__( + self, + title, + url: Incomplete | None = None, + description: Incomplete | None = None, + stats: Incomplete | None = None, + instruction=(), + tags=(), + functions=(), + ) -> None: ... + +class Group(Record): + __attributes__: Incomplete + title: Incomplete + url: Incomplete + description: Incomplete + instruction: Incomplete + metas: Incomplete + def __init__( + self, title, url: Incomplete | None = None, description: Incomplete | None = None, instruction=(), metas=() + ) -> None: ... + +def is_group(item): ... + +class Stats(Record): + __attributes__: Incomplete + bytes: Incomplete + count: Incomplete + def __init__(self, bytes: Incomplete | None = None, count: Incomplete | None = None) -> None: ... + +NER: str +NEWS: str +FICTION: str +SOCIAL: str +MORPH: str +SYNTAX: str +EMB: str +SIM: str +SENTIMENT: str +WEB: str +METAS: Incomplete diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/mokoron.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/mokoron.pyi new file mode 100644 index 0000000000..01217ec4b8 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/mokoron.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +__all__ = ["load_mokoron"] + +class MokoronRecord(Record): + __attributes__: Incomplete + id: Incomplete + timestamp: Incomplete + user: Incomplete + text: Incomplete + sentiment: Incomplete + replies: Incomplete + retweets: Incomplete + favourites: Incomplete + posts: Incomplete + followers: Incomplete + friends: Incomplete + lists: Incomplete + def __init__( + self, id, timestamp, user, text, sentiment, replies, retweets, favourites, posts, followers, friends, lists + ) -> None: ... + @classmethod + def from_match(cls, match): ... + +def load_mokoron(path) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/morphoru.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/morphoru.pyi new file mode 100644 index 0000000000..3010d097b2 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/morphoru.pyi @@ -0,0 +1,24 @@ +from _typeshed import Incomplete + +from corus.record import Record + +__all__ = ["load_morphoru_gicrya", "load_morphoru_rnc", "load_morphoru_corpora"] + +class MorphoSent(Record): + __attributes__: Incomplete + tokens: Incomplete + attrs: Incomplete + def __init__(self, tokens, attrs=()) -> None: ... + +class MorphoToken(Record): + __attributes__: Incomplete + text: Incomplete + lemma: Incomplete + pos: Incomplete + feats: Incomplete + feats2: Incomplete + def __init__(self, text, lemma, pos, feats, feats2: Incomplete | None = None) -> None: ... + +def load_morphoru_gicrya(path): ... +def load_morphoru_rnc(path): ... +def load_morphoru_corpora(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ne5.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ne5.pyi new file mode 100644 index 0000000000..45eb12c9b3 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ne5.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class Ne5Span(Record): + __attributes__: Incomplete + index: Incomplete + type: Incomplete + start: Incomplete + stop: Incomplete + text: Incomplete + def __init__(self, index, type, start, stop, text) -> None: ... + +class Ne5Markup(Record): + __attributes__: Incomplete + id: Incomplete + text: Incomplete + spans: Incomplete + def __init__(self, id, text, spans) -> None: ... + +def list_ids(dir) -> Generator[Incomplete]: ... +def txt_path(id, dir): ... +def ann_path(id, dir): ... +def parse_spans(lines) -> Generator[Incomplete]: ... +def load_text(path): ... +def load_id(id, dir): ... +def load_ne5(dir) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ods.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ods.pyi new file mode 100644 index 0000000000..7705fdf392 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ods.pyi @@ -0,0 +1,46 @@ +from _typeshed import Incomplete + +from corus.record import Record + +__all__ = [ + "load_ods_interfax", + "load_ods_gazeta", + "load_ods_izvestia", + "load_ods_meduza", + "load_ods_ria", + "load_ods_rt", + "load_ods_tass", +] + +class NewsRecord(Record): + __attributes__: Incomplete + timestamp: Incomplete + url: Incomplete + edition: Incomplete + topics: Incomplete + authors: Incomplete + title: Incomplete + text: Incomplete + stats: Incomplete + def __init__(self, timestamp, url, edition, topics, authors, title, text, stats) -> None: ... + +class Stats(Record): + __attributes__: Incomplete + fb: Incomplete + vk: Incomplete + ok: Incomplete + twitter: Incomplete + lj: Incomplete + tg: Incomplete + likes: Incomplete + views: Incomplete + comments: Incomplete + def __init__(self, fb, vk, ok, twitter, lj, tg, likes, views, comments) -> None: ... + +def load_ods_interfax(path): ... +def load_ods_gazeta(path): ... +def load_ods_izvestia(path): ... +def load_ods_meduza(path): ... +def load_ods_ria(path): ... +def load_ods_rt(path): ... +def load_ods_tass(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/omnia.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/omnia.pyi new file mode 100644 index 0000000000..becd69ade5 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/omnia.pyi @@ -0,0 +1,49 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class OmniaDoc(Record): + __attributes__: Incomplete + id: Incomplete + attrs: Incomplete + pars: Incomplete + def __init__(self, id, attrs, pars) -> None: ... + +class OmniaPar(Record): + __attributes__: Incomplete + sents: Incomplete + def __init__(self, sents) -> None: ... + +class OmniaSent(Record): + __attributes__: Incomplete + tokens: Incomplete + def __init__(self, tokens) -> None: ... + +class OmniaToken(Record): + __attributes__: Incomplete + text: Incomplete + lemma: Incomplete + atag: Incomplete + tag: Incomplete + ztag: Incomplete + g: Incomplete + def __init__(self, text, lemma, atag, tag, ztag, g) -> None: ... + +DID: str +G_TAG: str +S_END: str +P_END: str +DOC_END: str + +def take_until(stream, value) -> Generator[Incomplete]: ... +def group_bounds(stream, end) -> Generator[Incomplete]: ... +def group_doc_bounds(stream) -> Generator[Incomplete]: ... +def group_pairs(stream) -> Generator[Incomplete]: ... +def parse_tokens(lines) -> Generator[Incomplete]: ... +def parse_sents(lines) -> Generator[Incomplete]: ... +def parse_pars(lines) -> Generator[Incomplete]: ... +def parse_tag_attrs(tag) -> Generator[Incomplete]: ... +def parse_doc_header(header): ... +def parse_docs(lines) -> Generator[Incomplete]: ... +def load_omnia(path) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/persons.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/persons.pyi new file mode 100644 index 0000000000..71f66bf071 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/persons.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +TEXT: str +ANNO: str + +class PersonsSpan(Record): + __attributes__: Incomplete + id: Incomplete + start: Incomplete + stop: Incomplete + value: Incomplete + def __init__(self, id, start, stop, value) -> None: ... + +class PersonsMarkup(Record): + __attributes__: Incomplete + text: Incomplete + spans: Incomplete + def __init__(self, text, spans) -> None: ... + +def list_ids(path) -> Generator[Incomplete]: ... +def part_names(ids, part) -> Generator[Incomplete]: ... +def parse_anno(text) -> Generator[Incomplete]: ... +def load_ids(ids, path) -> Generator[Incomplete]: ... +def load_persons(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ria.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ria.pyi new file mode 100644 index 0000000000..e5c555df8d --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ria.pyi @@ -0,0 +1,21 @@ +from _typeshed import Incomplete + +from corus.record import Record + +__all__ = ["load_ria_raw", "load_ria"] + +class RiaRawRecord(Record): + __attributes__: Incomplete + title: Incomplete + text: Incomplete + def __init__(self, title, text) -> None: ... + +class RiaRecord(Record): + __attributes__: Incomplete + title: Incomplete + prefix: Incomplete + text: Incomplete + def __init__(self, title, prefix, text) -> None: ... + +def load_ria_raw(path): ... +def load_ria(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/rudrec.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/rudrec.pyi new file mode 100644 index 0000000000..d2c883a23f --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/rudrec.pyi @@ -0,0 +1,27 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class RuDReCRecord(Record): + __attributes__: Incomplete + file_name: Incomplete + text: Incomplete + sentence_id: Incomplete + entities: Incomplete + def __init__(self, file_name, text, sentence_id, entities) -> None: ... + +class RuDReCEntity(Record): + __attributes__: Incomplete + entity_id: Incomplete + entity_text: Incomplete + entity_type: Incomplete + start: Incomplete + end: Incomplete + concept_id: Incomplete + concept_name: Incomplete + def __init__(self, entity_id, entity_text, entity_type, start, end, concept_id, concept_name) -> None: ... + +def parse_entities(items) -> Generator[Incomplete]: ... +def parse_rudrec(items) -> Generator[Incomplete]: ... +def load_rudrec(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/russe.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/russe.pyi new file mode 100644 index 0000000000..e313f1d604 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/russe.pyi @@ -0,0 +1,16 @@ +from _typeshed import Incomplete + +from corus.record import Record + +__all__ = ["load_russe_hj", "load_russe_rt", "load_russe_ae"] + +class RusseSemRecord(Record): + __attributes__: Incomplete + word1: Incomplete + word2: Incomplete + sim: Incomplete + def __init__(self, word1, word2, sim) -> None: ... + +def load_russe_hj(path): ... +def load_russe_rt(path): ... +def load_russe_ae(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/simlex.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/simlex.pyi new file mode 100644 index 0000000000..77794639ae --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/simlex.pyi @@ -0,0 +1,14 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class SimlexRecord(Record): + __attributes__: Incomplete + word1: Incomplete + word2: Incomplete + score: Incomplete + def __init__(self, word1, word2, score) -> None: ... + +def parse_simlex(lines) -> Generator[Incomplete]: ... +def load_simlex(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/__init__.pyi new file mode 100644 index 0000000000..0dd458f58a --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/__init__.pyi @@ -0,0 +1,10 @@ +from .arzamas import * +from .fontanka import * +from .interfax import * +from .kp import * +from .lenta import * +from .magazines import * +from .nplus1 import * +from .proza import * +from .social import * +from .subtitles import * diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/arzamas.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/arzamas.pyi new file mode 100644 index 0000000000..2b653b0c36 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/arzamas.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +__all__ = ["load_taiga_arzamas_metas", "load_taiga_arzamas"] + +def load_taiga_arzamas_metas(path, offset: int = 0, count: int = 1): ... +def load_taiga_arzamas(path, metas: Incomplete | None = None, offset: int = 144896, count: int = 311): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/common.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/common.pyi new file mode 100644 index 0000000000..34fd4cc4ab --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/common.pyi @@ -0,0 +1,77 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class ArchiveRecord(Record): + __attributes__: Incomplete + name: Incomplete + offset: Incomplete + file: Incomplete + def __init__(self, name, offset, file) -> None: ... + +class TaigaRecord(Record): + __attributes__: Incomplete + id: Incomplete + meta: Incomplete + text: Incomplete + def __init__(self, id, meta, text) -> None: ... + +class Author(Record): + __attributes__: Incomplete + name: Incomplete + readers: Incomplete + texts: Incomplete + profession: Incomplete + about: Incomplete + url: Incomplete + def __init__( + self, + name, + readers: Incomplete | None = None, + texts: Incomplete | None = None, + profession: Incomplete | None = None, + about: Incomplete | None = None, + url: Incomplete | None = None, + ) -> None: ... + +class Meta(Record): + __attributes__: Incomplete + id: Incomplete + timestamp: Incomplete + tags: Incomplete + themes: Incomplete + rubric: Incomplete + genre: Incomplete + topic: Incomplete + author: Incomplete + lang: Incomplete + title: Incomplete + url: Incomplete + def __init__( + self, + id, + timestamp: Incomplete | None = None, + tags: Incomplete | None = None, + themes: Incomplete | None = None, + rubric: Incomplete | None = None, + genre: Incomplete | None = None, + topic: Incomplete | None = None, + author: Incomplete | None = None, + lang: Incomplete | None = None, + title: Incomplete | None = None, + url: Incomplete | None = None, + ) -> None: ... + +def load_tar(path, offset: int = 0) -> Generator[Incomplete]: ... +def load_zip(path, offset: int = 0) -> Generator[Incomplete]: ... +def parse_meta(file, encoding: str = "utf8") -> Generator[Incomplete]: ... +def load_metas(path, pattern, offset, count, load) -> Generator[Incomplete]: ... +def load_tar_metas(path, pattern, offset, count): ... +def load_zip_metas(path, pattern, offset, count): ... +def load_texts(path, pattern, offset, count, parse_id, load, encoding: str = "utf8") -> Generator[Incomplete]: ... +def parse_filename_id(path): ... +def load_tar_texts(path, pattern, offset, count, parse_id=...): ... +def load_zip_texts(path, pattern, offset, count, parse_id=...): ... +def merge_metas(records, metas: Incomplete | None = None) -> Generator[Incomplete]: ... +def patch_month(date, months): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/fontanka.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/fontanka.pyi new file mode 100644 index 0000000000..0b04f867fe --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/fontanka.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +__all__ = ["load_taiga_fontanka_metas", "load_taiga_fontanka"] + +def load_taiga_fontanka_metas(path, offset: int = 0, count=13): ... +def load_taiga_fontanka(path, metas: Incomplete | None = None, offset: int = 306359296, count: int = 342683): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/interfax.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/interfax.pyi new file mode 100644 index 0000000000..9957c1c760 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/interfax.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +__all__ = ["load_taiga_interfax_metas", "load_taiga_interfax"] + +def load_taiga_interfax_metas(path, offset: int = 0, count: int = 1): ... +def load_taiga_interfax(path, metas: Incomplete | None = None, offset: int = 11447296, count: int = 46429): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/kp.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/kp.pyi new file mode 100644 index 0000000000..ed3d7f7024 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/kp.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +__all__ = ["load_taiga_kp_metas", "load_taiga_kp"] + +def load_taiga_kp_metas(path, offset: int = 0, count: int = 1): ... +def load_taiga_kp(path, metas: Incomplete | None = None, offset: int = 13042176, count: int = 45503): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/lenta.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/lenta.pyi new file mode 100644 index 0000000000..a46dc6187c --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/lenta.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +__all__ = ["load_taiga_lenta_metas", "load_taiga_lenta"] + +def load_taiga_lenta_metas(path, offset: int = 0, count: int = 1): ... +def load_taiga_lenta(path, metas: Incomplete | None = None, offset: int = 12800000, count: int = 36446): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/magazines.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/magazines.pyi new file mode 100644 index 0000000000..b536568f19 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/magazines.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +__all__ = ["load_taiga_magazines_metas", "load_taiga_magazines"] + +def load_taiga_magazines_metas(path, offset: int = 0, count: int = 36): ... +def load_taiga_magazines(path, metas: Incomplete | None = None, offset: int = 7292416, count: int = 39890): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/nplus1.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/nplus1.pyi new file mode 100644 index 0000000000..b83240f2a6 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/nplus1.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete + +__all__ = ["load_taiga_nplus1_metas", "load_taiga_nplus1"] + +def load_taiga_nplus1_metas(path, offset: int = 0, count: int = 1): ... +def load_taiga_nplus1(path, metas: Incomplete | None = None, offset: int = 1919488, count: int = 7696): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/proza.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/proza.pyi new file mode 100644 index 0000000000..2e584686b3 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/proza.pyi @@ -0,0 +1,8 @@ +from _typeshed import Incomplete + +__all__ = ["load_taiga_proza_metas", "load_taiga_proza", "load_taiga_stihi_metas", "load_taiga_stihi"] + +def load_taiga_proza_metas(path, offset: int = 0, count=13): ... +def load_taiga_stihi_metas(path, offset: int = 0, count=3): ... +def load_taiga_proza(path, metas: Incomplete | None = None, offset: int = ..., count: int = ...): ... +def load_taiga_stihi(path, metas: Incomplete | None = None, offset: int = ..., count: int = ...): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/social.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/social.pyi new file mode 100644 index 0000000000..e5b55ac11c --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/social.pyi @@ -0,0 +1,15 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +__all__ = ["load_taiga_social"] + +class TaigaSocialRecord(Record): + __attributes__: Incomplete + id: Incomplete + network: Incomplete + text: Incomplete + def __init__(self, id, network, text) -> None: ... + +def load_taiga_social(path, offset: int = 3985892864, count: int = 4) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/subtitles.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/subtitles.pyi new file mode 100644 index 0000000000..b2066c0d5a --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/taiga/subtitles.pyi @@ -0,0 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +def parse_metas(items) -> Generator[Incomplete]: ... +def load_taiga_subtitles_metas(path, offset: int = 0, count: int = 1): ... +def load_taiga_subtitles(path, metas: Incomplete | None = None, offset: int = 2113024, count: int = 19011): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/toloka.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/toloka.pyi new file mode 100644 index 0000000000..31c38839a9 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/toloka.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class LRWCRecord(Record): + __attributes__: Incomplete + hyponym: Incomplete + hypernym: Incomplete + genitive: Incomplete + judgement: Incomplete + confidence: Incomplete + def __init__(self, hyponym, hypernym, genitive, judgement, confidence) -> None: ... + +def parse_judgement(value): ... +def parse_confidence(value): ... +def parse_toloka_lrwc(lines) -> Generator[Incomplete]: ... +def load_toloka_lrwc(path): ... + +class RuADReCTRecord(Record): + __attributes__: Incomplete + tweet_id: Incomplete + tweet: Incomplete + label: Incomplete + def __init__(self, tweet_id, tweet, label) -> None: ... + +def parse_ruadrect(lines) -> Generator[Incomplete]: ... +def load_ruadrect(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ud.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ud.pyi new file mode 100644 index 0000000000..7b01da92c5 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/ud.pyi @@ -0,0 +1,29 @@ +from _typeshed import Incomplete + +from corus.record import Record + +__all__ = ["load_ud_gsd", "load_ud_taiga", "load_ud_pud", "load_ud_syntag"] + +class UDSent(Record): + __attributes__: Incomplete + id: Incomplete + text: Incomplete + attrs: Incomplete + tokens: Incomplete + def __init__(self, id, text, attrs, tokens) -> None: ... + +class UDToken(Record): + __attributes__: Incomplete + id: Incomplete + text: Incomplete + lemma: Incomplete + pos: Incomplete + feats: Incomplete + head_id: Incomplete + rel: Incomplete + def __init__(self, id, text, lemma, pos, feats, head_id, rel) -> None: ... + +def load_ud_gsd(path): ... +def load_ud_taiga(path): ... +def load_ud_pud(path): ... +def load_ud_syntag(path): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/wiki.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/wiki.pyi new file mode 100644 index 0000000000..0c26cc4072 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/wiki.pyi @@ -0,0 +1,20 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record +from corus.third.WikiExtractor import Extractor + +class WikiRecord(Record): + __attributes__: Incomplete + id: Incomplete + url: Incomplete + title: Incomplete + text: Incomplete + def __init__(self, id, url, title, text) -> None: ... + @classmethod + def from_json(cls, data): ... + +class Extractor_(Extractor): + def extract_(self): ... + +def load_wiki(path) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/wikiner.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/wikiner.pyi new file mode 100644 index 0000000000..e36381c74d --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/sources/wikiner.pyi @@ -0,0 +1,19 @@ +from _typeshed import Incomplete +from collections.abc import Generator + +from corus.record import Record + +class WikinerToken(Record): + __attributes__: Incomplete + text: Incomplete + pos: Incomplete + tag: Incomplete + def __init__(self, text, pos, tag) -> None: ... + +class WikinerMarkup(Record): + __attributes__: Incomplete + tokens: Incomplete + def __init__(self, tokens) -> None: ... + +def parse_wikiner(line): ... +def load_wikiner(path) -> Generator[Incomplete]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/third/WikiExtractor.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/third/WikiExtractor.pyi new file mode 100644 index 0000000000..b8ee370c8a --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/third/WikiExtractor.pyi @@ -0,0 +1,227 @@ +import typing +from _typeshed import Incomplete +from collections.abc import Generator +from math import ( + acos as acos, + asin as asin, + atan as atan, + ceil as ceil, + cos as cos, + exp as exp, + floor as floor, + pi as pi, + sin as sin, + tan as tan, + trunc as trunc, +) + +PY2: Incomplete +text_type = str +version: str +options: Incomplete +templateKeys: Incomplete +filter_disambig_page_pattern: Incomplete +g_page_total: int +g_page_articl_total: int +g_page_articl_used_total: int + +def keepPage(ns, catSet, page): ... +def get_url(uid): ... + +selfClosingTags: Incomplete +placeholder_tags: Incomplete + +def normalizeTitle(title): ... +def unescape(text): ... + +comment: Incomplete +nowiki: Incomplete + +def ignoreTag(tag) -> None: ... + +selfClosing_tag_patterns: Incomplete +placeholder_tag_patterns: Incomplete +preformatted: Incomplete +externalLink: Incomplete +externalLinkNoAnchor: Incomplete +bold_italic: Incomplete +bold: Incomplete +italic_quote: Incomplete +italic: Incomplete +quote_quote: Incomplete +spaces: Incomplete +dots: Incomplete + +_T = typing.TypeVar("_T") + +class Template(list[_T]): + @classmethod + def parse(cls, body): ... + def subst(self, params, extractor, depth: int = 0): ... + +class TemplateText(text_type): + def subst(self, params, extractor, depth): ... + +class TemplateArg: + name: Incomplete + default: Incomplete + def __init__(self, parameter) -> None: ... + def subst(self, params, extractor, depth): ... + +class Frame: + title: Incomplete + args: Incomplete + prev: Incomplete + depth: Incomplete + def __init__(self, title: str = "", args=[], prev: Incomplete | None = None) -> None: ... + def push(self, title, args): ... + def pop(self): ... + +substWords: str + +class Extractor: + id: Incomplete + revid: Incomplete + title: Incomplete + text: Incomplete + magicWords: Incomplete + frame: Incomplete + recursion_exceeded_1_errs: int + recursion_exceeded_2_errs: int + recursion_exceeded_3_errs: int + template_title_errs: int + def __init__(self, id, revid, title, lines) -> None: ... + def write_output(self, out, text) -> None: ... + def extract(self, out) -> None: ... + def transform(self, wikitext): ... + def transform1(self, text): ... + def wiki2text(self, text): ... + def clean(self, text): ... + maxTemplateRecursionLevels: int + maxParameterRecursionLevels: int + reOpen: Incomplete + def expand(self, wikitext): ... + def templateParams(self, parameters): ... + def expandTemplate(self, body): ... + +def splitParts(paramsList): ... +def findMatchingBraces(text, ldelim: int = 0) -> Generator[Incomplete]: ... +def findBalanced(text, openDelim=["[["], closeDelim=["]]"]) -> Generator[Incomplete]: ... +def if_empty(*rest): ... +def functionParams(args, vars): ... +def string_sub(args): ... +def string_sublength(args): ... +def string_len(args): ... +def string_find(args): ... +def string_pos(args): ... +def string_replace(args): ... +def string_rep(args): ... +def roman_main(args): ... + +modules: Incomplete + +class MagicWords: + names: Incomplete + values: Incomplete + def __init__(self) -> None: ... + def __getitem__(self, name): ... + def __setitem__(self, name, value) -> None: ... + switches: Incomplete + +magicWordsRE: Incomplete + +def ucfirst(string): ... +def lcfirst(string): ... +def fullyQualifiedTemplateTitle(templateTitle): ... +def normalizeNamespace(ns): ... + +class Infix: + function: Incomplete + def __init__(self, function) -> None: ... + def __ror__(self, other): ... + def __or__(self, other): ... + def __rlshift__(self, other): ... + def __rshift__(self, other): ... + def __call__(self, value1, value2): ... + +ROUND: Incomplete + +def sharp_expr(extr, expr): ... +def sharp_if(extr, testValue, valueIfTrue, valueIfFalse: Incomplete | None = None, *args): ... +def sharp_ifeq(extr, lvalue, rvalue, valueIfTrue, valueIfFalse: Incomplete | None = None, *args): ... +def sharp_iferror(extr, test, then: str = "", Else: Incomplete | None = None, *args): ... +def sharp_switch(extr, primary, *params): ... +def sharp_invoke(module, function, args): ... + +parserFunctions: Incomplete + +def callParserFunction(functionName, args, extractor): ... + +reNoinclude: Incomplete +reIncludeonly: Incomplete + +def define_template(title, page) -> None: ... +def dropNested(text, openDelim, closeDelim): ... +def dropSpans(spans, text): ... +def replaceInternalLinks(text): ... +def makeInternalLink(title, label): ... + +wgUrlProtocols: Incomplete +EXT_LINK_URL_CLASS: str +ANCHOR_CLASS: str +ExtLinkBracketedRegex: Incomplete +EXT_IMAGE_REGEX: Incomplete + +def replaceExternalLinks(text): ... +def makeExternalLink(url, anchor): ... +def makeExternalImage(url, alt: str = ""): ... + +tailRE: Incomplete +syntaxhighlight: Incomplete +section: Incomplete +listOpen: Incomplete +listClose: Incomplete +listItem: Incomplete + +def compact(text): ... +def handle_unicode(entity): ... + +class NextFile: + filesPerDir: int + path_name: Incomplete + dir_index: int + file_index: int + def __init__(self, path_name) -> None: ... + def __next__(self): ... + next = __next__ + +class OutputSplitter: + nextFile: Incomplete + compress: Incomplete + max_file_size: Incomplete + file: Incomplete + def __init__(self, nextFile, max_file_size: int = 0, compress: bool = True) -> None: ... + def reserve(self, size) -> None: ... + def write(self, data) -> None: ... + def close(self) -> None: ... + def open(self, filename): ... + +tagRE: Incomplete +keyRE: Incomplete +catRE: Incomplete + +def load_templates(file, output_file: Incomplete | None = None) -> None: ... +def pages_from(input) -> Generator[Incomplete]: ... +def process_dump(input_file, template_file, out_file, file_size, file_compress, process_count) -> None: ... +def extract_process(opts, i, jobs_queue, output_queue) -> None: ... + +report_period: int + +def reduce_process( + opts, output_queue, spool_length, out_file: Incomplete | None = None, file_size: int = 0, file_compress: bool = True +) -> None: ... + +minFileSize: Incomplete + +def main() -> None: ... +def createLogger(quiet, debug, log_file) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/third/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/third/__init__.pyi new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/zip.pyi b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/zip.pyi new file mode 100644 index 0000000000..036cd24485 --- /dev/null +++ b/packages/pyright-internal/typeshed-fallback/stubs/corus/corus/zip.pyi @@ -0,0 +1,28 @@ +from _typeshed import Incomplete +from typing import NamedTuple + +def open_zip(path): ... + +HEADER_FORMAT: str +HEADER_SIGNATURE: bytes +NO_COMPRESSION: int +DEFLATED: int + +class ZipHeader(NamedTuple): + signature: Incomplete + extract_by: Incomplete + flags: Incomplete + compression: Incomplete + time: Incomplete + date: Incomplete + crc: Incomplete + compressed: Incomplete + uncompressed: Incomplete + name: Incomplete + extra: Incomplete + +def decode_name(name): ... +def read_zip_header(file): ... +def is_zip_header(record): ... +def assert_zip_header(record) -> None: ... +def read_zip_data(file, header): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/flake8-2020/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/flake8-2020/METADATA.toml deleted file mode 100644 index 27b3527702..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/flake8-2020/METADATA.toml +++ /dev/null @@ -1,2 +0,0 @@ -version = "1.8.*" -upstream_repository = "https://github.com/asottile/flake8-2020" diff --git a/packages/pyright-internal/typeshed-fallback/stubs/flake8-2020/flake8_2020.pyi b/packages/pyright-internal/typeshed-fallback/stubs/flake8-2020/flake8_2020.pyi deleted file mode 100644 index 7af7c26b6d..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/flake8-2020/flake8_2020.pyi +++ /dev/null @@ -1,26 +0,0 @@ -# flake8-2020 has type annotations, but PEP 561 states: -# This PEP does not support distributing typing information as part of module-only distributions or single-file modules within namespace packages. -# Therefore typeshed is the best place. - -import ast -from collections.abc import Generator -from typing import Any, ClassVar - -YTT101: str -YTT102: str -YTT103: str -YTT201: str -YTT202: str -YTT203: str -YTT204: str -YTT301: str -YTT302: str -YTT303: str - -class Visitor(ast.NodeVisitor): ... - -class Plugin: - name: ClassVar[str] - version: ClassVar[str] - def __init__(self, tree: ast.AST) -> None: ... - def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/fpdf2/fpdf/drawing.pyi b/packages/pyright-internal/typeshed-fallback/stubs/fpdf2/fpdf/drawing.pyi index 997f1fd4f0..f9a426344f 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/fpdf2/fpdf/drawing.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/fpdf2/fpdf/drawing.pyi @@ -1,7 +1,7 @@ import decimal from _typeshed import Incomplete from collections import OrderedDict -from collections.abc import Callable, Generator, Iterator, Sequence +from collections.abc import Callable, Generator, Sequence from contextlib import contextmanager from re import Pattern from typing import Any, ClassVar, Literal, NamedTuple, TypeVar, overload @@ -354,7 +354,7 @@ class PaintedPath: @clipping_path.setter def clipping_path(self, new_clipath) -> None: ... @contextmanager - def transform_group(self, transform) -> Iterator[Self]: ... + def transform_group(self, transform) -> Generator[Self]: ... def add_path_element(self, item, _copy: bool = True) -> None: ... def remove_last_path_element(self) -> None: ... def rectangle(self, x, y, w, h, rx: int = 0, ry: int = 0) -> Self: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/fpdf2/fpdf/fpdf.pyi b/packages/pyright-internal/typeshed-fallback/stubs/fpdf2/fpdf/fpdf.pyi index f364de9818..0664638d05 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/fpdf2/fpdf/fpdf.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/fpdf2/fpdf/fpdf.pyi @@ -426,7 +426,7 @@ class FPDF(GraphicsStateMixin): def skew( self, ax: float = 0, ay: float = 0, x: float | None = None, y: float | None = None ) -> _GeneratorContextManager[None]: ... - def mirror(self, origin, angle) -> Generator[None, None, None]: ... + def mirror(self, origin, angle) -> Generator[None]: ... def local_context( self, font_family: Incomplete | None = None, diff --git a/packages/pyright-internal/typeshed-fallback/stubs/google-cloud-ndb/google/cloud/ndb/client.pyi b/packages/pyright-internal/typeshed-fallback/stubs/google-cloud-ndb/google/cloud/ndb/client.pyi index 8b7e65d98f..d5893fc73c 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/google-cloud-ndb/google/cloud/ndb/client.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/google-cloud-ndb/google/cloud/ndb/client.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable, Iterator +from collections.abc import Callable, Generator from contextlib import contextmanager from typing import ClassVar @@ -32,4 +32,4 @@ class Client: global_cache_policy: Callable[[key.Key], bool] | None = ..., global_cache_timeout_policy: Callable[[key.Key], int] | None = ..., legacy_data: bool = ..., - ) -> Iterator[context_module.Context]: ... + ) -> Generator[context_module.Context]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/influxdb-client/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/influxdb-client/METADATA.toml index 74f497ce41..2be30ac5f5 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/influxdb-client/METADATA.toml +++ b/packages/pyright-internal/typeshed-fallback/stubs/influxdb-client/METADATA.toml @@ -1,4 +1,4 @@ -version = "1.44.*" +version = "1.45.*" upstream_repository = "https://github.com/influxdata/influxdb-client-python" # requires a version of urllib3 with a py.typed file requires = ["urllib3>=2"] diff --git a/packages/pyright-internal/typeshed-fallback/stubs/jsonschema/jsonschema/validators.pyi b/packages/pyright-internal/typeshed-fallback/stubs/jsonschema/jsonschema/validators.pyi index 72ef1f6cfc..a6f39402fc 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/jsonschema/jsonschema/validators.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/jsonschema/jsonschema/validators.pyi @@ -107,7 +107,7 @@ class RefResolver: @property def base_uri(self): ... @contextmanager - def in_scope(self, scope) -> Generator[None, None, None]: ... + def in_scope(self, scope) -> Generator[None]: ... @contextmanager def resolving(self, ref) -> Generator[Incomplete, None, None]: ... def resolve(self, ref): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/networkx/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/networkx/METADATA.toml index d808108cfb..ace417a7f4 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/networkx/METADATA.toml +++ b/packages/pyright-internal/typeshed-fallback/stubs/networkx/METADATA.toml @@ -1,8 +1,9 @@ version = "3.2.1" upstream_repository = "https://github.com/networkx/networkx" # requires a version of numpy with a `py.typed` file -# TODO: Lots of stubtest errors when using numpy 2 -requires = ["numpy>=1.20,<2"] +# see https://github.com/python/typeshed/issues/12551 +# on why we need the upper bound +requires = ["numpy>=1.20,<2.1.0"] partial_stub = true [tool.stubtest] diff --git a/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/digraph.pyi b/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/digraph.pyi index 1636f6307c..2c3476e703 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/digraph.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/digraph.pyi @@ -1,28 +1,28 @@ from _typeshed import Incomplete from collections.abc import Iterator +from functools import cached_property from networkx.classes.coreviews import AdjacencyView from networkx.classes.graph import Graph, _Node -from networkx.classes.reportviews import ( - InDegreeView, - InEdgeView, - InMultiDegreeView, - OutDegreeView, - OutEdgeView, - OutMultiDegreeView, -) +from networkx.classes.reportviews import DiDegreeView, OutEdgeView class DiGraph(Graph[_Node]): - succ: AdjacencyView[_Node, _Node, dict[str, Incomplete]] - pred: AdjacencyView[_Node, _Node, dict[str, Incomplete]] + @cached_property + def succ(self) -> AdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... + @cached_property + def pred(self) -> AdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... def has_successor(self, u: _Node, v: _Node) -> bool: ... def has_predecessor(self, u: _Node, v: _Node) -> bool: ... def successors(self, n: _Node) -> Iterator[_Node]: ... def predecessors(self, n: _Node) -> Iterator[_Node]: ... - in_edges: InEdgeView[_Node] - in_degree: InDegreeView[_Node] | InMultiDegreeView[_Node] # ugly hack to make MultiDiGraph work - out_edges: OutEdgeView[_Node] - out_degree: OutDegreeView[_Node] | OutMultiDegreeView[_Node] # ugly hack to make MultiDiGraph work + @cached_property + def out_edges(self) -> OutEdgeView[_Node]: ... + @cached_property + def in_edges(self) -> OutEdgeView[_Node]: ... + @cached_property + def in_degree(self) -> DiDegreeView[_Node]: ... + @cached_property + def out_degree(self) -> DiDegreeView[_Node]: ... def to_undirected(self, reciprocal: bool = False, as_view: bool = False): ... # type: ignore[override] # Has an additional `reciprocal` keyword argument def reverse(self, copy: bool = True) -> DiGraph[_Node]: ... def copy(self, as_view: bool = False) -> DiGraph[_Node]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/graph.pyi b/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/graph.pyi index 9edca89f48..ea92cb7e31 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/graph.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/graph.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, Mapping, MutableMapping +from functools import cached_property from typing import Any, ClassVar, TypeVar, overload from typing_extensions import Self, TypeAlias @@ -33,13 +34,17 @@ class Graph(Collection[_Node]): edge_attr_dict_factory: ClassVar[_MapFactory] = ... graph_attr_dict_factory: ClassVar[_MapFactory] = ... + graph: dict[str, Any] + def to_directed_class(self) -> type[DiGraph[_Node]]: ... def to_undirected_class(self) -> type[Graph[_Node]]: ... def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr) -> None: ... - - adj: AdjacencyView[_Node, _Node, dict[str, Incomplete]] - name: str - + @cached_property + def adj(self) -> AdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... + @property + def name(self) -> str: ... + @name.setter + def name(self, s: str) -> None: ... def __getitem__(self, n: _Node) -> AtlasView[_Node, _Node, dict[str, Incomplete]]: ... def __iter__(self) -> Iterator[_Node]: ... def __contains__(self, n: object) -> bool: ... @@ -48,7 +53,8 @@ class Graph(Collection[_Node]): def add_nodes_from(self, nodes_for_adding: Iterable[_NodePlus[_Node]], **attr) -> None: ... def remove_node(self, n: _Node) -> None: ... def remove_nodes_from(self, nodes: Iterable[_Node]) -> None: ... - nodes: NodeView[_Node] + @cached_property + def nodes(self) -> NodeView[_Node]: ... def number_of_nodes(self) -> int: ... def order(self) -> int: ... def has_node(self, n: _Node) -> bool: ... @@ -67,12 +73,12 @@ class Graph(Collection[_Node]): ) -> None: ... def has_edge(self, u: _Node, v: _Node) -> bool: ... def neighbors(self, n: _Node) -> Iterator[_Node]: ... - edges: OutEdgeView[_Node] + @cached_property + def edges(self) -> OutEdgeView[_Node]: ... def get_edge_data(self, u: _Node, v: _Node, default: Incomplete | None = None) -> Mapping[str, Incomplete]: ... def adjacency(self) -> Iterator[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ... - - degree: DiDegreeView[_Node] - + @cached_property + def degree(self) -> DiDegreeView[_Node]: ... def clear(self) -> None: ... def clear_edges(self) -> None: ... def is_multigraph(self) -> bool: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/multidigraph.pyi b/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/multidigraph.pyi index 8f90911ec1..e9a2b91b1c 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/multidigraph.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/multidigraph.pyi @@ -1,12 +1,25 @@ +from _typeshed import Incomplete +from functools import cached_property + +from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.classes.multigraph import MultiGraph -from networkx.classes.reportviews import InMultiDegreeView, MultiDegreeView, OutMultiDegreeView +from networkx.classes.reportviews import InMultiDegreeView, OutMultiDegreeView, OutMultiEdgeView class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]): - degree: MultiDegreeView[_Node] - in_degree: InMultiDegreeView[_Node] - out_degree: OutMultiDegreeView[_Node] + @cached_property + def succ(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... + @cached_property + def pred(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... + @cached_property + def out_edges(self) -> OutMultiEdgeView[_Node]: ... + @cached_property + def in_edges(self) -> OutMultiEdgeView[_Node]: ... + @cached_property + def in_degree(self) -> InMultiDegreeView[_Node]: ... + @cached_property + def out_degree(self) -> OutMultiDegreeView[_Node]: ... def to_undirected(self, reciprocal: bool = False, as_view: bool = False) -> MultiGraph[_Node]: ... # type: ignore def reverse(self, copy: bool = True) -> MultiDiGraph[_Node]: ... def copy(self, as_view: bool = False) -> MultiDiGraph[_Node]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/multigraph.pyi b/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/multigraph.pyi index 9462bd64cf..fac0920609 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/multigraph.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/networkx/networkx/classes/multigraph.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete +from functools import cached_property from typing_extensions import TypeAlias +from networkx.classes.coreviews import MultiAdjacencyView from networkx.classes.graph import Graph, _Node from networkx.classes.multidigraph import MultiDiGraph @@ -8,6 +10,8 @@ _MultiEdge: TypeAlias = tuple[_Node, _Node, int] # noqa: Y047 class MultiGraph(Graph[_Node]): def __init__(self, incoming_graph_data: Incomplete | None = None, multigraph_input: bool | None = None, **attr) -> None: ... + @cached_property + def adj(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ... def new_edge_key(self, u: _Node, v: _Node) -> int: ... def add_edge(self, u_for_edge, v_for_edge, key: Incomplete | None = None, **attr): ... # type: ignore[override] # Has an additional `key` keyword argument def remove_edge(self, u, v, key: Incomplete | None = None): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/cell/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/cell/__init__.pyi index 92212f351e..725383e2bc 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/cell/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/cell/__init__.pyi @@ -1,5 +1,6 @@ from datetime import date, datetime, time, timedelta from decimal import Decimal +from typing import Any from typing_extensions import TypeAlias from openpyxl.cell.rich_text import CellRichText @@ -20,3 +21,4 @@ _CellValue: TypeAlias = ( # noqa: Y047 # Used in other modules | DataTableFormula | ArrayFormula ) +_AnyCellValue: TypeAlias = Any # Any of _CellValue # noqa: Y047 # Used in other modules diff --git a/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/chart/series.pyi b/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/chart/series.pyi index fe34bc76bf..3cad7ed070 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/chart/series.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/chart/series.pyi @@ -83,7 +83,9 @@ class Series(Serialisable): explosion: _HasTagAndGet[ConvertibleToInt | None] | ConvertibleToInt | None = None, extLst: Unused = None, ) -> None: ... - def to_tree(self, tagname: str | None = None, idx: _HasTagAndGet[ConvertibleToInt] | ConvertibleToInt | None = None) -> Element: ... # type: ignore[override] + def to_tree( # type: ignore[override] + self, tagname: str | None = None, idx: _HasTagAndGet[ConvertibleToInt] | ConvertibleToInt | None = None + ) -> Element: ... class XYSeries(Series): # Same as parent diff --git a/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/_reader.pyi b/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/_reader.pyi index 9b9b21bc01..feec1c6c5d 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/_reader.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/openpyxl/openpyxl/worksheet/_reader.pyi @@ -1,9 +1,10 @@ from _typeshed import Incomplete, SupportsGetItem, Unused from collections.abc import Container, Generator from datetime import datetime -from typing import Any, Final +from typing import Final from xml.etree.ElementTree import _FileRead +from openpyxl.cell import _AnyCellValue from openpyxl.cell.cell import Cell from openpyxl.cell.rich_text import CellRichText from openpyxl.descriptors.serialisable import _ChildSerialisableTreeElement, _SerialisableTreeElement @@ -86,12 +87,10 @@ class WorkSheetParser: ) -> None: ... def parse(self) -> Generator[Incomplete, None, None]: ... def parse_dimensions(self) -> _RangeBoundariesTuple | None: ... - # AnyOf[time, date, datetime, timedelta, float, int, bool, str, ArrayFormula, DataTableFormula, Translator, Text, TextBlock, CellRichText, None] - def parse_cell(self, element) -> dict[str, Any]: ... + def parse_cell(self, element) -> dict[str, _AnyCellValue]: ... def parse_formula(self, element): ... def parse_column_dimensions(self, col: _HasAttrib) -> None: ... - # Any: Same as parse_cell - def parse_row(self, row: _SupportsIterAndAttrib) -> tuple[int, list[dict[str, Any]]]: ... + def parse_row(self, row: _SupportsIterAndAttrib) -> tuple[int, list[dict[str, _AnyCellValue]]]: ... def parse_formatting(self, element: _ChildSerialisableTreeElement) -> None: ... def parse_sheet_protection(self, element: _SerialisableTreeElement) -> None: ... def parse_extensions(self, element: _ChildSerialisableTreeElement) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/METADATA.toml deleted file mode 100644 index 8b467422de..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/METADATA.toml +++ /dev/null @@ -1,3 +0,0 @@ -version = "1.6.*" -upstream_repository = "https://github.com/eclipse/paho.mqtt.python" -obsolete_since = "2.0.0" # Released on 2024-02-10 diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/__init__.pyi deleted file mode 100644 index ce4f3fba06..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -class MQTTException(Exception): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/client.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/client.pyi deleted file mode 100644 index 35111866ff..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/client.pyi +++ /dev/null @@ -1,331 +0,0 @@ -import logging -import socket as _socket -import ssl as _ssl -import time -import types -from _typeshed import Incomplete, Unused -from collections.abc import Callable -from typing import Any, TypeVar -from typing_extensions import TypeAlias - -from .matcher import MQTTMatcher as MQTTMatcher -from .properties import Properties as Properties -from .reasoncodes import ReasonCodes as ReasonCodes -from .subscribeoptions import SubscribeOptions as SubscribeOptions - -ssl: types.ModuleType | None -socks: types.ModuleType | None -time_func = time.monotonic -HAVE_DNS: bool -EAGAIN: int | Incomplete -MQTTv31: int -MQTTv311: int -MQTTv5: int -unicode = str -basestring = str -CONNECT: int -CONNACK: int -PUBLISH: int -PUBACK: int -PUBREC: int -PUBREL: int -PUBCOMP: int -SUBSCRIBE: int -SUBACK: int -UNSUBSCRIBE: int -UNSUBACK: int -PINGREQ: int -PINGRESP: int -DISCONNECT: int -AUTH: int -MQTT_LOG_INFO: int -MQTT_LOG_NOTICE: int -MQTT_LOG_WARNING: int -MQTT_LOG_ERR: int -MQTT_LOG_DEBUG: int -LOGGING_LEVEL: dict[int, int] -CONNACK_ACCEPTED: int -CONNACK_REFUSED_PROTOCOL_VERSION: int -CONNACK_REFUSED_IDENTIFIER_REJECTED: int -CONNACK_REFUSED_SERVER_UNAVAILABLE: int -CONNACK_REFUSED_BAD_USERNAME_PASSWORD: int -CONNACK_REFUSED_NOT_AUTHORIZED: int -mqtt_cs_new: int -mqtt_cs_connected: int -mqtt_cs_disconnecting: int -mqtt_cs_connect_async: int -mqtt_ms_invalid: int -mqtt_ms_publish: int -mqtt_ms_wait_for_puback: int -mqtt_ms_wait_for_pubrec: int -mqtt_ms_resend_pubrel: int -mqtt_ms_wait_for_pubrel: int -mqtt_ms_resend_pubcomp: int -mqtt_ms_wait_for_pubcomp: int -mqtt_ms_send_pubrec: int -mqtt_ms_queued: int -MQTT_ERR_AGAIN: int -MQTT_ERR_SUCCESS: int -MQTT_ERR_NOMEM: int -MQTT_ERR_PROTOCOL: int -MQTT_ERR_INVAL: int -MQTT_ERR_NO_CONN: int -MQTT_ERR_CONN_REFUSED: int -MQTT_ERR_NOT_FOUND: int -MQTT_ERR_CONN_LOST: int -MQTT_ERR_TLS: int -MQTT_ERR_PAYLOAD_SIZE: int -MQTT_ERR_NOT_SUPPORTED: int -MQTT_ERR_AUTH: int -MQTT_ERR_ACL_DENIED: int -MQTT_ERR_UNKNOWN: int -MQTT_ERR_ERRNO: int -MQTT_ERR_QUEUE_SIZE: int -MQTT_ERR_KEEPALIVE: int -MQTT_CLIENT: int -MQTT_BRIDGE: int -MQTT_CLEAN_START_FIRST_ONLY: int -sockpair_data: bytes -_UserData: TypeAlias = Any -_Socket: TypeAlias = _socket.socket | _ssl.SSLSocket | Incomplete -_Payload: TypeAlias = str | bytes | bytearray | float -_ExtraHeader: TypeAlias = dict[str, str] | Callable[[dict[str, str]], dict[str, str]] -_OnLog: TypeAlias = Callable[[Client, _UserData, int, str], object] -_OnConnect: TypeAlias = Callable[[Client, _UserData, dict[str, int], int], object] -_OnConnectV5: TypeAlias = Callable[[Client, _UserData, dict[str, int], ReasonCodes, Properties | None], object] -_TOnConnect = TypeVar("_TOnConnect", _OnConnect, _OnConnectV5) -_OnConnectFail: TypeAlias = Callable[[Client, _UserData], object] -_OnSubscribe: TypeAlias = Callable[[Client, _UserData, int, tuple[int]], object] -_OnSubscribeV5: TypeAlias = Callable[[Client, _UserData, int, list[ReasonCodes], Properties], object] -_TOnSubscribe = TypeVar("_TOnSubscribe", _OnSubscribe, _OnSubscribeV5) -_OnMessage: TypeAlias = Callable[[Client, _UserData, MQTTMessage], object] -_OnPublish: TypeAlias = Callable[[Client, _UserData, int], object] -_OnUnsubscribe: TypeAlias = Callable[[Client, _UserData, int], object] -_OnUnsubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Properties, list[ReasonCodes] | ReasonCodes], object] -_TOnUnsubscribe = TypeVar("_TOnUnsubscribe", _OnUnsubscribe, _OnUnsubscribeV5) -_OnDisconnect: TypeAlias = Callable[[Client, _UserData, int], object] -_OnDisconnectV5: TypeAlias = Callable[[Client, _UserData, ReasonCodes | None, Properties | None], object] -_TOnDisconnect = TypeVar("_TOnDisconnect", _OnDisconnect, _OnDisconnectV5) -_OnSocket: TypeAlias = Callable[[Client, _UserData, _Socket | WebsocketWrapper | None], object] - -class WebsocketConnectionError(ValueError): ... - -def error_string(mqtt_errno: int) -> str: ... -def connack_string(connack_code: int) -> str: ... -def base62(num: int, base: str = ..., padding: int = 1) -> str: ... -def topic_matches_sub(sub: str, topic: str) -> bool: ... - -class MQTTMessageInfo: - mid: int - rc: int - def __init__(self, mid: int) -> None: ... - def __iter__(self) -> MQTTMessageInfo: ... - def __next__(self) -> int: ... - def next(self) -> int: ... - def __getitem__(self, index: int) -> int: ... - def wait_for_publish(self, timeout: float | None = None) -> None: ... - def is_published(self) -> bool: ... - -class MQTTMessage: - timestamp: int - state: int - dup: bool - mid: int - payload: bytes | bytearray - qos: int - retain: bool - info: MQTTMessageInfo - properties: Properties | None - def __init__(self, mid: int = 0, topic: bytes | bytearray = b"") -> None: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - @property - def topic(self) -> str: ... - @topic.setter - def topic(self, value: bytes | bytearray) -> None: ... - -class Client: - suppress_exceptions: bool - def __init__( - self, - client_id: str | None = "", - clean_session: bool | None = None, - userdata: _UserData | None = None, - protocol: int = 4, - transport: str = "tcp", - reconnect_on_failure: bool = True, - ) -> None: ... - def __del__(self) -> None: ... - def reinitialise(self, client_id: str = "", clean_session: bool = True, userdata: _UserData | None = None) -> None: ... - def ws_set_options(self, path: str = "/mqtt", headers: _ExtraHeader | None = None) -> None: ... - def tls_set_context(self, context: _ssl.SSLContext | None = None) -> None: ... - def tls_set( - self, - ca_certs: str | None = None, - certfile: str | None = None, - keyfile: str | None = None, - cert_reqs: _ssl.VerifyMode | None = None, - tls_version: _ssl._SSLMethod | None = None, - ciphers: str | None = None, - keyfile_password: _ssl._PasswordType | None = None, - ) -> None: ... - def tls_insecure_set(self, value: bool) -> None: ... - def proxy_set(self, **proxy_args: Any) -> None: ... - def enable_logger(self, logger: logging.Logger | None = None) -> None: ... - def disable_logger(self) -> None: ... - def connect( - self, - host: str, - port: int = 1883, - keepalive: int = 60, - bind_address: str = "", - bind_port: int = 0, - clean_start: int = 3, - properties: Properties | None = None, - ) -> int: ... - def connect_srv( - self, - domain: str | None = None, - keepalive: int = 60, - bind_address: str = "", - clean_start: int = 3, - properties: Properties | None = None, - ) -> int: ... - def connect_async( - self, - host: str, - port: int = 1883, - keepalive: int = 60, - bind_address: str = "", - bind_port: int = 0, - clean_start: int = 3, - properties: Properties | None = None, - ) -> None: ... - def reconnect_delay_set(self, min_delay: int = 1, max_delay: int = 120) -> None: ... - def reconnect(self) -> int: ... - def loop(self, timeout: float = 1.0, max_packets: int = 1) -> int: ... - def publish( - self, - topic: str, - payload: _Payload | None = None, - qos: int = 0, - retain: bool = False, - properties: Properties | None = None, - ) -> MQTTMessageInfo: ... - def username_pw_set(self, username: str, password: str | bytes | bytearray | None = None) -> None: ... - def enable_bridge_mode(self) -> None: ... - def is_connected(self) -> bool: ... - def disconnect(self, reasoncode: ReasonCodes | None = None, properties: Properties | None = None) -> int: ... - def subscribe( - self, - topic: str | tuple[str, SubscribeOptions] | list[tuple[str, SubscribeOptions]] | list[tuple[str, int]], - qos: int = 0, - options: SubscribeOptions | None = None, - properties: Properties | None = None, - ) -> tuple[int, int]: ... - def unsubscribe(self, topic: str | list[str], properties: Properties | None = None) -> tuple[int, int]: ... - def loop_read(self, max_packets: int = 1) -> int: ... - def loop_write(self, max_packets: int = 1) -> int: ... - def want_write(self) -> bool: ... - def loop_misc(self) -> int: ... - def max_inflight_messages_set(self, inflight: int) -> None: ... - def max_queued_messages_set(self, queue_size: int) -> Client: ... - def message_retry_set(self, retry: Unused) -> None: ... - def user_data_set(self, userdata: _UserData) -> None: ... - def will_set( - self, - topic: str, - payload: _Payload | None = None, - qos: int = 0, - retain: bool = False, - properties: Properties | None = None, - ) -> None: ... - def will_clear(self) -> None: ... - def socket(self) -> _Socket | WebsocketWrapper: ... - def loop_forever(self, timeout: float = 1.0, max_packets: int = 1, retry_first_connection: bool = False) -> int: ... - def loop_start(self) -> int | None: ... - def loop_stop(self, force: bool = False) -> int | None: ... - @property - def on_log(self) -> _OnLog | None: ... - @on_log.setter - def on_log(self, func: _OnLog | None) -> None: ... - def log_callback(self) -> Callable[[_OnLog], _OnLog]: ... - @property - def on_connect(self) -> _OnConnect | _OnConnectV5 | None: ... - @on_connect.setter - def on_connect(self, func: _OnConnect | _OnConnectV5 | None) -> None: ... - def connect_callback(self) -> Callable[[_TOnConnect], _TOnConnect]: ... - @property - def on_connect_fail(self) -> _OnConnectFail | None: ... - @on_connect_fail.setter - def on_connect_fail(self, func: _OnConnectFail | None) -> None: ... - def connect_fail_callback(self) -> Callable[[_OnConnectFail], _OnConnectFail]: ... - @property - def on_subscribe(self) -> _OnSubscribe | _OnSubscribeV5 | None: ... - @on_subscribe.setter - def on_subscribe(self, func: _OnSubscribe | _OnSubscribeV5 | None) -> None: ... - def subscribe_callback(self) -> Callable[[_TOnSubscribe], _TOnSubscribe]: ... - @property - def on_message(self) -> _OnMessage | None: ... - @on_message.setter - def on_message(self, func: _OnMessage | None) -> None: ... - def message_callback(self) -> Callable[[_OnMessage], _OnMessage]: ... - @property - def on_publish(self) -> _OnPublish | None: ... - @on_publish.setter - def on_publish(self, func: _OnPublish | None) -> None: ... - def publish_callback(self) -> Callable[[_OnPublish], _OnPublish]: ... - @property - def on_unsubscribe(self) -> _OnUnsubscribe | _OnUnsubscribeV5 | None: ... - @on_unsubscribe.setter - def on_unsubscribe(self, func: _OnUnsubscribe | _OnUnsubscribeV5 | None) -> None: ... - def unsubscribe_callback(self) -> Callable[[_TOnUnsubscribe], _TOnUnsubscribe]: ... - @property - def on_disconnect(self) -> _OnDisconnect | _OnDisconnectV5 | None: ... - @on_disconnect.setter - def on_disconnect(self, func: _OnDisconnect | _OnDisconnectV5 | None) -> None: ... - def disconnect_callback(self) -> Callable[[_TOnDisconnect], _TOnDisconnect]: ... - @property - def on_socket_open(self) -> _OnSocket | None: ... - @on_socket_open.setter - def on_socket_open(self, func: _OnSocket | None) -> None: ... - def socket_open_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... - @property - def on_socket_close(self) -> _OnSocket | None: ... - @on_socket_close.setter - def on_socket_close(self, func: _OnSocket | None) -> None: ... - def socket_close_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... - @property - def on_socket_register_write(self) -> _OnSocket | None: ... - @on_socket_register_write.setter - def on_socket_register_write(self, func: _OnSocket | None) -> None: ... - def socket_register_write_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... - @property - def on_socket_unregister_write(self) -> _OnSocket | None: ... - @on_socket_unregister_write.setter - def on_socket_unregister_write(self, func: _OnSocket | None) -> None: ... - def socket_unregister_write_callback(self) -> Callable[[_OnSocket], _OnSocket]: ... - def message_callback_add(self, sub: str, callback: _OnMessage) -> None: ... - def topic_callback(self, sub: str) -> Callable[[_OnMessage], _OnMessage]: ... - def message_callback_remove(self, sub: str) -> None: ... - -class WebsocketWrapper: - OPCODE_CONTINUATION: int - OPCODE_TEXT: int - OPCODE_BINARY: int - OPCODE_CONNCLOSE: int - OPCODE_PING: int - OPCODE_PONG: int - connected: bool - def __init__( - self, socket: _Socket, host: str, port: int, is_ssl: bool, path: str, extra_headers: _ExtraHeader | None - ) -> None: ... - def __del__(self) -> None: ... - def recv(self, length: int) -> bytes | bytearray | None: ... - def read(self, length: int) -> bytes | bytearray | None: ... - def send(self, data: bytes | bytearray) -> int: ... - def write(self, data: bytes | bytearray) -> int: ... - def close(self) -> None: ... - def fileno(self) -> int: ... - def pending(self) -> int: ... - def setblocking(self, flag: bool) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/matcher.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/matcher.pyi deleted file mode 100644 index 549ac1b36a..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/matcher.pyi +++ /dev/null @@ -1,11 +0,0 @@ -from collections.abc import Generator -from typing import Any - -class MQTTMatcher: - class Node: ... - - def __init__(self) -> None: ... - def __setitem__(self, key: str, value: Any) -> None: ... - def __getitem__(self, key: str) -> Any: ... - def __delitem__(self, key: str) -> None: ... - def iter_match(self, topic: str) -> Generator[Any, None, None]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/packettypes.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/packettypes.pyi deleted file mode 100644 index 2fe5644e58..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/packettypes.pyi +++ /dev/null @@ -1,19 +0,0 @@ -class PacketTypes: - indexes: range - CONNECT: int - CONNACK: int - PUBLISH: int - PUBACK: int - PUBREC: int - PUBREL: int - PUBCOMP: int - SUBSCRIBE: int - SUBACK: int - UNSUBSCRIBE: int - UNSUBACK: int - PINGREQ: int - PINGRESP: int - DISCONNECT: int - AUTH: int - WILLMESSAGE: int - Names: list[str] diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/properties.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/properties.pyi deleted file mode 100644 index 174a6a0e54..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/properties.pyi +++ /dev/null @@ -1,38 +0,0 @@ -from typing import Any - -from . import MQTTException as MQTTException - -class MalformedPacket(MQTTException): ... - -def writeInt16(length: int) -> bytearray: ... -def readInt16(buf: bytes) -> int: ... -def writeInt32(length: int) -> bytearray: ... -def readInt32(buf: bytes) -> int: ... -def writeUTF(data: str | bytes) -> bytearray: ... -def readUTF(buffer: bytes, maxlen: int) -> tuple[str, int]: ... -def writeBytes(buffer: bytes) -> bytearray: ... -def readBytes(buffer: bytes) -> tuple[bytes, int]: ... - -class VariableByteIntegers: - @staticmethod - def encode(x: int) -> bytes: ... - @staticmethod - def decode(buffer: bytes) -> tuple[int, int]: ... - -class Properties: - packetType: int - types: list[str] - names: dict[str, int] - properties: dict[int, tuple[int, list[int]]] - def __init__(self, packetType: int) -> None: ... - def allowsMultiple(self, compressedName: str) -> bool: ... - def getIdentFromName(self, compressedName: str) -> int: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def json(self) -> dict[str, Any]: ... - def isEmpty(self) -> bool: ... - def clear(self) -> None: ... - def writeProperty(self, identifier: int, type: int, value: Any) -> bytes: ... - def pack(self) -> bytes: ... - def readProperty(self, buffer: bytes, type: int, propslen: int) -> Any: ... - def getNameFromIdent(self, identifier: int) -> str | None: ... - def unpack(self, buffer: bytes) -> tuple[Properties, int]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/publish.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/publish.pyi deleted file mode 100644 index 581408f7c1..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/publish.pyi +++ /dev/null @@ -1,63 +0,0 @@ -import ssl -from collections.abc import Iterable -from typing import TypedDict -from typing_extensions import NotRequired, TypeAlias - -_Payload: TypeAlias = str | bytes | bytearray | float - -class _Msg(TypedDict): - topic: str - payload: NotRequired[_Payload | None] - qos: NotRequired[int] - retain: NotRequired[int] - -class _Auth(TypedDict): - username: str - password: NotRequired[str] - -class _TLS(TypedDict): - ca_certs: str - certfile: NotRequired[str] - keyfile: NotRequired[str] - tls_version: NotRequired[ssl._SSLMethod] - ciphers: NotRequired[str] - insecure: NotRequired[str] - cert_reqs: NotRequired[ssl.VerifyMode] - keyfile_password: NotRequired[ssl._PasswordType] - -class _Proxy(TypedDict): - proxy_type: int - proxy_addr: str - proxy_rdns: NotRequired[bool] - proxy_username: NotRequired[str] - proxy_passwor: NotRequired[str] - -def multiple( - msgs: Iterable[_Msg], - hostname: str = "localhost", - port: int = 1883, - client_id: str = "", - keepalive: int = 60, - will: _Msg | None = None, - auth: _Auth | None = None, - tls: _TLS | None = None, - protocol: int = 4, - transport: str = "tcp", - proxy_args: _Proxy | None = None, -) -> None: ... -def single( - topic: str, - payload: _Payload | None = None, - qos: int | None = 0, - retain: bool | None = False, - hostname: str = "localhost", - port: int = 1883, - client_id: str = "", - keepalive: int = 60, - will: _Msg | None = None, - auth: _Auth | None = None, - tls: _TLS | None = None, - protocol: int = 4, - transport: str = "tcp", - proxy_args: _Proxy | None = None, -) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/reasoncodes.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/reasoncodes.pyi deleted file mode 100644 index ff63229442..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/reasoncodes.pyi +++ /dev/null @@ -1,13 +0,0 @@ -class ReasonCodes: - packetType: int - names: dict[int, dict[str, list[int]]] - value: int - def __init__(self, packetType: int, aName: str = "Success", identifier: int = -1) -> None: ... - def __getName__(self, packetType: int, identifier: int) -> str: ... - def getId(self, name: str) -> int: ... - def set(self, name: str) -> None: ... - def unpack(self, buffer: bytearray) -> int: ... - def getName(self) -> str: ... - def __eq__(self, other: object) -> bool: ... - def json(self) -> str: ... - def pack(self) -> bytearray: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/subscribe.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/subscribe.pyi deleted file mode 100644 index e7e48255c6..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/subscribe.pyi +++ /dev/null @@ -1,39 +0,0 @@ -from collections.abc import Callable - -from .client import Client, MQTTMessage, _UserData -from .publish import _TLS, _Auth, _Msg, _Proxy - -def callback( - callback: Callable[[Client, _UserData, MQTTMessage], None], - topics: list[str], - qos: int = 0, - userdata: _UserData | None = None, - hostname: str = "localhost", - port: int = 1883, - client_id: str = "", - keepalive: int = 60, - will: _Msg | None = None, - auth: _Auth | None = None, - tls: _TLS | None = None, - protocol: int = 4, - transport: str = "tcp", - clean_session: bool = True, - proxy_args: _Proxy | None = None, -) -> None: ... -def simple( - topics: str | list[str], - qos: int = 0, - msg_count: int = 1, - retained: bool = True, - hostname: str = "localhost", - port: int = 1883, - client_id: str = "", - keepalive: int = 60, - will: _Msg | None = None, - auth: _Auth | None = None, - tls: _TLS | None = None, - protocol: int = 4, - transport: str = "tcp", - clean_session: bool = True, - proxy_args: _Proxy | None = None, -) -> list[MQTTMessage] | MQTTMessage: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/subscribeoptions.pyi b/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/subscribeoptions.pyi deleted file mode 100644 index 6ca40acdde..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/paho-mqtt/paho/mqtt/subscribeoptions.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from typing import Any, TypedDict - -from . import MQTTException as MQTTException - -class _SubscribeOptionsJson(TypedDict): - QoS: int - noLocal: bool - retainAsPublished: bool - retainHandling: int - -class SubscribeOptions: - RETAIN_SEND_ON_SUBSCRIBE: int - RETAIN_SEND_IF_NEW_SUB: int - RETAIN_DO_NOT_SEND: int - names: list[str] - Qos: int - noLocal: bool - retainAsPublished: bool - retainHandling: int - def __init__(self, qos: int = 0, noLocal: bool = False, retainAsPublished: bool = False, retainHandling: int = 0) -> None: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def pack(self) -> bytes: ... - def unpack(self, buffer: bytes | bytearray) -> int: ... - def json(self) -> _SubscribeOptionsJson: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/passlib/passlib/utils/handlers.pyi b/packages/pyright-internal/typeshed-fallback/stubs/passlib/passlib/utils/handlers.pyi index a89e28e401..edb743617b 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/passlib/passlib/utils/handlers.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/passlib/passlib/utils/handlers.pyi @@ -84,7 +84,9 @@ class HasManyIdents(GenericHandler): ident_aliases: ClassVar[dict[str, str] | None] ident: str # type: ignore[misc] @classmethod - def using(cls, default_ident: Incomplete | None = None, ident: Incomplete | None = None, **kwds): ... # type: ignore[override] + def using( # type: ignore[override] + cls, default_ident: Incomplete | None = None, ident: Incomplete | None = None, **kwds + ): ... def __init__(self, ident: Incomplete | None = None, **kwds) -> None: ... class HasSalt(GenericHandler): @@ -95,7 +97,9 @@ class HasSalt(GenericHandler): default_salt_chars: ClassVar[str | None] salt: str | bytes | None @classmethod - def using(cls, default_salt_size: int | None = None, salt_size: int | None = None, salt: str | bytes | None = None, **kwds): ... # type: ignore[override] + def using( # type: ignore[override] + cls, default_salt_size: int | None = None, salt_size: int | None = None, salt: str | bytes | None = None, **kwds + ): ... def __init__(self, salt: str | bytes | None = None, **kwds) -> None: ... @classmethod def bitsize(cls, salt_size: int | None = None, **kwds): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/peewee/peewee.pyi b/packages/pyright-internal/typeshed-fallback/stubs/peewee/peewee.pyi index dc5c1642e7..8299d6ca79 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/peewee/peewee.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/peewee/peewee.pyi @@ -98,7 +98,7 @@ class Context: def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None ) -> None: ... - def push_alias(self) -> Generator[None, None, None]: ... + def push_alias(self) -> Generator[None]: ... def sql(self, obj): ... def literal(self, keyword): ... def value(self, value, converter: Incomplete | None = ..., add_param: bool = ...): ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/polib/polib.pyi b/packages/pyright-internal/typeshed-fallback/stubs/polib/polib.pyi index 6a8251125d..0788fe8ca3 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/polib/polib.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/polib/polib.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import IO, Any, Generic, SupportsIndex, TypeVar, overload +from typing import IO, Any, Generic, Literal, SupportsIndex, TypeVar, overload _TB = TypeVar("_TB", bound=_BaseEntry) _TP = TypeVar("_TP", bound=POFile) @@ -38,7 +38,9 @@ class _BaseFile(list[_TB]): def insert(self, index: SupportsIndex, entry: _TB) -> None: ... def metadata_as_entry(self) -> POEntry: ... def save(self, fpath: str | None = ..., repr_method: str = ..., newline: str | None = ...) -> None: ... - def find(self, st: str, by: str = ..., include_obsolete_entries: bool = ..., msgctxt: bool = ...) -> _TB | None: ... + def find( + self, st: str, by: str = ..., include_obsolete_entries: bool = ..., msgctxt: str | Literal[False] = ... + ) -> _TB | None: ... def ordered_metadata(self) -> list[tuple[str, str]]: ... def to_binary(self) -> bytes: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/psycopg2/psycopg2/_psycopg.pyi b/packages/pyright-internal/typeshed-fallback/stubs/psycopg2/psycopg2/_psycopg.pyi index fec234993e..e4c9a995bd 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -217,7 +217,7 @@ class ConnectionInfo: # [1]: https://www.psycopg.org/docs/extensions.html#psycopg2.extensions.ConnectionInfo # [2]: https://github.com/psycopg/psycopg2/blob/1d3a89a0bba621dc1cc9b32db6d241bd2da85ad1/psycopg/conninfo_type.c#L52 and below # [3]: https://www.postgresql.org/docs/current/libpq-status.html - # [4]: https://github.com/postgres/postgres/blob/b39838889e76274b107935fa8e8951baf0e8b31b/src/interfaces/libpq/fe-connect.c#L6754 and below + # [4]: https://github.com/postgres/postgres/blob/b39838889e76274b107935fa8e8951baf0e8b31b/src/interfaces/libpq/fe-connect.c#L6754 and below # noqa: E501 @property def backend_pid(self) -> int: ... @property diff --git a/packages/pyright-internal/typeshed-fallback/stubs/pyflakes/pyflakes/checker.pyi b/packages/pyright-internal/typeshed-fallback/stubs/pyflakes/pyflakes/checker.pyi index 4a18d8d703..0d60f10dcd 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/pyflakes/pyflakes/checker.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/pyflakes/pyflakes/checker.pyi @@ -1,6 +1,6 @@ import ast import sys -from collections.abc import Callable, Iterable, Iterator +from collections.abc import Callable, Generator, Iterable, Iterator from contextlib import contextmanager from re import Pattern from typing import Any, ClassVar, Literal, TypeVar, overload @@ -203,7 +203,7 @@ class Checker: @property def scope(self) -> Scope: ... @contextmanager - def in_scope(self, cls: Callable[[], Scope]) -> Iterator[None]: ... + def in_scope(self, cls: Callable[[], Scope]) -> Generator[None]: ... def checkDeadScopes(self) -> None: ... def report(self, messageClass: Callable[_P, Message], *args: _P.args, **kwargs: _P.kwargs) -> None: ... def getParent(self, node: ast.AST) -> ast.AST: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/pygit2/pygit2/utils.pyi b/packages/pyright-internal/typeshed-fallback/stubs/pygit2/pygit2/utils.pyi index 5fee3112f2..5bffb9cd2f 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/pygit2/pygit2/utils.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/pygit2/pygit2/utils.pyi @@ -1,7 +1,7 @@ import contextlib import types from _typeshed import StrOrBytesPath, StrPath -from collections.abc import Iterator +from collections.abc import Generator from typing import Generic, TypeVar from typing_extensions import TypeAlias @@ -12,7 +12,7 @@ def to_bytes(s: _CDataBase | StrOrBytesPath | None, encoding: str = "utf-8", err def to_str(s: StrOrBytesPath) -> str: ... def ptr_to_bytes(ptr_cdata: _CDataBase) -> bytes: ... @contextlib.contextmanager -def new_git_strarray() -> Iterator[_GitStrArray]: ... +def new_git_strarray() -> Generator[_GitStrArray]: ... def strarray_to_strings(arr: _GitStrArray) -> list[str]: ... # Actual type: _cffi_backend.__CDataOwn diff --git a/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/METADATA.toml index 395fc9f723..93e986d027 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/METADATA.toml +++ b/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/METADATA.toml @@ -1,6 +1,2 @@ -version = "6.9.*" +version = "6.10.*" upstream_repository = "https://github.com/pyinstaller/pyinstaller" -requires = ["types-setuptools"] - -[tool.stubtest] -extras = ["completion"] diff --git a/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/PyInstaller/building/splash.pyi b/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/PyInstaller/building/splash.pyi index da76b1162b..1caae6c82b 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/PyInstaller/building/splash.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/PyInstaller/building/splash.pyi @@ -42,5 +42,4 @@ class Splash(Target): always_on_top: bool = True, ) -> None: ... def assemble(self) -> None: ... - def test_tk_version(self) -> None: ... def generate_script(self) -> str: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/PyInstaller/compat.pyi b/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/PyInstaller/compat.pyi index 72e3d48b02..05a1440e19 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/PyInstaller/compat.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/pyinstaller/PyInstaller/compat.pyi @@ -14,6 +14,7 @@ is_py39: Final[bool] is_py310: Final[bool] is_py311: Final[bool] is_py312: Final[bool] +is_py313: Final[bool] is_win: Final[bool] is_win_10: Final[bool] is_win_11: Final[bool] @@ -31,6 +32,7 @@ is_musl: Final[bool] is_macos_11_compat: Final[bool] is_macos_11_native: Final[bool] is_macos_11: Final[bool] +is_nogil: Final[bool] PYDYLIB_NAMES: Final[set[str]] base_prefix: Final[str] is_venv: Final[bool] diff --git a/packages/pyright-internal/typeshed-fallback/stubs/pynput/pynput/keyboard/_base.pyi b/packages/pyright-internal/typeshed-fallback/stubs/pynput/pynput/keyboard/_base.pyi index 69cc5cad0a..60eb21d285 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/pynput/pynput/keyboard/_base.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/pynput/pynput/keyboard/_base.pyi @@ -1,7 +1,7 @@ import contextlib import enum import sys -from collections.abc import Callable, Iterable, Iterator +from collections.abc import Callable, Generator, Iterable, Iterator from typing import Any, ClassVar from typing_extensions import Self @@ -108,7 +108,7 @@ class Controller: def tap(self, key: str | Key | KeyCode) -> None: ... def touch(self, key: str | Key | KeyCode, is_press: bool) -> None: ... @contextlib.contextmanager - def pressed(self, *args: str | Key | KeyCode) -> Iterator[None]: ... + def pressed(self, *args: str | Key | KeyCode) -> Generator[None]: ... def type(self, string: str) -> None: ... @property def modifiers(self) -> contextlib.AbstractContextManager[Iterator[set[Key]]]: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/METADATA.toml deleted file mode 100644 index 0998ef19db..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/METADATA.toml +++ /dev/null @@ -1,3 +0,0 @@ -version = "8.0.2" -upstream_repository = "https://github.com/un33k/python-slugify" -obsolete_since = "8.0.2" # Released on 2024-01-25 diff --git a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/__init__.pyi deleted file mode 100644 index 2d77c5af91..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/__init__.pyi +++ /dev/null @@ -1,12 +0,0 @@ -from .__version__ import ( - __author__ as __author__, - __author_email__ as __author_email__, - __copyright__ as __copyright__, - __description__ as __description__, - __license__ as __license__, - __title__ as __title__, - __url__ as __url__, - __version__ as __version__, -) -from .slugify import * -from .special import * diff --git a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/__version__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/__version__.pyi deleted file mode 100644 index ed1591f36f..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/__version__.pyi +++ /dev/null @@ -1,8 +0,0 @@ -__title__: str -__author__: str -__author_email__: str -__description__: str -__url__: str -__license__: str -__copyright__: str -__version__: str diff --git a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/slugify.pyi b/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/slugify.pyi deleted file mode 100644 index 585e18fa3a..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/slugify.pyi +++ /dev/null @@ -1,20 +0,0 @@ -from collections.abc import Iterable - -def smart_truncate( - string: str, max_length: int = 0, word_boundary: bool = False, separator: str = " ", save_order: bool = False -) -> str: ... -def slugify( - text: str, - entities: bool = True, - decimal: bool = True, - hexadecimal: bool = True, - max_length: int = 0, - word_boundary: bool = False, - separator: str = "-", - save_order: bool = False, - stopwords: Iterable[str] = (), - regex_pattern: str | None = None, - lowercase: bool = True, - replacements: Iterable[Iterable[str]] = (), - allow_unicode: bool = False, -) -> str: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/special.pyi b/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/special.pyi deleted file mode 100644 index 2d1da58e83..0000000000 --- a/packages/pyright-internal/typeshed-fallback/stubs/python-slugify/slugify/special.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from collections.abc import Sequence - -def add_uppercase_char(char_list: Sequence[tuple[str, str]]) -> Sequence[tuple[str, str]]: ... - -CYRILLIC: Sequence[tuple[str, str]] -GERMAN: Sequence[tuple[str, str]] -GREEK: Sequence[tuple[str, str]] -PRE_TRANSLATIONS: Sequence[tuple[str, str]] diff --git a/packages/pyright-internal/typeshed-fallback/stubs/redis/redis/client.pyi b/packages/pyright-internal/typeshed-fallback/stubs/redis/redis/client.pyi index 9368b8c597..62acef13f7 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/redis/redis/client.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/redis/redis/client.pyi @@ -485,7 +485,9 @@ class Pipeline(Redis[_StrType]): def slowlog_reset(self) -> Pipeline[_StrType]: ... # type: ignore[override] def time(self) -> Pipeline[_StrType]: ... # type: ignore[override] def append(self, key, value) -> Pipeline[_StrType]: ... - def bitcount(self, key: _Key, start: int | None = None, end: int | None = None, mode: str | None = None) -> Pipeline[_StrType]: ... # type: ignore[override] + def bitcount( # type: ignore[override] + self, key: _Key, start: int | None = None, end: int | None = None, mode: str | None = None + ) -> Pipeline[_StrType]: ... def bitop(self, operation, dest, *keys) -> Pipeline[_StrType]: ... def bitpos(self, key, bit, start=None, end=None, mode: str | None = None) -> Pipeline[_StrType]: ... def decr(self, name, amount=1) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -494,7 +496,9 @@ class Pipeline(Redis[_StrType]): def dump(self, name) -> Pipeline[_StrType]: ... # type: ignore[override] def exists(self, *names: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] def __contains__(self, *names: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] - def expire(self, name: _Key, time: int | timedelta, nx: bool = False, xx: bool = False, gt: bool = False, lt: bool = False) -> Pipeline[_StrType]: ... # type: ignore[override] + def expire( # type: ignore[override] + self, name: _Key, time: int | timedelta, nx: bool = False, xx: bool = False, gt: bool = False, lt: bool = False + ) -> Pipeline[_StrType]: ... def expireat( self, name, when, nx: bool = False, xx: bool = False, gt: bool = False, lt: bool = False ) -> Pipeline[_StrType]: ... @@ -512,8 +516,12 @@ class Pipeline(Redis[_StrType]): def msetnx(self, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... # type: ignore[override] def move(self, name: _Key, db: int) -> Pipeline[_StrType]: ... # type: ignore[override] def persist(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] - def pexpire(self, name: _Key, time: int | timedelta, nx: bool = False, xx: bool = False, gt: bool = False, lt: bool = False) -> Pipeline[_StrType]: ... # type: ignore[override] - def pexpireat(self, name: _Key, when: int | datetime, nx: bool = False, xx: bool = False, gt: bool = False, lt: bool = False) -> Pipeline[_StrType]: ... # type: ignore[override] + def pexpire( # type: ignore[override] + self, name: _Key, time: int | timedelta, nx: bool = False, xx: bool = False, gt: bool = False, lt: bool = False + ) -> Pipeline[_StrType]: ... + def pexpireat( # type: ignore[override] + self, name: _Key, when: int | datetime, nx: bool = False, xx: bool = False, gt: bool = False, lt: bool = False + ) -> Pipeline[_StrType]: ... def psetex(self, name, time_ms, value) -> Pipeline[_StrType]: ... def pttl(self, name) -> Pipeline[_StrType]: ... # type: ignore[override] def randomkey(self) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -598,7 +606,9 @@ class Pipeline(Redis[_StrType]): store: _Key | None = None, groups: bool = False, ) -> Pipeline[_StrType]: ... - def scan(self, cursor: int = 0, match: _Key | None = None, count: int | None = None, _type: str | None = None) -> Pipeline[_StrType]: ... # type: ignore[override] + def scan( # type: ignore[override] + self, cursor: int = 0, match: _Key | None = None, count: int | None = None, _type: str | None = None + ) -> Pipeline[_StrType]: ... def scan_iter(self, match: _Key | None = None, count: int | None = None, _type: str | None = None) -> Iterator[Any]: ... # type: ignore[override] def sscan(self, name: _Key, cursor: int = 0, match: _Key | None = None, count: int | None = None) -> Pipeline[_StrType]: ... # type: ignore[override] def sscan_iter(self, name: _Key, match: _Key | None = None, count: int | None = None) -> Iterator[Any]: ... @@ -680,7 +690,9 @@ class Pipeline(Redis[_StrType]): def zcard(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] def zcount(self, name: _Key, min: _Value, max: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] def zincrby(self, name: _Key, amount: float, value: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] - def zinterstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] | None = None) -> Pipeline[_StrType]: ... # type: ignore[override] + def zinterstore( # type: ignore[override] + self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] | None = None + ) -> Pipeline[_StrType]: ... def zlexcount(self, name: _Key, min: _Value, max: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] def zpopmax(self, name: _Key, count: int | None = None) -> Pipeline[_StrType]: ... # type: ignore[override] def zpopmin(self, name: _Key, count: int | None = None) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -699,7 +711,9 @@ class Pipeline(Redis[_StrType]): offset: int | None = None, num: int | None = None, ) -> Pipeline[_StrType]: ... - def zrangebylex(self, name: _Key, min: _Value, max: _Value, start: int | None = None, num: int | None = None) -> Pipeline[_StrType]: ... # type: ignore[override] + def zrangebylex( # type: ignore[override] + self, name: _Key, min: _Value, max: _Value, start: int | None = None, num: int | None = None + ) -> Pipeline[_StrType]: ... def zrangebyscore( # type: ignore[override] self, name: _Key, @@ -733,7 +747,9 @@ class Pipeline(Redis[_StrType]): ) -> Pipeline[_StrType]: ... def zrevrank(self, name: _Key, value: _Value, withscore: bool = False) -> Pipeline[_StrType]: ... # type: ignore[override] def zscore(self, name: _Key, value: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] - def zunionstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] | None = None) -> Pipeline[_StrType]: ... # type: ignore[override] + def zunionstore( # type: ignore[override] + self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] | None = None + ) -> Pipeline[_StrType]: ... def pfadd(self, name: _Key, *values: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] def pfcount(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] def pfmerge(self, dest: _Key, *sources: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] diff --git a/packages/pyright-internal/typeshed-fallback/stubs/reportlab/reportlab/platypus/doctemplate.pyi b/packages/pyright-internal/typeshed-fallback/stubs/reportlab/reportlab/platypus/doctemplate.pyi index c61877b51c..d5557db149 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/reportlab/reportlab/platypus/doctemplate.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/reportlab/reportlab/platypus/doctemplate.pyi @@ -264,4 +264,10 @@ class BaseDocTemplate: class SimpleDocTemplate(BaseDocTemplate): def handle_pageBegin(self) -> None: ... - def build(self, flowables: list[Flowable], onFirstPage: _PageCallback = ..., onLaterPages: _PageCallback = ..., canvasmaker: _CanvasMaker = ...) -> None: ... # type: ignore[override] + def build( # type: ignore[override] + self, + flowables: list[Flowable], + onFirstPage: _PageCallback = ..., + onLaterPages: _PageCallback = ..., + canvasmaker: _CanvasMaker = ..., + ) -> None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/seaborn/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/seaborn/METADATA.toml index 4c5367456c..4603b91ba7 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/seaborn/METADATA.toml +++ b/packages/pyright-internal/typeshed-fallback/stubs/seaborn/METADATA.toml @@ -1,6 +1,8 @@ version = "0.13.2" # Requires a version of numpy and matplotlib with a `py.typed` file -requires = ["matplotlib>=3.8", "numpy>=1.20", "pandas-stubs"] +# see https://github.com/python/typeshed/issues/12551 +# on why we need the upper bound for numpy +requires = ["matplotlib>=3.8", "numpy>=1.20,<2.1.0", "pandas-stubs"] # matplotlib>=3.8 requires Python >=3.9 requires_python = ">=3.9" upstream_repository = "https://github.com/mwaskom/seaborn" diff --git a/packages/pyright-internal/typeshed-fallback/stubs/seaborn/seaborn/_core/plot.pyi b/packages/pyright-internal/typeshed-fallback/stubs/seaborn/seaborn/_core/plot.pyi index e2398daeb4..d5574f604f 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/seaborn/seaborn/_core/plot.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/seaborn/seaborn/_core/plot.pyi @@ -46,7 +46,7 @@ class PairSpec(TypedDict, total=False): wrap: int | None @contextmanager -def theme_context(params: dict[str, Any]) -> Generator[None, None, None]: ... +def theme_context(params: dict[str, Any]) -> Generator[None]: ... def build_plot_signature(cls: _ClsT) -> _ClsT: ... # -> _ClsT & "__signature__ protocol" class ThemeConfig(mpl.RcParams): diff --git a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/__init__.pyi b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/__init__.pyi index 0bfb669200..c2875da23e 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/__init__.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/__init__.pyi @@ -1,15 +1,39 @@ from _typeshed import Incomplete, StrPath from abc import abstractmethod from collections.abc import Iterable, Mapping, Sequence -from typing import Any, TypeVar, overload +from typing import Any, Literal, TypeVar, overload from ._distutils.cmd import Command as _Command +from .command.alias import alias +from .command.bdist_egg import bdist_egg +from .command.bdist_rpm import bdist_rpm +from .command.bdist_wheel import bdist_wheel +from .command.build import build +from .command.build_clib import build_clib +from .command.build_ext import build_ext +from .command.build_py import build_py +from .command.develop import develop +from .command.dist_info import dist_info +from .command.easy_install import easy_install +from .command.editable_wheel import editable_wheel +from .command.egg_info import egg_info +from .command.install import install +from .command.install_egg_info import install_egg_info +from .command.install_lib import install_lib +from .command.install_scripts import install_scripts +from .command.register import register +from .command.rotate import rotate +from .command.saveopts import saveopts +from .command.sdist import sdist +from .command.setopt import setopt +from .command.upload import upload +from .command.upload_docs import upload_docs from .depends import Require as Require from .dist import Distribution as Distribution from .extension import Extension as Extension from .warnings import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning -_CommandT = TypeVar("_CommandT", bound=_Command) +_CommandT = TypeVar("_CommandT", bound=Command) __all__ = [ "setup", @@ -79,8 +103,116 @@ class Command(_Command): # Any: Dynamic command subclass attributes def __init__(self, dist: Distribution, **kw: Any) -> None: ... def ensure_string_list(self, option: str) -> None: ... - @overload # Extra **kw param - def reinitialize_command(self, command: str, reinit_subcommands: bool = False, **kw) -> _Command: ... + # Note: Commands that setuptools doesn't re-expose are considered deprecated (they must be imported from distutils directly) + # So we're not listing them here. This list comes directly from the setuptools/command folder. Minus the test command. + @overload # type: ignore[override] + def get_finalized_command(self, command: Literal["alias"], create: bool | Literal[0, 1] = 1) -> alias: ... + @overload + def get_finalized_command(self, command: Literal["bdist_egg"], create: bool | Literal[0, 1] = 1) -> bdist_egg: ... + @overload + def get_finalized_command(self, command: Literal["bdist_rpm"], create: bool | Literal[0, 1] = 1) -> bdist_rpm: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["bdist_wheel"], create: bool | Literal[0, 1] = 1) -> bdist_wheel: ... + @overload + def get_finalized_command(self, command: Literal["build"], create: bool | Literal[0, 1] = 1) -> build: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["build_clib"], create: bool | Literal[0, 1] = 1) -> build_clib: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["build_ext"], create: bool | Literal[0, 1] = 1) -> build_ext: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["build_py"], create: bool | Literal[0, 1] = 1) -> build_py: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["develop"], create: bool | Literal[0, 1] = 1) -> develop: ... + @overload + def get_finalized_command(self, command: Literal["dist_info"], create: bool | Literal[0, 1] = 1) -> dist_info: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["easy_install"], create: bool | Literal[0, 1] = 1) -> easy_install: ... + @overload + def get_finalized_command(self, command: Literal["editable_wheel"], create: bool | Literal[0, 1] = 1) -> editable_wheel: ... + @overload + def get_finalized_command(self, command: Literal["egg_info"], create: bool | Literal[0, 1] = 1) -> egg_info: ... + @overload + def get_finalized_command(self, command: Literal["install"], create: bool | Literal[0, 1] = 1) -> install: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command( + self, command: Literal["install_egg_info"], create: bool | Literal[0, 1] = 1 + ) -> install_egg_info: ... + @overload + def get_finalized_command(self, command: Literal["install_lib"], create: bool | Literal[0, 1] = 1) -> install_lib: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["install_scripts"], create: bool | Literal[0, 1] = 1) -> install_scripts: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["register"], create: bool | Literal[0, 1] = 1) -> register: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["rotate"], create: bool | Literal[0, 1] = 1) -> rotate: ... + @overload + def get_finalized_command(self, command: Literal["saveopts"], create: bool | Literal[0, 1] = 1) -> saveopts: ... + @overload + def get_finalized_command(self, command: Literal["sdist"], create: bool | Literal[0, 1] = 1) -> sdist: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["setopt"], create: bool | Literal[0, 1] = 1) -> setopt: ... + @overload + def get_finalized_command(self, command: Literal["upload"], create: bool | Literal[0, 1] = 1) -> upload: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: Literal["upload_docs"], create: bool | Literal[0, 1] = 1) -> upload_docs: ... # type: ignore[overload-overlap] + @overload + def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ... + @overload # type: ignore[override] # Extra **kw param + def reinitialize_command(self, command: Literal["alias"], reinit_subcommands: bool = False, **kw) -> alias: ... + @overload + def reinitialize_command(self, command: Literal["bdist_egg"], reinit_subcommands: bool = False, **kw) -> bdist_egg: ... + @overload + def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False, **kw) -> bdist_rpm: ... + @overload + def reinitialize_command(self, command: Literal["bdist_wheel"], reinit_subcommands: bool = False, **kw) -> bdist_wheel: ... + @overload + def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool = False, **kw) -> build: ... + @overload + def reinitialize_command(self, command: Literal["build_clib"], reinit_subcommands: bool = False, **kw) -> build_clib: ... + @overload + def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool = False, **kw) -> build_ext: ... + @overload + def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool = False, **kw) -> build_py: ... + @overload + def reinitialize_command(self, command: Literal["develop"], reinit_subcommands: bool = False, **kw) -> develop: ... + @overload + def reinitialize_command(self, command: Literal["dist_info"], reinit_subcommands: bool = False, **kw) -> dist_info: ... + @overload + def reinitialize_command(self, command: Literal["easy_install"], reinit_subcommands: bool = False, **kw) -> easy_install: ... + @overload + def reinitialize_command( + self, command: Literal["editable_wheel"], reinit_subcommands: bool = False, **kw + ) -> editable_wheel: ... + @overload + def reinitialize_command(self, command: Literal["egg_info"], reinit_subcommands: bool = False, **kw) -> egg_info: ... + @overload + def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool = False, **kw) -> install: ... + @overload + def reinitialize_command( + self, command: Literal["install_egg_info"], reinit_subcommands: bool = False, **kw + ) -> install_egg_info: ... + @overload + def reinitialize_command(self, command: Literal["install_lib"], reinit_subcommands: bool = False, **kw) -> install_lib: ... + @overload + def reinitialize_command( + self, command: Literal["install_scripts"], reinit_subcommands: bool = False, **kw + ) -> install_scripts: ... + @overload + def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool = False, **kw) -> register: ... + @overload + def reinitialize_command(self, command: Literal["rotate"], reinit_subcommands: bool = False, **kw) -> rotate: ... + @overload + def reinitialize_command(self, command: Literal["saveopts"], reinit_subcommands: bool = False, **kw) -> saveopts: ... + @overload + def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool = False, **kw) -> sdist: ... + @overload + def reinitialize_command(self, command: Literal["setopt"], reinit_subcommands: bool = False, **kw) -> setopt: ... + @overload + def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool = False, **kw) -> upload: ... + @overload + def reinitialize_command(self, command: Literal["upload_docs"], reinit_subcommands: bool = False, **kw) -> upload_docs: ... + @overload + def reinitialize_command(self, command: str, reinit_subcommands: bool = False, **kw) -> Command: ... @overload def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False, **kw) -> _CommandT: ... @abstractmethod diff --git a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/cmd.pyi b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/cmd.pyi index 42310b8cfb..97133a6dc2 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/cmd.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/cmd.pyi @@ -31,6 +31,8 @@ class Command: def ensure_dirname(self, option: str) -> None: ... def get_command_name(self) -> str: ... def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ... + # NOTE: Because this is private setuptools implementation and we don't re-expose all commands here, + # we're not overloading each and every command possibility. def get_finalized_command(self, command: str, create: bool = True) -> Command: ... @overload def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/dist.pyi b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/dist.pyi index e363c0b69b..e814c15cb4 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -64,10 +64,6 @@ class Distribution: def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ... def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ... - @overload - def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ... - @overload - def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ... global_options: ClassVar[_OptionsList] common_usage: ClassVar[str] display_options: ClassVar[_OptionsList] @@ -109,6 +105,12 @@ class Distribution: def print_commands(self) -> None: ... def get_command_list(self): ... def get_command_packages(self): ... + # NOTE: Because this is private setuptools implementation and we don't re-expose all commands here, + # we're not overloading each and every command possibility. + @overload + def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ... + @overload + def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ... def get_command_class(self, command: str) -> type[Command]: ... @overload def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/sysconfig.pyi b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/sysconfig.pyi index 0848e593e7..dca1990fa0 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/sysconfig.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/_distutils/sysconfig.pyi @@ -1,10 +1,10 @@ -from typing import Literal, overload +from typing import Final, Literal, overload from typing_extensions import deprecated from setuptools._distutils.ccompiler import CCompiler -PREFIX: str -EXEC_PREFIX: str +PREFIX: Final[str] +EXEC_PREFIX: Final[str] @overload @deprecated("SO is deprecated, use EXT_SUFFIX. Support will be removed when this module is synchronized with stdlib Python 3.11") diff --git a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/dist.pyi b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/dist.pyi index 51d4d0e893..5948c073d8 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/dist.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/dist.pyi @@ -1,8 +1,35 @@ from _typeshed import Incomplete, StrPath from collections.abc import Iterable, Iterator, MutableMapping +from typing import Literal, TypeVar, overload from . import Command, SetuptoolsDeprecationWarning from ._distutils.dist import Distribution as _Distribution +from .command.alias import alias +from .command.bdist_egg import bdist_egg +from .command.bdist_rpm import bdist_rpm +from .command.bdist_wheel import bdist_wheel +from .command.build import build +from .command.build_clib import build_clib +from .command.build_ext import build_ext +from .command.build_py import build_py +from .command.develop import develop +from .command.dist_info import dist_info +from .command.easy_install import easy_install +from .command.editable_wheel import editable_wheel +from .command.egg_info import egg_info +from .command.install import install +from .command.install_egg_info import install_egg_info +from .command.install_lib import install_lib +from .command.install_scripts import install_scripts +from .command.register import register +from .command.rotate import rotate +from .command.saveopts import saveopts +from .command.sdist import sdist +from .command.setopt import setopt +from .command.upload import upload +from .command.upload_docs import upload_docs + +_CommandT = TypeVar("_CommandT", bound=Command) __all__ = ["Distribution"] @@ -17,7 +44,165 @@ class Distribution(_Distribution): def fetch_build_eggs(self, requires: str | Iterable[str]): ... def get_egg_cache_dir(self) -> str: ... def fetch_build_egg(self, req): ... + # NOTE: Commands that setuptools doesn't re-expose are considered deprecated (they must be imported from distutils directly) + # So we're not listing them here. This list comes directly from the setuptools/command folder. Minus the test command. + @overload # type: ignore[override] + def get_command_obj(self, command: Literal["alias"], create: Literal[1, True] = 1) -> alias: ... + @overload + def get_command_obj(self, command: Literal["bdist_egg"], create: Literal[1, True] = 1) -> bdist_egg: ... + @overload + def get_command_obj(self, command: Literal["bdist_rpm"], create: Literal[1, True] = 1) -> bdist_rpm: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["bdist_wheel"], create: Literal[1, True] = 1) -> bdist_wheel: ... + @overload + def get_command_obj(self, command: Literal["build"], create: Literal[1, True] = 1) -> build: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["build_clib"], create: Literal[1, True] = 1) -> build_clib: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["build_ext"], create: Literal[1, True] = 1) -> build_ext: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["build_py"], create: Literal[1, True] = 1) -> build_py: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["develop"], create: Literal[1, True] = 1) -> develop: ... + @overload + def get_command_obj(self, command: Literal["dist_info"], create: Literal[1, True] = 1) -> dist_info: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["easy_install"], create: Literal[1, True] = 1) -> easy_install: ... + @overload + def get_command_obj(self, command: Literal["editable_wheel"], create: Literal[1, True] = 1) -> editable_wheel: ... + @overload + def get_command_obj(self, command: Literal["egg_info"], create: Literal[1, True] = 1) -> egg_info: ... + @overload + def get_command_obj(self, command: Literal["install"], create: Literal[1, True] = 1) -> install: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["install_egg_info"], create: Literal[1, True] = 1) -> install_egg_info: ... + @overload + def get_command_obj(self, command: Literal["install_lib"], create: Literal[1, True] = 1) -> install_lib: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["install_scripts"], create: Literal[1, True] = 1) -> install_scripts: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["register"], create: Literal[1, True] = 1) -> register: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["rotate"], create: Literal[1, True] = 1) -> rotate: ... + @overload + def get_command_obj(self, command: Literal["saveopts"], create: Literal[1, True] = 1) -> saveopts: ... + @overload + def get_command_obj(self, command: Literal["sdist"], create: Literal[1, True] = 1) -> sdist: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["setopt"], create: Literal[1, True] = 1) -> setopt: ... + @overload + def get_command_obj(self, command: Literal["upload"], create: Literal[1, True] = 1) -> upload: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: Literal["upload_docs"], create: Literal[1, True] = 1) -> upload_docs: ... # type: ignore[overload-overlap] + @overload + def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ... + # Not replicating the overloads for "Command | None", user may use "isinstance" + @overload + def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ... + @overload + def get_command_class(self, command: Literal["alias"]) -> type[alias]: ... + @overload + def get_command_class(self, command: Literal["bdist_egg"]) -> type[bdist_egg]: ... + @overload + def get_command_class(self, command: Literal["bdist_rpm"]) -> type[bdist_rpm]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["bdist_wheel"]) -> type[bdist_wheel]: ... + @overload + def get_command_class(self, command: Literal["build"]) -> type[build]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["build_clib"]) -> type[build_clib]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["build_ext"]) -> type[build_ext]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["build_py"]) -> type[build_py]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["develop"]) -> type[develop]: ... + @overload + def get_command_class(self, command: Literal["dist_info"]) -> type[dist_info]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["easy_install"]) -> type[easy_install]: ... + @overload + def get_command_class(self, command: Literal["editable_wheel"]) -> type[editable_wheel]: ... + @overload + def get_command_class(self, command: Literal["egg_info"]) -> type[egg_info]: ... + @overload + def get_command_class(self, command: Literal["install"]) -> type[install]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["install_egg_info"]) -> type[install_egg_info]: ... + @overload + def get_command_class(self, command: Literal["install_lib"]) -> type[install_lib]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["install_scripts"]) -> type[install_scripts]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["register"]) -> type[register]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["rotate"]) -> type[rotate]: ... + @overload + def get_command_class(self, command: Literal["saveopts"]) -> type[saveopts]: ... + @overload + def get_command_class(self, command: Literal["sdist"]) -> type[sdist]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["setopt"]) -> type[setopt]: ... + @overload + def get_command_class(self, command: Literal["upload"]) -> type[upload]: ... # type: ignore[overload-overlap] + @overload + def get_command_class(self, command: Literal["upload_docs"]) -> type[upload_docs]: ... # type: ignore[overload-overlap] + @overload def get_command_class(self, command: str) -> type[Command]: ... + @overload # type: ignore[override] + def reinitialize_command(self, command: Literal["alias"], reinit_subcommands: bool = False) -> alias: ... + @overload + def reinitialize_command(self, command: Literal["bdist_egg"], reinit_subcommands: bool = False) -> bdist_egg: ... + @overload + def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False) -> bdist_rpm: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["bdist_wheel"], reinit_subcommands: bool = False) -> bdist_wheel: ... + @overload + def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool = False) -> build: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["build_clib"], reinit_subcommands: bool = False) -> build_clib: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool = False) -> build_ext: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool = False) -> build_py: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["develop"], reinit_subcommands: bool = False) -> develop: ... + @overload + def reinitialize_command(self, command: Literal["dist_info"], reinit_subcommands: bool = False) -> dist_info: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["easy_install"], reinit_subcommands: bool = False) -> easy_install: ... + @overload + def reinitialize_command(self, command: Literal["editable_wheel"], reinit_subcommands: bool = False) -> editable_wheel: ... + @overload + def reinitialize_command(self, command: Literal["egg_info"], reinit_subcommands: bool = False) -> egg_info: ... + @overload + def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool = False) -> install: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command( + self, command: Literal["install_egg_info"], reinit_subcommands: bool = False + ) -> install_egg_info: ... + @overload + def reinitialize_command(self, command: Literal["install_lib"], reinit_subcommands: bool = False) -> install_lib: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["install_scripts"], reinit_subcommands: bool = False) -> install_scripts: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool = False) -> register: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["rotate"], reinit_subcommands: bool = False) -> rotate: ... + @overload + def reinitialize_command(self, command: Literal["saveopts"], reinit_subcommands: bool = False) -> saveopts: ... + @overload + def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool = False) -> sdist: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["setopt"], reinit_subcommands: bool = False) -> setopt: ... + @overload + def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool = False) -> upload: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: Literal["upload_docs"], reinit_subcommands: bool = False) -> upload_docs: ... # type: ignore[overload-overlap] + @overload + def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... + @overload + def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ... def include(self, **attrs) -> None: ... def exclude_package(self, package: str) -> None: ... def has_contents_for(self, package: str) -> bool | None: ... diff --git a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/wheel.pyi b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/wheel.pyi index 240e43d1ec..ae56166a85 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/wheel.pyi +++ b/packages/pyright-internal/typeshed-fallback/stubs/setuptools/setuptools/wheel.pyi @@ -5,7 +5,7 @@ WHEEL_NAME: Incomplete NAMESPACE_PACKAGE_INIT: str def unpack(src_dir, dst_dir) -> None: ... -def disable_info_traces() -> Generator[None, None, None]: ... +def disable_info_traces() -> Generator[None]: ... class Wheel: filename: Incomplete diff --git a/packages/pyright-internal/typeshed-fallback/stubs/shapely/METADATA.toml b/packages/pyright-internal/typeshed-fallback/stubs/shapely/METADATA.toml index e12eb3f77a..db229f6921 100644 --- a/packages/pyright-internal/typeshed-fallback/stubs/shapely/METADATA.toml +++ b/packages/pyright-internal/typeshed-fallback/stubs/shapely/METADATA.toml @@ -1,4 +1,6 @@ version = "2.0.*" # Requires a version of numpy with a `py.typed` file -requires = ["numpy>=1.20"] +# see https://github.com/python/typeshed/issues/12551 +# on why we need the upper bound for numpy +requires = ["numpy>=1.20,<2.1.0"] upstream_repository = "https://github.com/shapely/shapely" diff --git a/packages/pyright/package-lock.json b/packages/pyright/package-lock.json index 8930519ee0..b26bbfe0b5 100644 --- a/packages/pyright/package-lock.json +++ b/packages/pyright/package-lock.json @@ -1,12 +1,12 @@ { "name": "basedpyright", - "version": "1.1.376", + "version": "1.1.377", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "basedpyright", - "version": "1.1.376", + "version": "1.1.377", "license": "MIT", "bin": { "pyright": "index.js", diff --git a/packages/pyright/package.json b/packages/pyright/package.json index 8366b7b1dc..2da28a9133 100644 --- a/packages/pyright/package.json +++ b/packages/pyright/package.json @@ -2,7 +2,7 @@ "name": "basedpyright", "displayName": "basedpyright", "description": "a pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server", - "version": "1.1.376", + "version": "1.1.377", "license": "MIT", "author": { "name": "detachhead" diff --git a/packages/vscode-pyright/package-lock.json b/packages/vscode-pyright/package-lock.json index 2242b247dd..3b2cb0dc00 100644 --- a/packages/vscode-pyright/package-lock.json +++ b/packages/vscode-pyright/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-pyright", - "version": "1.1.376", + "version": "1.1.377", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-pyright", - "version": "1.1.376", + "version": "1.1.377", "license": "MIT", "dependencies": { "@vscode/python-extension": "^1.0.5", diff --git a/packages/vscode-pyright/package.json b/packages/vscode-pyright/package.json index 132e497943..2bd5cc5cd7 100644 --- a/packages/vscode-pyright/package.json +++ b/packages/vscode-pyright/package.json @@ -2,7 +2,7 @@ "name": "vscode-pyright", "displayName": "BasedPyright", "description": "VS Code static type checking for Python (but based)", - "version": "1.1.376", + "version": "1.1.377", "private": true, "license": "MIT", "author": {