@zzzen/pyright-internal 1.2.0-dev.20230903 → 1.2.0-dev.20230910
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/checker.js +39 -14
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +5 -0
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructors.js +16 -7
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +2 -0
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +16 -1
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/importResolver.js +4 -7
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.js +1 -1
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/program.d.ts +2 -2
- package/dist/analyzer/program.js +30 -24
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +10 -8
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.js +14 -12
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +1 -1
- package/dist/analyzer/typeEvaluator.js +162 -102
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +9 -8
- package/dist/analyzer/typeEvaluatorTypes.js +11 -8
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +38 -6
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +6 -4
- package/dist/analyzer/typeUtils.js +81 -54
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +1 -0
- package/dist/analyzer/types.js +8 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/common/configOptions.js +2 -2
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/extensibility.d.ts +6 -0
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/pathUtils.d.ts +2 -15
- package/dist/common/pathUtils.js +9 -84
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.js +22 -13
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/languageServerBase.d.ts +1 -1
- package/dist/languageServerBase.js +2 -2
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +3 -2
- package/dist/languageService/completionProvider.js +12 -6
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +9 -0
- package/dist/localization/localize.js +7 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +8 -2
- package/dist/localization/package.nls.de.json +8 -2
- package/dist/localization/package.nls.en-us.json +9 -3
- package/dist/localization/package.nls.es.json +8 -2
- package/dist/localization/package.nls.fr.json +8 -2
- package/dist/localization/package.nls.it.json +8 -2
- package/dist/localization/package.nls.ja.json +8 -2
- package/dist/localization/package.nls.ko.json +8 -2
- package/dist/localization/package.nls.pl.json +8 -2
- package/dist/localization/package.nls.pt-br.json +8 -2
- package/dist/localization/package.nls.qps-ploc.json +8 -2
- package/dist/localization/package.nls.ru.json +8 -2
- package/dist/localization/package.nls.tr.json +8 -2
- package/dist/localization/package.nls.zh-cn.json +8 -2
- package/dist/localization/package.nls.zh-tw.json +8 -2
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/checker.test.js +2 -2
- package/dist/tests/completions.test.js +27 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +5 -5
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js +5 -5
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js +11 -9
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +14 -14
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js +12 -12
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js +9 -9
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js +3 -3
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +3 -3
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js +4 -4
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js +8 -8
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js.map +1 -1
- package/dist/tests/fourslash/fourslash.d.ts +1 -0
- package/dist/tests/fourslash/importnotresolved.fourslash.js +2 -2
- package/dist/tests/fourslash/importnotresolved.fourslash.js.map +1 -1
- package/dist/tests/fourslash/missingModuleSource.fourslash.js +1 -1
- package/dist/tests/fourslash/missingModuleSource.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -0
- package/dist/tests/harness/fourslash/testState.Consts.js +2 -0
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +4 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.js +10 -6
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/pathUtils.test.js +13 -21
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +1 -1
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +5 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +4 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/workspaceFactory.js +8 -14
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
package/dist/analyzer/checker.js
CHANGED
@@ -1105,15 +1105,22 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1105
1105
|
}
|
1106
1106
|
const exprTypeResult = this._evaluator.getTypeOfExpression(expression);
|
1107
1107
|
let isExprFunction = true;
|
1108
|
+
let isCoroutine = false;
|
1108
1109
|
(0, typeUtils_1.doForEachSubtype)(exprTypeResult.type, (subtype) => {
|
1109
1110
|
subtype = this._evaluator.makeTopLevelTypeVarsConcrete(subtype);
|
1110
1111
|
if (!(0, types_1.isFunction)(subtype) && !(0, types_1.isOverloadedFunction)(subtype)) {
|
1111
1112
|
isExprFunction = false;
|
1112
1113
|
}
|
1114
|
+
if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isBuiltIn(subtype, 'Coroutine')) {
|
1115
|
+
isCoroutine = true;
|
1116
|
+
}
|
1113
1117
|
});
|
1114
1118
|
if (isExprFunction) {
|
1115
1119
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, localize_1.Localizer.Diagnostic.functionInConditionalExpression(), expression);
|
1116
1120
|
}
|
1121
|
+
if (isCoroutine) {
|
1122
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, localize_1.Localizer.Diagnostic.coroutineInConditionalExpression(), expression);
|
1123
|
+
}
|
1117
1124
|
}
|
1118
1125
|
_reportUnusedExpression(node) {
|
1119
1126
|
var _a, _b;
|
@@ -1990,18 +1997,24 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1990
1997
|
// is implicitly initialized by the synthesized `__init__` method and
|
1991
1998
|
// therefore has an implied assignment.
|
1992
1999
|
let isImplicitlyAssigned = false;
|
2000
|
+
// Is this a class variable within a protocol class? If so, it can
|
2001
|
+
// be marked final without providing a value.
|
2002
|
+
let isProtocolClass = false;
|
1993
2003
|
if (symbol.isClassMember() && !symbol.isClassVar()) {
|
1994
2004
|
const containingClass = ParseTreeUtils.getEnclosingClass(firstDecl.node, /* stopAtFunction */ true);
|
1995
2005
|
if (containingClass) {
|
1996
2006
|
const classType = this._evaluator.getTypeOfClass(containingClass);
|
1997
|
-
if (classType &&
|
1998
|
-
(
|
1999
|
-
|
2000
|
-
|
2007
|
+
if (classType && (0, types_1.isClass)(classType.decoratedType)) {
|
2008
|
+
if (types_1.ClassType.isDataClass(classType.decoratedType)) {
|
2009
|
+
isImplicitlyAssigned = true;
|
2010
|
+
}
|
2011
|
+
if (types_1.ClassType.isProtocolClass(classType.decoratedType)) {
|
2012
|
+
isProtocolClass = true;
|
2013
|
+
}
|
2001
2014
|
}
|
2002
2015
|
}
|
2003
2016
|
}
|
2004
|
-
if (!isImplicitlyAssigned) {
|
2017
|
+
if (!isImplicitlyAssigned && !isProtocolClass) {
|
2005
2018
|
this._evaluator.addError(localize_1.Localizer.Diagnostic.finalUnassigned().format({ name }), firstDecl.node);
|
2006
2019
|
}
|
2007
2020
|
}
|
@@ -2492,7 +2505,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2492
2505
|
// derives from an unknown type. In this case, we'll add an
|
2493
2506
|
// unknown type into the filtered type list to avoid any
|
2494
2507
|
// false positives.
|
2495
|
-
const isClassRelationshipIndeterminate =
|
2508
|
+
const isClassRelationshipIndeterminate = filterIsSuperclass && filterIsSubclass && !types_1.ClassType.isSameGenericClass(varType, filterType);
|
2496
2509
|
if (isClassRelationshipIndeterminate) {
|
2497
2510
|
filteredTypes.push(types_1.UnknownType.create());
|
2498
2511
|
}
|
@@ -2628,6 +2641,22 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2628
2641
|
}
|
2629
2642
|
let errorMessage;
|
2630
2643
|
let deprecatedMessage;
|
2644
|
+
function getDeprecatedMessageForFunction(functionType) {
|
2645
|
+
if (functionType.details.declaration &&
|
2646
|
+
functionType.details.declaration.node.nodeType === 28 /* Function */) {
|
2647
|
+
const containingClass = ParseTreeUtils.getEnclosingClass(functionType.details.declaration.node,
|
2648
|
+
/* stopAtFunction */ true);
|
2649
|
+
if (containingClass) {
|
2650
|
+
return localize_1.Localizer.Diagnostic.deprecatedMethod().format({
|
2651
|
+
name: functionType.details.name || '<anonymous>',
|
2652
|
+
className: containingClass.name.value,
|
2653
|
+
});
|
2654
|
+
}
|
2655
|
+
}
|
2656
|
+
return localize_1.Localizer.Diagnostic.deprecatedFunction().format({
|
2657
|
+
name: functionType.details.name,
|
2658
|
+
});
|
2659
|
+
}
|
2631
2660
|
function getDeprecatedMessageForOverloadedCall(evaluator, type) {
|
2632
2661
|
// Determine if the node is part of a call expression. If so,
|
2633
2662
|
// we can determine which overload(s) were used to satisfy
|
@@ -2643,9 +2672,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2643
2672
|
if (overload.details.deprecatedMessage !== undefined) {
|
2644
2673
|
if (node.value === overload.details.name) {
|
2645
2674
|
deprecatedMessage = overload.details.deprecatedMessage;
|
2646
|
-
errorMessage =
|
2647
|
-
name: overload.details.name,
|
2648
|
-
});
|
2675
|
+
errorMessage = getDeprecatedMessageForFunction(overload);
|
2649
2676
|
}
|
2650
2677
|
else if ((0, types_1.isInstantiableClass)(type) && overload.details.name === '__init__') {
|
2651
2678
|
deprecatedMessage = overload.details.deprecatedMessage;
|
@@ -2674,9 +2701,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2674
2701
|
else if ((0, types_1.isFunction)(subtype)) {
|
2675
2702
|
if (subtype.details.deprecatedMessage !== undefined && node.value === subtype.details.name) {
|
2676
2703
|
deprecatedMessage = subtype.details.deprecatedMessage;
|
2677
|
-
errorMessage =
|
2678
|
-
name: subtype.details.name || '<anonymous>',
|
2679
|
-
});
|
2704
|
+
errorMessage = getDeprecatedMessageForFunction(subtype);
|
2680
2705
|
}
|
2681
2706
|
}
|
2682
2707
|
else if ((0, types_1.isOverloadedFunction)(subtype)) {
|
@@ -3178,7 +3203,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3178
3203
|
if (!types_1.ClassType.isDataClass(classType)) {
|
3179
3204
|
return;
|
3180
3205
|
}
|
3181
|
-
const postInitMember = (0, typeUtils_1.lookUpClassMember)(classType, '__post_init__', 2 /* SkipBaseClasses */ |
|
3206
|
+
const postInitMember = (0, typeUtils_1.lookUpClassMember)(classType, '__post_init__', 2 /* SkipBaseClasses */ | 32 /* DeclaredTypesOnly */);
|
3182
3207
|
// If there's no __post_init__ method, there's nothing to check.
|
3183
3208
|
if (!postInitMember) {
|
3184
3209
|
return;
|
@@ -3508,7 +3533,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3508
3533
|
// __call__ method, skip this check.
|
3509
3534
|
const metaclass = newMember.classType.details.effectiveMetaclass;
|
3510
3535
|
if (metaclass && (0, types_1.isClass)(metaclass) && !types_1.ClassType.isBuiltIn(metaclass, 'type')) {
|
3511
|
-
const callMethod = (0, typeUtils_1.lookUpClassMember)(metaclass, '__call__',
|
3536
|
+
const callMethod = (0, typeUtils_1.lookUpClassMember)(metaclass, '__call__', 64 /* SkipTypeBaseClass */ | 8 /* SkipInstanceVariables */);
|
3512
3537
|
if (callMethod) {
|
3513
3538
|
return;
|
3514
3539
|
}
|