@zzzen/pyright-internal 1.1.254 → 1.2.0-dev.2022-07-02
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/analyzer/analyzerFileInfo.d.ts +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +1 -0
- package/dist/analyzer/backgroundAnalysisProgram.js +3 -0
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +9 -2
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +19 -26
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.js +33 -0
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/dataClasses.js +6 -4
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.js +11 -1
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/importResult.js +7 -0
- package/dist/analyzer/importResult.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +10 -1
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +1 -1
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/packageTypeReport.js +10 -1
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +11 -2
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/program.d.ts +2 -1
- package/dist/analyzer/program.js +27 -23
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/protocols.js +3 -1
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/scope.js +22 -1
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/service.d.ts +20 -8
- package/dist/analyzer/service.js +39 -19
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +1 -1
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.d.ts +2 -0
- package/dist/analyzer/sourceFileInfoUtils.js +15 -0
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -0
- package/dist/analyzer/symbol.d.ts +3 -1
- package/dist/analyzer/symbol.js +39 -1
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +10 -2
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +86 -32
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +0 -1
- package/dist/analyzer/typeEvaluatorTypes.js +65 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +2 -0
- package/dist/analyzer/typeGuards.js +113 -69
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +23 -1
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +119 -28
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +2 -1
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +1 -0
- package/dist/analyzer/types.js +195 -1
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +1 -1
- package/dist/commands/commands.js +9 -0
- package/dist/commands/commands.js.map +1 -1
- package/dist/common/commandLineOptions.js +8 -1
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/core.js +7 -1
- package/dist/common/core.js.map +1 -1
- package/dist/common/diagnostic.js +9 -1
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/host.js +7 -1
- package/dist/common/host.js.map +1 -1
- package/dist/common/pathUtils.d.ts +1 -0
- package/dist/common/pathUtils.js +34 -1
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/stringUtils.d.ts +1 -0
- package/dist/common/stringUtils.js +8 -1
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +10 -3
- package/dist/languageServerBase.js +40 -14
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +3 -0
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.js +2 -1
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +2 -2
- package/dist/languageService/completionProvider.js +3 -5
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/parser/parseNodes.d.ts +3 -0
- package/dist/parser/parseNodes.js +110 -2
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.d.ts +0 -1
- package/dist/parser/parser.js +26 -12
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +8 -1
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/parser/tokenizerTypes.js +155 -1
- package/dist/parser/tokenizerTypes.js.map +1 -1
- package/dist/pyright.js +6 -1
- package/dist/pyright.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +12 -9
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +4 -0
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/config.test.js +14 -13
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/debug.test.js +6 -0
- package/dist/tests/debug.test.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js +53 -0
- package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js.map +1 -0
- package/dist/tests/fourslash/fourslash.d.ts +16 -0
- package/dist/tests/fourslash/hover.class.docString.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.class.docString.fourslash.js +24 -0
- package/dist/tests/fourslash/hover.class.docString.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/fourSlashParser.js +6 -0
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashTypes.js +19 -1
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +9 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -0
- package/dist/tests/harness/fourslash/testState.Consts.js +1 -0
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +4 -3
- package/dist/tests/harness/fourslash/testState.js +27 -11
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +25 -1
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/pathUtils.test.js +17 -0
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/testUtils.js +1 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +9 -1
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +9 -1
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +4 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/workspaceMap.d.ts +2 -1
- package/dist/workspaceMap.js +25 -3
- package/dist/workspaceMap.js.map +1 -1
- package/package.json +45 -44
package/dist/analyzer/checker.js
CHANGED
@@ -57,6 +57,7 @@ const staticExpressions_1 = require("./staticExpressions");
|
|
57
57
|
const SymbolNameUtils = __importStar(require("./symbolNameUtils"));
|
58
58
|
const symbolUtils_1 = require("./symbolUtils");
|
59
59
|
const typeEvaluator_1 = require("./typeEvaluator");
|
60
|
+
const typeGuards_1 = require("./typeGuards");
|
60
61
|
const types_1 = require("./types");
|
61
62
|
const typeUtils_1 = require("./typeUtils");
|
62
63
|
const typeVarContext_1 = require("./typeVarContext");
|
@@ -459,6 +460,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
459
460
|
}
|
460
461
|
visitFor(node) {
|
461
462
|
this._evaluator.evaluateTypesForStatement(node);
|
463
|
+
if (node.typeComment) {
|
464
|
+
this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.annotationNotSupported(), node.typeComment);
|
465
|
+
}
|
462
466
|
return true;
|
463
467
|
}
|
464
468
|
visitList(node) {
|
@@ -495,6 +499,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
495
499
|
node.withItems.forEach((item) => {
|
496
500
|
this._evaluator.evaluateTypesForStatement(item);
|
497
501
|
});
|
502
|
+
if (node.typeComment) {
|
503
|
+
this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.annotationNotSupported(), node.typeComment);
|
504
|
+
}
|
498
505
|
return true;
|
499
506
|
}
|
500
507
|
visitReturn(node) {
|
@@ -1769,14 +1776,17 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1769
1776
|
}
|
1770
1777
|
else if (otherDecl.type === 3 /* Function */) {
|
1771
1778
|
const primaryType = this._evaluator.getTypeForDeclaration(primaryDecl);
|
1779
|
+
let duplicateIsOk = false;
|
1772
1780
|
// If the return type has not yet been inferred, do so now.
|
1773
1781
|
if (primaryType && (0, types_1.isFunction)(primaryType)) {
|
1774
1782
|
this._evaluator.getFunctionInferredReturnType(primaryType);
|
1775
1783
|
}
|
1776
|
-
let duplicateIsOk = false;
|
1777
1784
|
const otherType = this._evaluator.getTypeForDeclaration(otherDecl);
|
1778
1785
|
const suite1 = ParseTreeUtils.getEnclosingSuite(primaryDecl.node);
|
1779
1786
|
const suite2 = ParseTreeUtils.getEnclosingSuite(otherDecl.node);
|
1787
|
+
// Allow same-signature overrides in cases where the declarations
|
1788
|
+
// are not within the same statement suite (e.g. one in the "if"
|
1789
|
+
// and another in the "else").
|
1780
1790
|
const isInSameStatementList = suite1 === suite2;
|
1781
1791
|
// If the return type has not yet been inferred, do so now.
|
1782
1792
|
if (otherType && (0, types_1.isFunction)(otherType)) {
|
@@ -1784,10 +1794,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1784
1794
|
}
|
1785
1795
|
// If both declarations are functions, it's OK if they
|
1786
1796
|
// both have the same signatures.
|
1787
|
-
if (primaryType && otherType && (0, types_1.isTypeSame)(primaryType, otherType)) {
|
1797
|
+
if (!isInSameStatementList && primaryType && otherType && (0, types_1.isTypeSame)(primaryType, otherType)) {
|
1788
1798
|
duplicateIsOk = true;
|
1789
1799
|
}
|
1790
|
-
if (!duplicateIsOk
|
1800
|
+
if (!duplicateIsOk) {
|
1791
1801
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, otherDecl.isMethod
|
1792
1802
|
? localize_1.Localizer.Diagnostic.obscuredMethodDeclaration().format({ name })
|
1793
1803
|
: localize_1.Localizer.Diagnostic.obscuredFunctionDeclaration().format({ name }), otherDecl.node.name);
|
@@ -1816,18 +1826,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1816
1826
|
}
|
1817
1827
|
}
|
1818
1828
|
}
|
1819
|
-
else if (primaryType && !(0, typeUtils_1.isProperty)(primaryType)) {
|
1820
|
-
if (primaryDecl.type === 3 /* Function */ || primaryDecl.type === 4 /* Class */) {
|
1821
|
-
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.obscuredVariableDeclaration().format({ name }), otherDecl.node);
|
1822
|
-
addPrimaryDeclInfo(diag);
|
1823
|
-
}
|
1824
|
-
}
|
1825
1829
|
}
|
1826
1830
|
}
|
1827
1831
|
}
|
1828
1832
|
_conditionallyReportUnusedSymbol(name, symbol, scopeType) {
|
1829
|
-
const
|
1830
|
-
if (symbol.isIgnoredForProtocolMatch() ||
|
1833
|
+
const accessedSymbolSet = this._fileInfo.accessedSymbolSet;
|
1834
|
+
if (symbol.isIgnoredForProtocolMatch() || accessedSymbolSet.has(symbol.id)) {
|
1831
1835
|
return;
|
1832
1836
|
}
|
1833
1837
|
// A name of "_" means "I know this symbol isn't used", so
|
@@ -2087,18 +2091,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2087
2091
|
const filterType = (varType) => {
|
2088
2092
|
const filteredTypes = [];
|
2089
2093
|
for (const filterType of classTypeList) {
|
2090
|
-
|
2091
|
-
|
2092
|
-
// but at runtime, isinstance returns True.
|
2093
|
-
const filterIsSuperclass = types_1.ClassType.isDerivedFrom(varType, filterType) ||
|
2094
|
-
(isInstanceCheck &&
|
2095
|
-
types_1.ClassType.isProtocolClass(filterType) &&
|
2096
|
-
this._evaluator.assignType(filterType, varType)) ||
|
2097
|
-
(types_1.ClassType.isBuiltIn(filterType, 'dict') && types_1.ClassType.isTypedDictClass(varType));
|
2098
|
-
const filterIsSubclass = types_1.ClassType.isDerivedFrom(filterType, varType) ||
|
2099
|
-
(isInstanceCheck &&
|
2100
|
-
types_1.ClassType.isProtocolClass(varType) &&
|
2101
|
-
this._evaluator.assignType(varType, filterType));
|
2094
|
+
const filterIsSuperclass = (0, typeGuards_1.isIsinstanceFilterSuperclass)(this._evaluator, varType, filterType, filterType, isInstanceCheck);
|
2095
|
+
const filterIsSubclass = (0, typeGuards_1.isIsinstanceFilterSubclass)(this._evaluator, varType, filterType, filterType, isInstanceCheck);
|
2102
2096
|
// Normally, a class should never be both a subclass and a
|
2103
2097
|
// superclass. However, this can happen if one of the classes
|
2104
2098
|
// derives from an unknown type. In this case, we'll add an
|
@@ -2645,8 +2639,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2645
2639
|
}
|
2646
2640
|
// Collect the list of init-only variables in the order they were declared.
|
2647
2641
|
const initOnlySymbolMap = new Map();
|
2648
|
-
|
2649
|
-
const mroClass = classType.details.mro[i];
|
2642
|
+
types_1.ClassType.getReverseMro(classType).forEach((mroClass) => {
|
2650
2643
|
if ((0, types_1.isClass)(mroClass) && types_1.ClassType.isDataClass(mroClass)) {
|
2651
2644
|
mroClass.details.fields.forEach((symbol, name) => {
|
2652
2645
|
if (symbol.isInitVar()) {
|
@@ -2654,7 +2647,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2654
2647
|
}
|
2655
2648
|
});
|
2656
2649
|
}
|
2657
|
-
}
|
2650
|
+
});
|
2658
2651
|
const postInitType = this._evaluator.getTypeOfMember(postInitMember);
|
2659
2652
|
if (!(0, types_1.isFunction)(postInitType) ||
|
2660
2653
|
!types_1.FunctionType.isInstanceMethod(postInitType) ||
|