@zzzen/pyright-internal 1.2.0-dev.20221016 → 1.2.0-dev.20221204
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/backgroundAnalysisProgram.d.ts +7 -9
- package/dist/analyzer/backgroundAnalysisProgram.js +14 -52
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +43 -32
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +15 -3
- package/dist/analyzer/checker.js +260 -143
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +2 -2
- package/dist/analyzer/codeFlowEngine.js +85 -88
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +1 -0
- package/dist/analyzer/codeFlowTypes.js +3 -1
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +11 -1
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +3 -3
- package/dist/analyzer/dataClasses.js +92 -59
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +1 -1
- package/dist/analyzer/declarationUtils.js +6 -4
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +7 -5
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +3 -0
- package/dist/analyzer/importResolver.js +50 -8
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.d.ts +1 -0
- package/dist/analyzer/namedTuples.js +1 -1
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.d.ts +2 -1
- package/dist/analyzer/packageTypeVerifier.js +16 -10
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +2 -1
- package/dist/analyzer/parseTreeUtils.js +38 -3
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.d.ts +86 -79
- package/dist/analyzer/parseTreeWalker.js +384 -201
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/program.d.ts +4 -7
- package/dist/analyzer/program.js +84 -79
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +10 -3
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +1 -1
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/regions.d.ts +11 -0
- package/dist/analyzer/regions.js +57 -0
- package/dist/analyzer/regions.js.map +1 -0
- package/dist/analyzer/service.d.ts +11 -6
- package/dist/analyzer/service.js +127 -65
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +5 -2
- package/dist/analyzer/sourceFile.js +23 -10
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.d.ts +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +6 -1
- package/dist/analyzer/sourceMapper.js +28 -5
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/sourceMapperUtils.d.ts +2 -1
- package/dist/analyzer/sourceMapperUtils.js +17 -5
- package/dist/analyzer/sourceMapperUtils.js.map +1 -1
- package/dist/analyzer/staticExpressions.js +19 -9
- package/dist/analyzer/staticExpressions.js.map +1 -1
- package/dist/analyzer/symbolUtils.d.ts +1 -0
- package/dist/analyzer/symbolUtils.js +5 -1
- package/dist/analyzer/symbolUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +664 -257
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +16 -4
- package/dist/analyzer/typeGuards.js +9 -0
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.d.ts +3 -1
- package/dist/analyzer/typePrinter.js +143 -28
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +5 -1
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +4 -2
- package/dist/analyzer/typeUtils.js +114 -20
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +8 -6
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +7 -5
- package/dist/analyzer/types.js +45 -20
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +6 -4
- package/dist/backgroundAnalysisBase.js +30 -9
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +2 -1
- package/dist/backgroundThreadBase.js +4 -0
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/createTypeStub.js +3 -1
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -0
- package/dist/common/configOptions.js +4 -0
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/core.d.ts +2 -0
- package/dist/common/core.js +24 -3
- package/dist/common/core.js.map +1 -1
- package/dist/common/diagnostic.d.ts +8 -0
- package/dist/common/diagnostic.js +5 -1
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticRules.d.ts +2 -1
- package/dist/common/diagnosticRules.js +1 -0
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/fileSystem.d.ts +1 -0
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/pathUtils.d.ts +1 -0
- package/dist/common/pathUtils.js +17 -4
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/pythonVersion.d.ts +1 -1
- package/dist/common/pythonVersion.js +1 -1
- package/dist/common/realFileSystem.js +12 -3
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/workspaceEditUtils.d.ts +6 -1
- package/dist/common/workspaceEditUtils.js +72 -1
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +16 -8
- package/dist/languageServerBase.js +76 -32
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.d.ts +6 -2
- package/dist/languageService/analyzerServiceExecutor.js +8 -6
- 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/codeActionProvider.js +30 -0
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +2 -0
- package/dist/languageService/completionProvider.js +84 -32
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/definitionProvider.d.ts +2 -0
- package/dist/languageService/definitionProvider.js +3 -0
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +7 -3
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +1 -1
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +1 -1
- package/dist/languageService/hoverProvider.js +73 -38
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/indentationUtils.d.ts +3 -0
- package/dist/languageService/indentationUtils.js +4 -3
- package/dist/languageService/indentationUtils.js.map +1 -1
- package/dist/languageService/referencesProvider.js +2 -1
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +1 -2
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +30 -19
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +29 -4
- package/dist/localization/localize.js +20 -5
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +18 -3
- package/dist/parser/parseNodes.d.ts +2 -1
- package/dist/parser/parseNodes.js +6 -1
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js +29 -15
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +19 -9
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/pyright.js +4 -4
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +1 -0
- package/dist/pyrightFileSystem.js +3 -0
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +1 -0
- package/dist/readonlyAugmentedFileSystem.js +3 -0
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +2 -0
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +26 -3
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/config.test.js +11 -0
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/diagnostics.test.d.ts +1 -0
- package/dist/tests/diagnostics.test.js +37 -0
- package/dist/tests/diagnostics.test.js.map +1 -0
- package/dist/tests/docStringConversion.test.js +71 -12
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js +5 -5
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.classVariable.fourslash.js +119 -24
- package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/{signature.paramspec.fourslash.d.ts → completions.dunderNew.Inheritance.fourslash.d.ts} +0 -0
- package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dunderNew.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dunderNew.fourslash.js +20 -0
- package/dist/tests/fourslash/completions.dunderNew.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fourslash.js +2 -2
- package/dist/tests/fourslash/completions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.libStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.localCode.fourslash.js +2 -2
- package/dist/tests/fourslash/completions.localCode.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.plainText.fourslash.js +2 -2
- package/dist/tests/fourslash/completions.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.self.fourslash.js +2 -2
- package/dist/tests/fourslash/completions.self.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js +2 -2
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js +32 -0
- package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js.map +1 -0
- package/dist/tests/fourslash/fourslash.d.ts +2 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js +4 -4
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +24 -0
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js +3 -3
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.js +13 -0
- package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.js +15 -0
- package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.js +21 -0
- package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.js +17 -0
- package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.js +15 -0
- package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js +3 -3
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libStub.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.libStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.plainText.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js.map +1 -1
- package/dist/tests/fourslash/shadowedImports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/shadowedImports.fourslash.js +75 -0
- package/dist/tests/fourslash/shadowedImports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.dunderNew.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.dunderNew.fourslash.js +24 -0
- package/dist/tests/fourslash/signature.dunderNew.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/runner.js +1 -1
- package/dist/tests/harness/fourslash/runner.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +3 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +5 -4
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +7 -7
- package/dist/tests/harness/fourslash/testState.js +79 -163
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.d.ts +16 -0
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +159 -0
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -0
- package/dist/tests/harness/vfs/filesystem.d.ts +1 -0
- package/dist/tests/harness/vfs/filesystem.js +3 -0
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/indentationUtils.ptvs.test.js +1 -1
- package/dist/tests/indentationUtils.test.js +4 -4
- package/dist/tests/ipythonMode.test.js +39 -0
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/logger.test.js +3 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/parser.test.js +3 -3
- package/dist/tests/pathUtils.test.js +7 -0
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/service.test.d.ts +1 -0
- package/dist/tests/service.test.js +159 -0
- package/dist/tests/service.test.js.map +1 -0
- package/dist/tests/sourceFile.test.js +34 -1
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +39 -4
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/tokenizer.test.js +6 -2
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +16 -6
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +15 -3
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +51 -11
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +11 -7
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +48 -0
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typePrinter.test.d.ts +1 -0
- package/dist/tests/typePrinter.test.js +148 -0
- package/dist/tests/typePrinter.test.js.map +1 -0
- package/dist/tests/workspaceEditUtils.test.d.ts +1 -0
- package/dist/tests/workspaceEditUtils.test.js +167 -0
- package/dist/tests/workspaceEditUtils.test.js.map +1 -0
- package/dist/workspaceMap.d.ts +4 -1
- package/dist/workspaceMap.js +64 -16
- package/dist/workspaceMap.js.map +1 -1
- package/package.json +3 -3
- package/dist/tests/fourslash/signature.paramspec.fourslash.js +0 -30
- package/dist/tests/fourslash/signature.paramspec.fourslash.js.map +0 -1
package/dist/analyzer/checker.js
CHANGED
@@ -39,6 +39,7 @@ const diagnosticRules_1 = require("../common/diagnosticRules");
|
|
39
39
|
const pathUtils_1 = require("../common/pathUtils");
|
40
40
|
const pythonVersion_1 = require("../common/pythonVersion");
|
41
41
|
const textRange_1 = require("../common/textRange");
|
42
|
+
const definitionProvider_1 = require("../languageService/definitionProvider");
|
42
43
|
const localize_1 = require("../localization/localize");
|
43
44
|
const parseNodes_1 = require("../parser/parseNodes");
|
44
45
|
const stringTokenUtils_1 = require("../parser/stringTokenUtils");
|
@@ -50,6 +51,7 @@ const importStatementUtils_1 = require("./importStatementUtils");
|
|
50
51
|
const ParseTreeUtils = __importStar(require("./parseTreeUtils"));
|
51
52
|
const parseTreeWalker_1 = require("./parseTreeWalker");
|
52
53
|
const patternMatching_1 = require("./patternMatching");
|
54
|
+
const regions_1 = require("./regions");
|
53
55
|
const scopeUtils_1 = require("./scopeUtils");
|
54
56
|
const sourceFile_1 = require("./sourceFile");
|
55
57
|
const sourceMapper_1 = require("./sourceMapper");
|
@@ -102,21 +104,32 @@ const deprecatedSpecialForms = new Map([
|
|
102
104
|
// functions to be emitted.
|
103
105
|
const isPrintCodeComplexityEnabled = false;
|
104
106
|
class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
105
|
-
constructor(_importResolver, _evaluator,
|
107
|
+
constructor(_importResolver, _evaluator, _parseResults, _sourceMapper) {
|
106
108
|
super();
|
107
109
|
this._importResolver = _importResolver;
|
108
110
|
this._evaluator = _evaluator;
|
109
|
-
this.
|
111
|
+
this._parseResults = _parseResults;
|
112
|
+
this._sourceMapper = _sourceMapper;
|
110
113
|
this._isUnboundCheckSuppressed = false;
|
111
114
|
// A list of all nodes that are defined within the module that
|
112
115
|
// have their own scopes.
|
113
116
|
this._scopedNodes = [];
|
114
117
|
// A list of all visited type parameter lists.
|
115
118
|
this._typeParameterLists = [];
|
116
|
-
this.
|
119
|
+
this._moduleNode = _parseResults.parseTree;
|
120
|
+
this._fileInfo = AnalyzerNodeInfo.getFileInfo(this._moduleNode);
|
117
121
|
}
|
118
122
|
check() {
|
119
123
|
this._scopedNodes.push(this._moduleNode);
|
124
|
+
this._conditionallyReportShadowedModule();
|
125
|
+
// Report code complexity issues for the module.
|
126
|
+
const codeComplexity = AnalyzerNodeInfo.getCodeFlowComplexity(this._moduleNode);
|
127
|
+
if (isPrintCodeComplexityEnabled) {
|
128
|
+
console.log(`Code complexity of module ${this._fileInfo.filePath} is ${codeComplexity.toString()}`);
|
129
|
+
}
|
130
|
+
if (codeComplexity > typeEvaluator_1.maxCodeComplexity) {
|
131
|
+
this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.codeTooComplexToAnalyze(), { start: 0, length: 0 });
|
132
|
+
}
|
120
133
|
this._walkStatementsAndReportUnreachable(this._moduleNode.statements);
|
121
134
|
// Mark symbols accessed by __all__ as accessed.
|
122
135
|
const dunderAllInfo = AnalyzerNodeInfo.getDunderAllInfo(this._moduleNode);
|
@@ -128,7 +141,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
128
141
|
// defined in this module for things like unaccessed variables.
|
129
142
|
this._validateSymbolTables();
|
130
143
|
this._reportDuplicateImports();
|
131
|
-
|
144
|
+
this._checkRegions();
|
132
145
|
}
|
133
146
|
walk(node) {
|
134
147
|
if (!AnalyzerNodeInfo.isCodeUnreachable(node)) {
|
@@ -176,9 +189,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
176
189
|
!types_1.ClassType.isBuiltIn(baseClassType, 'Generic')) {
|
177
190
|
if (!types_1.ClassType.isProtocolClass(baseClassType)) {
|
178
191
|
this._evaluator.addError(localize_1.Localizer.Diagnostic.protocolBaseClass().format({
|
179
|
-
classType: this._evaluator.printType(classTypeResult.classType,
|
180
|
-
|
181
|
-
baseType: this._evaluator.printType(baseClassType, /* expandTypeAlias */ false),
|
192
|
+
classType: this._evaluator.printType(classTypeResult.classType),
|
193
|
+
baseType: this._evaluator.printType(baseClassType),
|
182
194
|
}), arg.valueExpression);
|
183
195
|
}
|
184
196
|
}
|
@@ -262,7 +274,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
262
274
|
else if ((0, typeUtils_1.isPartlyUnknown)(paramType)) {
|
263
275
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
264
276
|
diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.paramType().format({
|
265
|
-
paramType: this._evaluator.printType(paramType,
|
277
|
+
paramType: this._evaluator.printType(paramType, { expandTypeAlias: true }),
|
266
278
|
}));
|
267
279
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.paramTypePartiallyUnknown().format({
|
268
280
|
paramName: param.name.value,
|
@@ -292,7 +304,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
292
304
|
}
|
293
305
|
});
|
294
306
|
// Check for invalid use of ParamSpec P.args and P.kwargs.
|
295
|
-
const paramSpecParams =
|
307
|
+
const paramSpecParams = functionTypeResult.functionType.details.parameters.filter((param) => {
|
296
308
|
if (param.typeAnnotation && (0, types_1.isTypeVar)(param.type) && (0, types_1.isParamSpec)(param.type)) {
|
297
309
|
if (param.category !== 0 /* Simple */ && param.name && param.type.paramSpecAccess) {
|
298
310
|
return true;
|
@@ -430,7 +442,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
430
442
|
}
|
431
443
|
else if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
|
432
444
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownLambdaType, diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.Localizer.Diagnostic.lambdaReturnTypePartiallyUnknown().format({
|
433
|
-
returnType: this._evaluator.printType(returnType,
|
445
|
+
returnType: this._evaluator.printType(returnType, { expandTypeAlias: true }),
|
434
446
|
}), node.expression);
|
435
447
|
}
|
436
448
|
}
|
@@ -449,7 +461,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
449
461
|
const returnType = this._evaluator.getType(node);
|
450
462
|
if (!isRevealTypeCall && returnType && this._isTypeValidForUnusedValueTest(returnType)) {
|
451
463
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnusedCallResult, diagnosticRules_1.DiagnosticRule.reportUnusedCallResult, localize_1.Localizer.Diagnostic.unusedCallResult().format({
|
452
|
-
type: this._evaluator.printType(returnType
|
464
|
+
type: this._evaluator.printType(returnType),
|
453
465
|
}), node);
|
454
466
|
if ((0, types_1.isClassInstance)(returnType) && types_1.ClassType.isBuiltIn(returnType, 'Coroutine')) {
|
455
467
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnusedCoroutine, diagnosticRules_1.DiagnosticRule.reportUnusedCoroutine, localize_1.Localizer.Diagnostic.unusedCoroutine(), node);
|
@@ -467,7 +479,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
467
479
|
const returnType = this._evaluator.getType(node);
|
468
480
|
if (returnType && this._isTypeValidForUnusedValueTest(returnType)) {
|
469
481
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnusedCallResult, diagnosticRules_1.DiagnosticRule.reportUnusedCallResult, localize_1.Localizer.Diagnostic.unusedCallResult().format({
|
470
|
-
type: this._evaluator.printType(returnType
|
482
|
+
type: this._evaluator.printType(returnType),
|
471
483
|
}), node);
|
472
484
|
}
|
473
485
|
}
|
@@ -582,8 +594,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
582
594
|
}
|
583
595
|
if (!returnTypeMatches) {
|
584
596
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.returnTypeMismatch().format({
|
585
|
-
exprType: this._evaluator.printType(returnType
|
586
|
-
returnType: this._evaluator.printType(declaredReturnType
|
597
|
+
exprType: this._evaluator.printType(returnType),
|
598
|
+
returnType: this._evaluator.printType(declaredReturnType),
|
587
599
|
}) + diagAddendum.getString(), node.returnExpression ? node.returnExpression : node);
|
588
600
|
}
|
589
601
|
}
|
@@ -593,7 +605,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
593
605
|
}
|
594
606
|
else if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
|
595
607
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownVariableType, diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.Localizer.Diagnostic.returnTypePartiallyUnknown().format({
|
596
|
-
returnType: this._evaluator.printType(returnType,
|
608
|
+
returnType: this._evaluator.printType(returnType, { expandTypeAlias: true }),
|
597
609
|
}), node.returnExpression);
|
598
610
|
}
|
599
611
|
}
|
@@ -605,6 +617,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
605
617
|
return true;
|
606
618
|
}
|
607
619
|
visitYieldFrom(node) {
|
620
|
+
var _a, _b, _c, _d;
|
608
621
|
const yieldFromType = this._evaluator.getType(node.expression) || types_1.UnknownType.create();
|
609
622
|
let yieldType;
|
610
623
|
if ((0, types_1.isClassInstance)(yieldFromType) && types_1.ClassType.isBuiltIn(yieldFromType, 'Coroutine')) {
|
@@ -613,7 +626,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
613
626
|
}
|
614
627
|
else {
|
615
628
|
yieldType =
|
616
|
-
this._evaluator.getTypeOfIterable(yieldFromType, /* isAsync */ false, node) || types_1.UnknownType.create();
|
629
|
+
(_b = (_a = this._evaluator.getTypeOfIterable({ type: yieldFromType }, /* isAsync */ false, node)) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create();
|
617
630
|
// Does the iterator return a Generator? If so, get the yield type from it.
|
618
631
|
// If the iterator doesn't return a Generator, use the iterator return type
|
619
632
|
// directly.
|
@@ -623,7 +636,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
623
636
|
}
|
624
637
|
else {
|
625
638
|
yieldType =
|
626
|
-
this._evaluator.getTypeOfIterator(yieldFromType, /* isAsync */ false, node) || types_1.UnknownType.create();
|
639
|
+
(_d = (_c = this._evaluator.getTypeOfIterator({ type: yieldFromType }, /* isAsync */ false, node)) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : types_1.UnknownType.create();
|
627
640
|
}
|
628
641
|
}
|
629
642
|
this._validateYieldType(node, yieldType);
|
@@ -643,13 +656,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
643
656
|
if ((0, types_1.isClass)(subtype)) {
|
644
657
|
if (!(0, typeUtils_1.derivesFromClassRecursive)(subtype, baseExceptionType, /* ignoreUnknown */ false)) {
|
645
658
|
diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
|
646
|
-
type: this._evaluator.printType(subtype
|
659
|
+
type: this._evaluator.printType(subtype),
|
647
660
|
}));
|
648
661
|
}
|
649
662
|
}
|
650
663
|
else {
|
651
664
|
diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
|
652
|
-
type: this._evaluator.printType(subtype
|
665
|
+
type: this._evaluator.printType(subtype),
|
653
666
|
}));
|
654
667
|
}
|
655
668
|
}
|
@@ -863,10 +876,20 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
863
876
|
return false;
|
864
877
|
}
|
865
878
|
visitImportAs(node) {
|
879
|
+
this._conditionallyReportShadowedImport(node);
|
866
880
|
this._evaluator.evaluateTypesForStatement(node);
|
867
|
-
return
|
881
|
+
return true;
|
868
882
|
}
|
869
883
|
visitImportFrom(node) {
|
884
|
+
// Verify that any "__future__" import occurs at the top of the file.
|
885
|
+
if (node.module.leadingDots === 0 &&
|
886
|
+
node.module.nameParts.length === 1 &&
|
887
|
+
node.module.nameParts[0].value === '__future__') {
|
888
|
+
if (!ParseTreeUtils.isValidLocationForFutureImport(node)) {
|
889
|
+
this._evaluator.addError(localize_1.Localizer.Diagnostic.futureImportLocationNotAllowed(), node);
|
890
|
+
}
|
891
|
+
}
|
892
|
+
this._conditionallyReportShadowedImport(node);
|
870
893
|
if (!node.isWildcardImport) {
|
871
894
|
node.imports.forEach((importAs) => {
|
872
895
|
this._evaluator.evaluateTypesForStatement(importAs);
|
@@ -881,6 +904,41 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
881
904
|
this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportWildcardImportFromLibrary, diagnosticRules_1.DiagnosticRule.reportWildcardImportFromLibrary, localize_1.Localizer.Diagnostic.wildcardLibraryImport(), node.wildcardToken || node);
|
882
905
|
}
|
883
906
|
}
|
907
|
+
return true;
|
908
|
+
}
|
909
|
+
visitImportFromAs(node) {
|
910
|
+
if (this._fileInfo.isStubFile) {
|
911
|
+
return false;
|
912
|
+
}
|
913
|
+
const decls = this._evaluator.getDeclarationsForNameNode(node.name);
|
914
|
+
if (!decls) {
|
915
|
+
return false;
|
916
|
+
}
|
917
|
+
for (const decl of decls) {
|
918
|
+
if (!(0, declaration_1.isAliasDeclaration)(decl) || !decl.submoduleFallback || decl.node !== node) {
|
919
|
+
// If it is not implicitly imported module, move to next.
|
920
|
+
continue;
|
921
|
+
}
|
922
|
+
const resolvedAlias = this._evaluator.resolveAliasDeclaration(decl, /* resolveLocalNames */ true);
|
923
|
+
if (!(resolvedAlias === null || resolvedAlias === void 0 ? void 0 : resolvedAlias.path) || !(0, sourceMapper_1.isStubFile)(resolvedAlias.path)) {
|
924
|
+
continue;
|
925
|
+
}
|
926
|
+
const importResult = this._getImportResult(node, resolvedAlias.path);
|
927
|
+
if (!importResult) {
|
928
|
+
continue;
|
929
|
+
}
|
930
|
+
this._addMissingModuleSourceDiagnosticIfNeeded(importResult, node.name);
|
931
|
+
break;
|
932
|
+
}
|
933
|
+
return false;
|
934
|
+
}
|
935
|
+
visitModuleName(node) {
|
936
|
+
if (this._fileInfo.isStubFile) {
|
937
|
+
return false;
|
938
|
+
}
|
939
|
+
const importResult = AnalyzerNodeInfo.getImportInfo(node);
|
940
|
+
(0, debug_1.assert)(importResult !== undefined);
|
941
|
+
this._addMissingModuleSourceDiagnosticIfNeeded(importResult, node);
|
884
942
|
return false;
|
885
943
|
}
|
886
944
|
visitTypeParameterList(node) {
|
@@ -923,6 +981,31 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
923
981
|
// Don't explore further.
|
924
982
|
return false;
|
925
983
|
}
|
984
|
+
_getImportResult(node, filePath) {
|
985
|
+
const execEnv = this._importResolver.getConfigOption().findExecEnvironment(filePath);
|
986
|
+
const moduleNameNode = node.parent.module;
|
987
|
+
// Handle both absolute and relative imports.
|
988
|
+
const moduleName = moduleNameNode.leadingDots === 0
|
989
|
+
? this._importResolver.getModuleNameForImport(filePath, execEnv).moduleName
|
990
|
+
: (0, importStatementUtils_1.getRelativeModuleName)(this._importResolver.fileSystem, this._fileInfo.filePath, filePath);
|
991
|
+
if (!moduleName) {
|
992
|
+
return undefined;
|
993
|
+
}
|
994
|
+
return this._importResolver.resolveImport(this._fileInfo.filePath, execEnv, (0, importResolver_1.createImportedModuleDescriptor)(moduleName));
|
995
|
+
}
|
996
|
+
_addMissingModuleSourceDiagnosticIfNeeded(importResult, node) {
|
997
|
+
if (importResult.isNativeLib ||
|
998
|
+
!importResult.isStubFile ||
|
999
|
+
importResult.importType === 0 /* BuiltIn */ ||
|
1000
|
+
!importResult.nonStubImportResult ||
|
1001
|
+
importResult.nonStubImportResult.isImportFound) {
|
1002
|
+
return;
|
1003
|
+
}
|
1004
|
+
// Type stub found, but source is missing.
|
1005
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportMissingModuleSource, diagnosticRules_1.DiagnosticRule.reportMissingModuleSource, localize_1.Localizer.Diagnostic.importSourceResolveFailure().format({
|
1006
|
+
importName: importResult.importName,
|
1007
|
+
}), node);
|
1008
|
+
}
|
926
1009
|
_reportUnnecessaryConditionExpression(expression) {
|
927
1010
|
if (expression.nodeType === 7 /* BinaryOperation */) {
|
928
1011
|
if (expression.operator === 36 /* And */ || expression.operator === 37 /* Or */) {
|
@@ -950,6 +1033,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
950
1033
|
}
|
951
1034
|
}
|
952
1035
|
_reportUnusedExpression(node) {
|
1036
|
+
var _a, _b;
|
953
1037
|
if (this._fileInfo.diagnosticRuleSet.reportUnusedExpression === 'none') {
|
954
1038
|
return;
|
955
1039
|
}
|
@@ -973,6 +1057,16 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
973
1057
|
reportAsUnused = true;
|
974
1058
|
}
|
975
1059
|
}
|
1060
|
+
if (reportAsUnused &&
|
1061
|
+
this._fileInfo.ipythonMode === sourceFile_1.IPythonMode.CellDocs &&
|
1062
|
+
((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 47 /* StatementList */ &&
|
1063
|
+
node.parent.statements[node.parent.statements.length - 1] === node &&
|
1064
|
+
((_b = node.parent.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 36 /* Module */ &&
|
1065
|
+
node.parent.parent.statements[node.parent.parent.statements.length - 1] === node.parent) {
|
1066
|
+
// Exclude an expression at the end of a notebook cell, as that is treated as
|
1067
|
+
// the cell's value.
|
1068
|
+
reportAsUnused = false;
|
1069
|
+
}
|
976
1070
|
if (reportAsUnused) {
|
977
1071
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnusedExpression, diagnosticRules_1.DiagnosticRule.reportUnusedExpression, localize_1.Localizer.Diagnostic.unusedExpression(), node);
|
978
1072
|
}
|
@@ -1049,8 +1143,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1049
1143
|
: localize_1.Localizer.Diagnostic.containmentAlwaysTrue();
|
1050
1144
|
};
|
1051
1145
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryContains, diagnosticRules_1.DiagnosticRule.reportUnnecessaryContains, getMessage().format({
|
1052
|
-
leftType: this._evaluator.printType(leftType,
|
1053
|
-
rightType: this._evaluator.printType(elementType,
|
1146
|
+
leftType: this._evaluator.printType(leftType, { expandTypeAlias: true }),
|
1147
|
+
rightType: this._evaluator.printType(elementType, { expandTypeAlias: true }),
|
1054
1148
|
}), node);
|
1055
1149
|
}
|
1056
1150
|
}
|
@@ -1089,8 +1183,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1089
1183
|
});
|
1090
1184
|
if (!isPossiblyTrue) {
|
1091
1185
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
|
1092
|
-
leftType: this._evaluator.printType(leftType,
|
1093
|
-
rightType: this._evaluator.printType(rightType,
|
1186
|
+
leftType: this._evaluator.printType(leftType, { expandTypeAlias: true }),
|
1187
|
+
rightType: this._evaluator.printType(rightType, { expandTypeAlias: true }),
|
1094
1188
|
}), node);
|
1095
1189
|
}
|
1096
1190
|
}
|
@@ -1113,8 +1207,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1113
1207
|
});
|
1114
1208
|
});
|
1115
1209
|
if (!isComparable) {
|
1116
|
-
const leftTypeText = this._evaluator.printType(leftType,
|
1117
|
-
const rightTypeText = this._evaluator.printType(rightType,
|
1210
|
+
const leftTypeText = this._evaluator.printType(leftType, { expandTypeAlias: true });
|
1211
|
+
const rightTypeText = this._evaluator.printType(rightType, { expandTypeAlias: true });
|
1118
1212
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
|
1119
1213
|
leftType: leftTypeText,
|
1120
1214
|
rightType: rightTypeText,
|
@@ -1454,8 +1548,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1454
1548
|
if (!(0, types_1.isNever)(overloadReturnType) &&
|
1455
1549
|
!this._evaluator.assignType(implementationReturnType, overloadReturnType, returnDiag.createAddendum(), implTypeVarContext, overloadTypeVarContext, 8 /* SkipSolveTypeVars */)) {
|
1456
1550
|
returnDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.functionReturnTypeMismatch().format({
|
1457
|
-
sourceType: this._evaluator.printType(overloadReturnType
|
1458
|
-
destType: this._evaluator.printType(implementationReturnType
|
1551
|
+
sourceType: this._evaluator.printType(overloadReturnType),
|
1552
|
+
destType: this._evaluator.printType(implementationReturnType),
|
1459
1553
|
}));
|
1460
1554
|
diag === null || diag === void 0 ? void 0 : diag.addAddendum(returnDiag);
|
1461
1555
|
isLegal = false;
|
@@ -1566,6 +1660,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1566
1660
|
}
|
1567
1661
|
}
|
1568
1662
|
_validateExceptionType(exceptionType, errorNode) {
|
1663
|
+
var _a, _b;
|
1569
1664
|
const baseExceptionType = this._evaluator.getBuiltInType(errorNode, 'BaseException');
|
1570
1665
|
const derivesFromBaseException = (classType) => {
|
1571
1666
|
if (!baseExceptionType || !(0, types_1.isInstantiableClass)(baseExceptionType)) {
|
@@ -1582,14 +1677,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1582
1677
|
if ((0, types_1.isInstantiableClass)(exceptionType)) {
|
1583
1678
|
if (!derivesFromBaseException(exceptionType)) {
|
1584
1679
|
diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
|
1585
|
-
type: this._evaluator.printType(exceptionType
|
1680
|
+
type: this._evaluator.printType(exceptionType),
|
1586
1681
|
}));
|
1587
1682
|
}
|
1588
1683
|
resultingExceptionType = types_1.ClassType.cloneAsInstance(exceptionType);
|
1589
1684
|
}
|
1590
1685
|
else if ((0, types_1.isClassInstance)(exceptionType)) {
|
1591
|
-
const iterableType = this._evaluator.getTypeOfIterator(exceptionType, /* isAsync */ false, errorNode) ||
|
1592
|
-
types_1.UnknownType.create();
|
1686
|
+
const iterableType = (_b = (_a = this._evaluator.getTypeOfIterator({ type: exceptionType }, /* isAsync */ false, errorNode)) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create();
|
1593
1687
|
resultingExceptionType = (0, typeUtils_1.mapSubtypes)(iterableType, (subtype) => {
|
1594
1688
|
if ((0, types_1.isAnyOrUnknown)(subtype)) {
|
1595
1689
|
return subtype;
|
@@ -1597,13 +1691,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1597
1691
|
if ((0, types_1.isInstantiableClass)(subtype)) {
|
1598
1692
|
if (!derivesFromBaseException(subtype)) {
|
1599
1693
|
diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
|
1600
|
-
type: this._evaluator.printType(exceptionType
|
1694
|
+
type: this._evaluator.printType(exceptionType),
|
1601
1695
|
}));
|
1602
1696
|
}
|
1603
1697
|
return types_1.ClassType.cloneAsInstance(subtype);
|
1604
1698
|
}
|
1605
1699
|
diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
|
1606
|
-
type: this._evaluator.printType(exceptionType
|
1700
|
+
type: this._evaluator.printType(exceptionType),
|
1607
1701
|
}));
|
1608
1702
|
return types_1.UnknownType.create();
|
1609
1703
|
});
|
@@ -1611,7 +1705,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1611
1705
|
}
|
1612
1706
|
if (!diagAddendum.isEmpty()) {
|
1613
1707
|
this._evaluator.addError(localize_1.Localizer.Diagnostic.exceptionTypeNotClass().format({
|
1614
|
-
type: this._evaluator.printType(exceptionType
|
1708
|
+
type: this._evaluator.printType(exceptionType),
|
1615
1709
|
}), errorNode);
|
1616
1710
|
}
|
1617
1711
|
return resultingExceptionType || types_1.UnknownType.create();
|
@@ -2000,6 +2094,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2000
2094
|
});
|
2001
2095
|
}
|
2002
2096
|
_conditionallyReportUnusedDeclaration(decl, isPrivate) {
|
2097
|
+
var _a;
|
2003
2098
|
let diagnosticLevel;
|
2004
2099
|
let nameNode;
|
2005
2100
|
let message;
|
@@ -2010,8 +2105,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2010
2105
|
rule = diagnosticRules_1.DiagnosticRule.reportUnusedImport;
|
2011
2106
|
if (decl.node.nodeType === 21 /* ImportAs */) {
|
2012
2107
|
if (decl.node.alias) {
|
2013
|
-
//
|
2014
|
-
|
2108
|
+
// For statements of the form "import x as x", don't mark "x" as unaccessed
|
2109
|
+
// because it's assumed to be re-exported.
|
2110
|
+
// See https://typing.readthedocs.io/en/latest/source/stubs.html#imports.
|
2111
|
+
if (decl.node.alias.value !== decl.moduleName) {
|
2015
2112
|
nameNode = decl.node.alias;
|
2016
2113
|
}
|
2017
2114
|
}
|
@@ -2030,9 +2127,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2030
2127
|
}
|
2031
2128
|
else if (decl.node.nodeType === 23 /* ImportFromAs */) {
|
2032
2129
|
const importFrom = decl.node.parent;
|
2033
|
-
//
|
2034
|
-
//
|
2035
|
-
const isReexport =
|
2130
|
+
// For statements of the form "from y import x as x", don't mark "x" as
|
2131
|
+
// unaccessed because it's assumed to be re-exported.
|
2132
|
+
const isReexport = ((_a = decl.node.alias) === null || _a === void 0 ? void 0 : _a.value) === decl.node.name.value;
|
2036
2133
|
// If this is a __future__ import, it's OK for the import symbol to be unaccessed.
|
2037
2134
|
const isFuture = importFrom.module.nameParts.length === 1 &&
|
2038
2135
|
importFrom.module.nameParts[0].value === '__future__';
|
@@ -2161,10 +2258,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2161
2258
|
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarNotAllowed());
|
2162
2259
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, isInstanceCheck
|
2163
2260
|
? localize_1.Localizer.Diagnostic.isInstanceInvalidType().format({
|
2164
|
-
type: this._evaluator.printType(arg1Type
|
2261
|
+
type: this._evaluator.printType(arg1Type),
|
2165
2262
|
}) + diag.getString()
|
2166
2263
|
: localize_1.Localizer.Diagnostic.isSubclassInvalidType().format({
|
2167
|
-
type: this._evaluator.printType(arg1Type
|
2264
|
+
type: this._evaluator.printType(arg1Type),
|
2168
2265
|
}) + diag.getString(), node.arguments[1]);
|
2169
2266
|
}
|
2170
2267
|
// If this call is within an assert statement, we won't check whether
|
@@ -2324,12 +2421,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2324
2421
|
if (!arg1IncludesSubclasses && (0, types_1.isTypeSame)(filteredType, arg0Type, { ignorePseudoGeneric: true })) {
|
2325
2422
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryIsInstance, diagnosticRules_1.DiagnosticRule.reportUnnecessaryIsInstance, isInstanceCheck
|
2326
2423
|
? localize_1.Localizer.Diagnostic.unnecessaryIsInstanceAlways().format({
|
2327
|
-
testType: this._evaluator.printType(arg0Type
|
2328
|
-
classType: this._evaluator.printType(getTestType()
|
2424
|
+
testType: this._evaluator.printType(arg0Type),
|
2425
|
+
classType: this._evaluator.printType(getTestType()),
|
2329
2426
|
})
|
2330
2427
|
: localize_1.Localizer.Diagnostic.unnecessaryIsSubclassAlways().format({
|
2331
|
-
testType: this._evaluator.printType(arg0Type
|
2332
|
-
classType: this._evaluator.printType(getTestType()
|
2428
|
+
testType: this._evaluator.printType(arg0Type),
|
2429
|
+
classType: this._evaluator.printType(getTestType()),
|
2333
2430
|
}), node);
|
2334
2431
|
}
|
2335
2432
|
}
|
@@ -2425,6 +2522,79 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2425
2522
|
}
|
2426
2523
|
}
|
2427
2524
|
}
|
2525
|
+
_conditionallyReportShadowedModule() {
|
2526
|
+
if (this._fileInfo.diagnosticRuleSet.reportShadowedImports === 'none') {
|
2527
|
+
return;
|
2528
|
+
}
|
2529
|
+
// Check the module we're in.
|
2530
|
+
const moduleName = this._fileInfo.moduleName;
|
2531
|
+
const desc = {
|
2532
|
+
nameParts: moduleName.split('.'),
|
2533
|
+
leadingDots: 0,
|
2534
|
+
importedSymbols: [],
|
2535
|
+
};
|
2536
|
+
const stdlibPath = this._importResolver.getTypeshedStdLibPath(this._fileInfo.executionEnvironment);
|
2537
|
+
if (stdlibPath &&
|
2538
|
+
this._importResolver.isStdlibModule(desc, this._fileInfo.executionEnvironment) &&
|
2539
|
+
this._sourceMapper.isUserCode(this._fileInfo.filePath)) {
|
2540
|
+
// This means the user has a module that is overwriting the stdlib module.
|
2541
|
+
const diag = this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportShadowedImports, diagnosticRules_1.DiagnosticRule.reportShadowedImports, localize_1.Localizer.Diagnostic.stdlibModuleOverridden().format({
|
2542
|
+
name: moduleName,
|
2543
|
+
path: this._fileInfo.filePath,
|
2544
|
+
}), this._moduleNode);
|
2545
|
+
// Add a quick action that renames the file.
|
2546
|
+
if (diag) {
|
2547
|
+
const renameAction = {
|
2548
|
+
action: "renameShadowedFile" /* RenameShadowedFileAction */,
|
2549
|
+
oldFile: this._fileInfo.filePath,
|
2550
|
+
newFile: this._sourceMapper.getNextFileName(this._fileInfo.filePath),
|
2551
|
+
};
|
2552
|
+
diag.addAction(renameAction);
|
2553
|
+
}
|
2554
|
+
}
|
2555
|
+
}
|
2556
|
+
_conditionallyReportShadowedImport(node) {
|
2557
|
+
if (this._fileInfo.diagnosticRuleSet.reportShadowedImports === 'none') {
|
2558
|
+
return;
|
2559
|
+
}
|
2560
|
+
const namePartNodes = node.nodeType === 21 /* ImportAs */
|
2561
|
+
? node.module.nameParts
|
2562
|
+
: node.nodeType === 23 /* ImportFromAs */
|
2563
|
+
? [node.name]
|
2564
|
+
: node.module.nameParts;
|
2565
|
+
const nameParts = namePartNodes.map((n) => n.value);
|
2566
|
+
const module = {
|
2567
|
+
nameParts,
|
2568
|
+
leadingDots: 0,
|
2569
|
+
importedSymbols: [],
|
2570
|
+
};
|
2571
|
+
// Make sure the module is a potential stdlib one so we don't spend the time
|
2572
|
+
// searching for the definition.
|
2573
|
+
const stdlibPath = this._importResolver.getTypeshedStdLibPath(this._fileInfo.executionEnvironment);
|
2574
|
+
if (stdlibPath && this._importResolver.isStdlibModule(module, this._fileInfo.executionEnvironment)) {
|
2575
|
+
// If the definition for this name is in 'user' module, it is overwriting the stdlib module.
|
2576
|
+
const definitions = definitionProvider_1.DefinitionProvider.getDefinitionsForNode(this._sourceMapper, namePartNodes[namePartNodes.length - 1], definitionProvider_1.DefinitionFilter.All, this._evaluator);
|
2577
|
+
const paths = definitions ? definitions.map((d) => d.path) : [];
|
2578
|
+
paths.forEach((p) => {
|
2579
|
+
if (!p.startsWith(stdlibPath) && !(0, sourceMapper_1.isStubFile)(p) && this._sourceMapper.isUserCode(p)) {
|
2580
|
+
// This means the user has a module that is overwriting the stdlib module.
|
2581
|
+
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportShadowedImports, diagnosticRules_1.DiagnosticRule.reportShadowedImports, localize_1.Localizer.Diagnostic.stdlibModuleOverridden().format({
|
2582
|
+
name: nameParts.join('.'),
|
2583
|
+
path: p,
|
2584
|
+
}), node);
|
2585
|
+
// Add a quick action that renames the file.
|
2586
|
+
if (diag) {
|
2587
|
+
const renameAction = {
|
2588
|
+
action: "renameShadowedFile" /* RenameShadowedFileAction */,
|
2589
|
+
oldFile: p,
|
2590
|
+
newFile: this._sourceMapper.getNextFileName(p),
|
2591
|
+
};
|
2592
|
+
diag.addAction(renameAction);
|
2593
|
+
}
|
2594
|
+
}
|
2595
|
+
});
|
2596
|
+
}
|
2597
|
+
}
|
2428
2598
|
_conditionallyReportPrivateUsage(node) {
|
2429
2599
|
var _a;
|
2430
2600
|
if (this._fileInfo.diagnosticRuleSet.reportPrivateUsage === 'none') {
|
@@ -2633,7 +2803,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2633
2803
|
}
|
2634
2804
|
else if ((0, typeUtils_1.isPartlyUnknown)(declaredReturnType)) {
|
2635
2805
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownVariableType, diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.Localizer.Diagnostic.declaredReturnTypePartiallyUnknown().format({
|
2636
|
-
returnType: this._evaluator.printType(declaredReturnType,
|
2806
|
+
returnType: this._evaluator.printType(declaredReturnType, { expandTypeAlias: true }),
|
2637
2807
|
}), returnAnnotation);
|
2638
2808
|
}
|
2639
2809
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
@@ -2672,8 +2842,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2672
2842
|
// the return type matches. This check can also be skipped for an overload.
|
2673
2843
|
if (!ParseTreeUtils.isSuiteEmpty(node.suite) && !types_1.FunctionType.isOverloaded(functionType)) {
|
2674
2844
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.returnMissing().format({
|
2675
|
-
returnType: this._evaluator.printType(declaredReturnType,
|
2676
|
-
/* expandTypeAlias */ false),
|
2845
|
+
returnType: this._evaluator.printType(declaredReturnType),
|
2677
2846
|
}) + diagAddendum.getString(), returnAnnotation);
|
2678
2847
|
}
|
2679
2848
|
}
|
@@ -2687,7 +2856,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2687
2856
|
}
|
2688
2857
|
else if ((0, typeUtils_1.isPartlyUnknown)(inferredReturnType)) {
|
2689
2858
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.returnTypePartiallyUnknown().format({
|
2690
|
-
returnType: this._evaluator.printType(inferredReturnType,
|
2859
|
+
returnType: this._evaluator.printType(inferredReturnType, { expandTypeAlias: true }),
|
2691
2860
|
}), node.name);
|
2692
2861
|
}
|
2693
2862
|
}
|
@@ -2785,7 +2954,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2785
2954
|
}
|
2786
2955
|
}
|
2787
2956
|
else if (decls[0].type === 5 /* Function */) {
|
2788
|
-
if (ParseTreeUtils.isSuiteEmpty(
|
2957
|
+
if (decls.every((decl) => decl.type !== 5 /* Function */ || ParseTreeUtils.isSuiteEmpty(decl.node.suite))) {
|
2789
2958
|
if ((0, pathUtils_1.getFileExtension)(decls[0].path).toLowerCase() !== '.pyi') {
|
2790
2959
|
if (!isSymbolImplemented(name)) {
|
2791
2960
|
diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.missingProtocolMember().format({
|
@@ -2911,6 +3080,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2911
3080
|
// Reports the case where an instance variable is not declared or initialized
|
2912
3081
|
// within the class body or constructor method.
|
2913
3082
|
_validateInstanceVariableInitialization(classType) {
|
3083
|
+
// This check doesn't apply to stub files.
|
3084
|
+
if (this._fileInfo.isStubFile) {
|
3085
|
+
return;
|
3086
|
+
}
|
2914
3087
|
// This check can be expensive, so don't perform it if the corresponding
|
2915
3088
|
// rule is disabled.
|
2916
3089
|
if (this._fileInfo.diagnosticRuleSet.reportUninitializedInstanceVariable === 'none') {
|
@@ -3465,7 +3638,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3465
3638
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.methodOverridden().format({
|
3466
3639
|
name: memberName,
|
3467
3640
|
className: baseClassAndSymbol.classType.details.name,
|
3468
|
-
type: this._evaluator.printType(overrideType
|
3641
|
+
type: this._evaluator.printType(overrideType),
|
3469
3642
|
}), lastDecl.node);
|
3470
3643
|
const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
|
3471
3644
|
if (diag && origDecl) {
|
@@ -3682,9 +3855,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3682
3855
|
}
|
3683
3856
|
}
|
3684
3857
|
else {
|
3858
|
+
const decoratorIsPresent = node.decorators.length > 0;
|
3859
|
+
const isOverloaded = types_1.FunctionType.isOverloaded(functionType);
|
3685
3860
|
// The presence of a decorator can change the behavior, so we need
|
3686
|
-
// to back off from this check if a decorator is present.
|
3687
|
-
|
3861
|
+
// to back off from this check if a decorator is present. An overload
|
3862
|
+
// is a decorator, but we'll ignore that here.
|
3863
|
+
if (isOverloaded || !decoratorIsPresent) {
|
3688
3864
|
let paramName = '';
|
3689
3865
|
let firstParamIsSimple = true;
|
3690
3866
|
if (node.parameters.length > 0) {
|
@@ -3812,7 +3988,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3812
3988
|
if (!this._evaluator.assignType(paramType, expectedType)) {
|
3813
3989
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.clsSelfParamTypeMismatch().format({
|
3814
3990
|
name: paramInfo.name,
|
3815
|
-
classType: this._evaluator.printType(expectedType
|
3991
|
+
classType: this._evaluator.printType(expectedType),
|
3816
3992
|
}), paramInfo.typeAnnotation);
|
3817
3993
|
}
|
3818
3994
|
}
|
@@ -3843,8 +4019,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3843
4019
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
3844
4020
|
if (!this._evaluator.assignType(declaredYieldType, yieldType, diagAddendum)) {
|
3845
4021
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.yieldTypeMismatch().format({
|
3846
|
-
exprType: this._evaluator.printType(yieldType
|
3847
|
-
yieldType: this._evaluator.printType(declaredYieldType
|
4022
|
+
exprType: this._evaluator.printType(yieldType),
|
4023
|
+
yieldType: this._evaluator.printType(declaredYieldType),
|
3848
4024
|
}) + diagAddendum.getString(), node.expression || node);
|
3849
4025
|
}
|
3850
4026
|
}
|
@@ -3856,6 +4032,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3856
4032
|
let sawUnknownExceptionType = false;
|
3857
4033
|
const exceptionTypesSoFar = [];
|
3858
4034
|
node.exceptClauses.forEach((except) => {
|
4035
|
+
var _a, _b;
|
3859
4036
|
if (sawUnknownExceptionType || except.isExceptGroup || !except.typeExpression) {
|
3860
4037
|
return;
|
3861
4038
|
}
|
@@ -3874,8 +4051,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3874
4051
|
typesOfThisExcept.push(exceptionType);
|
3875
4052
|
}
|
3876
4053
|
else if ((0, types_1.isClassInstance)(exceptionType)) {
|
3877
|
-
const iterableType = this._evaluator.getTypeOfIterator(
|
3878
|
-
|
4054
|
+
const iterableType = (_b = (_a = this._evaluator.getTypeOfIterator({ type: exceptionType },
|
4055
|
+
/* isAsync */ false,
|
4056
|
+
/* errorNode */ undefined)) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create();
|
3879
4057
|
(0, typeUtils_1.doForEachSubtype)(iterableType, (subtype) => {
|
3880
4058
|
if ((0, types_1.isAnyOrUnknown)(subtype)) {
|
3881
4059
|
sawUnknownExceptionType = true;
|
@@ -3950,94 +4128,33 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3950
4128
|
}
|
3951
4129
|
});
|
3952
4130
|
}
|
3953
|
-
|
3954
|
-
|
3955
|
-
|
3956
|
-
|
3957
|
-
|
3958
|
-
|
3959
|
-
this._evaluator = _evaluator;
|
3960
|
-
this._fileInfo = _fileInfo;
|
3961
|
-
}
|
3962
|
-
static report(importResolver, evaluator, fileInfo, node) {
|
3963
|
-
if (fileInfo.isStubFile) {
|
3964
|
-
// Don't report this for stub files.
|
3965
|
-
return;
|
3966
|
-
}
|
3967
|
-
new MissingModuleSourceReporter(importResolver, evaluator, fileInfo).walk(node);
|
3968
|
-
}
|
3969
|
-
visitNode(node) {
|
3970
|
-
// Optimization. don't walk into expressions which can't
|
3971
|
-
// have import statement as child nodes.
|
3972
|
-
if ((0, parseNodes_1.isExpressionNode)(node)) {
|
3973
|
-
return [];
|
3974
|
-
}
|
3975
|
-
return super.visitNode(node);
|
3976
|
-
}
|
3977
|
-
visitModule(node) {
|
3978
|
-
const codeComplexity = AnalyzerNodeInfo.getCodeFlowComplexity(node);
|
3979
|
-
if (isPrintCodeComplexityEnabled) {
|
3980
|
-
console.log(`Code complexity of module ${this._fileInfo.filePath} is ${codeComplexity.toString()}`);
|
3981
|
-
}
|
3982
|
-
if (codeComplexity > typeEvaluator_1.maxCodeComplexity) {
|
3983
|
-
this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.codeTooComplexToAnalyze(), { start: 0, length: 0 });
|
3984
|
-
return false;
|
3985
|
-
}
|
3986
|
-
return true;
|
3987
|
-
}
|
3988
|
-
visitModuleName(node) {
|
3989
|
-
const importResult = AnalyzerNodeInfo.getImportInfo(node);
|
3990
|
-
(0, debug_1.assert)(importResult !== undefined);
|
3991
|
-
this._addMissingModuleSourceDiagnosticIfNeeded(importResult, node);
|
3992
|
-
return false;
|
3993
|
-
}
|
3994
|
-
visitImportFromAs(node) {
|
3995
|
-
const decls = this._evaluator.getDeclarationsForNameNode(node.name);
|
3996
|
-
if (!decls) {
|
3997
|
-
return false;
|
3998
|
-
}
|
3999
|
-
for (const decl of decls) {
|
4000
|
-
if (!(0, declaration_1.isAliasDeclaration)(decl) || !decl.submoduleFallback || decl.node !== node) {
|
4001
|
-
// If it is not implicitly imported module, move to next.
|
4002
|
-
continue;
|
4131
|
+
_checkRegions() {
|
4132
|
+
const regionComments = (0, regions_1.getRegionComments)(this._parseResults);
|
4133
|
+
const regionStack = [];
|
4134
|
+
regionComments.forEach((regionComment) => {
|
4135
|
+
if (regionComment.type === 0 /* Region */) {
|
4136
|
+
regionStack.push(regionComment);
|
4003
4137
|
}
|
4004
|
-
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4138
|
+
else {
|
4139
|
+
if (regionStack.length > 0) {
|
4140
|
+
regionStack.pop();
|
4141
|
+
}
|
4142
|
+
else {
|
4143
|
+
this._addDiagnosticForRegionComment(regionComment, localize_1.Localizer.Diagnostic.unmatchedEndregionComment());
|
4144
|
+
}
|
4011
4145
|
}
|
4012
|
-
|
4013
|
-
|
4014
|
-
|
4015
|
-
|
4016
|
-
}
|
4017
|
-
_getImportResult(node, filePath) {
|
4018
|
-
const execEnv = this._importResolver.getConfigOption().findExecEnvironment(filePath);
|
4019
|
-
const moduleNameNode = node.parent.module;
|
4020
|
-
// Handle both absolute and relative imports.
|
4021
|
-
const moduleName = moduleNameNode.leadingDots === 0
|
4022
|
-
? this._importResolver.getModuleNameForImport(filePath, execEnv).moduleName
|
4023
|
-
: (0, importStatementUtils_1.getRelativeModuleName)(this._importResolver.fileSystem, this._fileInfo.filePath, filePath);
|
4024
|
-
if (!moduleName) {
|
4025
|
-
return undefined;
|
4026
|
-
}
|
4027
|
-
return this._importResolver.resolveImport(this._fileInfo.filePath, execEnv, (0, importResolver_1.createImportedModuleDescriptor)(moduleName));
|
4146
|
+
});
|
4147
|
+
regionStack.forEach((regionComment) => {
|
4148
|
+
this._addDiagnosticForRegionComment(regionComment, localize_1.Localizer.Diagnostic.unmatchedRegionComment());
|
4149
|
+
});
|
4028
4150
|
}
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4032
|
-
|
4033
|
-
|
4034
|
-
|
4035
|
-
return;
|
4036
|
-
}
|
4037
|
-
// Type stub found, but source is missing.
|
4038
|
-
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportMissingModuleSource, diagnosticRules_1.DiagnosticRule.reportMissingModuleSource, localize_1.Localizer.Diagnostic.importSourceResolveFailure().format({
|
4039
|
-
importName: importResult.importName,
|
4040
|
-
}), node);
|
4151
|
+
_addDiagnosticForRegionComment(regionComment, message) {
|
4152
|
+
// extend range to include # character
|
4153
|
+
const range = regionComment.comment;
|
4154
|
+
range.start -= 1;
|
4155
|
+
range.length += 1;
|
4156
|
+
return this._evaluator.addDiagnosticForTextRange(this._fileInfo, 'error', '', message, range);
|
4041
4157
|
}
|
4042
4158
|
}
|
4159
|
+
exports.Checker = Checker;
|
4043
4160
|
//# sourceMappingURL=checker.js.map
|