UNPKG

pyright

Version:

Type checker for the Python language

1 lines 2.98 MB
"use strict";exports.id=394,exports.ids=[394],exports.modules={3093:function(e,t,n){var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,r)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&a(t,e,n);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.nullCallback=void 0,t.analyzeProgram=function(e,n,a,r,s,p){let c=!1;r=r??t.nullCallback;try{(0,i.throwIfCancellationRequested)(p);const t=new l.Duration;c=e.analyze(n,p);const s=e.getFilesToAnalyzeCount(),o=void 0!==n,d=e.getDiagnostics(a,o),u=d.length,m=t.getDurationInSeconds();(u>0||!c)&&r({diagnostics:d,filesInProgram:e.getFileCount(),requiringAnalysisCount:s,checkingOnlyOpenFiles:e.isCheckingOnlyOpenFiles(),fatalErrorOccurred:!1,configParseErrorOccurred:!1,elapsedTime:m,reason:"analysis"})}catch(e){if(i.OperationCanceledException.is(e))return!1;const t=o.getErrorString(e);s.error("Error performing analysis: "+t),r({diagnostics:[],filesInProgram:0,requiringAnalysisCount:{files:0,cells:0},checkingOnlyOpenFiles:!0,fatalErrorOccurred:!0,configParseErrorOccurred:!1,elapsedTime:0,error:o.getSerializableError(e),reason:"analysis"})}return c};const i=n(7824),o=s(n(2607)),l=n(9864);t.nullCallback=()=>{}},2875:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isAnnotationEvaluationPostponed=function(e){return!!e.isStubFile||(!!e.futureImports.has("annotations")||!!a.PythonVersion.isGreaterOrEqualTo(e.executionEnvironment.pythonVersion,a.pythonVersion3_14))};const a=n(8818)},2677:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cleanNodeAnalysisInfo=function(e){const t=s(e);t?.scope&&(t.scope=void 0),t?.declaration&&(t.declaration=void 0),t?.flowNode&&(t.flowNode=void 0),t?.afterFlowNode&&(t.afterFlowNode=void 0),t?.fileInfo&&(t.fileInfo=void 0),t?.codeFlowExpressions&&(t.codeFlowExpressions=void 0),t?.codeFlowComplexity&&(t.codeFlowComplexity=void 0),t?.dunderAllInfo&&(t.dunderAllInfo=void 0),t?.typeParamSymbol&&(t.typeParamSymbol=void 0)},t.getImportInfo=function(e){const t=s(e);return t?.importInfo},t.setImportInfo=function(e,t){i(e).importInfo=t},t.getScope=function(e){const t=s(e);return t?.scope},t.setScope=function(e,t){i(e).scope=t},t.getDeclaration=function(e){const t=s(e);return t?.declaration},t.setDeclaration=function(e,t){i(e).declaration=t},t.getFlowNode=r,t.setFlowNode=function(e,t){i(e).flowNode=t},t.getAfterFlowNode=function(e){const t=s(e);return t?.afterFlowNode},t.setAfterFlowNode=function(e,t){i(e).afterFlowNode=t},t.getFileInfo=function(e){for(;36!==e.nodeType;)e=e.parent;return s(e).fileInfo},t.setFileInfo=function(e,t){i(e).fileInfo=t},t.getCodeFlowExpressions=function(e){const t=s(e);return t?.codeFlowExpressions},t.setCodeFlowExpressions=function(e,t){i(e).codeFlowExpressions=t},t.getCodeFlowComplexity=function(e){const t=s(e);return t?.codeFlowComplexity??0},t.setCodeFlowComplexity=function(e,t){i(e).codeFlowComplexity=t},t.getDunderAllInfo=function(e){const t=s(e);return t?.dunderAllInfo},t.setDunderAllInfo=function(e,t){i(e).dunderAllInfo=t},t.isCodeUnreachable=function(e){let t=e;for(;t;){const e=r(t);if(e)return!!(e.flags&a.FlowFlags.Unreachable);t=t.parent}return!1};const a=n(1973);function r(e){const t=s(e);return t?.flowNode}function s(e){return e.a}function i(e){let t=e.a;return t||(e.a=t={}),t}},9689:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BackgroundAnalysisProgram=t.InvalidatedReason=void 0,n(2816);const a=n(3093),r=n(6767);var s;!function(e){e[e.Reanalyzed=0]="Reanalyzed",e[e.SourceWatcherChanged=1]="SourceWatcherChanged",e[e.LibraryWatcherChanged=2]="LibraryWatcherChanged",e[e.LibraryWatcherContentOnlyChanged=3]="LibraryWatcherContentOnlyChanged"}(s||(t.InvalidatedReason=s={})),t.BackgroundAnalysisProgram=class{constructor(e,t,n,a,s,i,o){this.serviceId=e,this._serviceProvider=t,this._configOptions=n,this._importResolver=a,this._backgroundAnalysis=s,this._maxAnalysisTime=i,this._disableChecker=o,this._disposed=!1,this._program=new r.Program(this.importResolver,this.configOptions,this._serviceProvider,void 0,this._disableChecker,e),this._backgroundAnalysis?.setProgramView(this._program)}get serviceProvider(){return this._serviceProvider}get configOptions(){return this._configOptions}get importResolver(){return this._importResolver}get program(){return this._program}get host(){return this._importResolver.host}get backgroundAnalysis(){return this._backgroundAnalysis}hasSourceFile(e){return!!this._program.getSourceFile(e)}setConfigOptions(e){this._configOptions=e,this._backgroundAnalysis?.setConfigOptions(e),this._program.setConfigOptions(e)}setImportResolver(e){this._importResolver=e,this._backgroundAnalysis?.setImportResolver(e),this._program.setImportResolver(e),this.configOptions.getExecutionEnvironments().forEach((e=>this._ensurePartialStubPackages(e)))}setTrackedFiles(e){this._backgroundAnalysis?.setTrackedFiles(e);const t=this._program.setTrackedFiles(e);this._reportDiagnosticsForRemovedFiles(t)}setAllowedThirdPartyImports(e){this._backgroundAnalysis?.setAllowedThirdPartyImports(e),this._program.setAllowedThirdPartyImports(e)}setFileOpened(e,t,n,a){this._backgroundAnalysis?.setFileOpened(e,t,n,a),this._program.setFileOpened(e,t,n,a)}getChainedUri(e){return this._program.getChainedUri(e)}updateChainedUri(e,t){this._backgroundAnalysis?.updateChainedUri(e,t),this._program.updateChainedUri(e,t)}updateOpenFileContents(e,t,n,a){this._backgroundAnalysis?.setFileOpened(e,t,n,a),this._program.setFileOpened(e,t,n,a),this.markFilesDirty([e],!0)}setFileClosed(e,t){this._backgroundAnalysis?.setFileClosed(e,t);const n=this._program.setFileClosed(e,t);this._reportDiagnosticsForRemovedFiles(n)}addInterimFile(e){this._backgroundAnalysis?.addInterimFile(e),this._program.addInterimFile(e)}markAllFilesDirty(e){this._backgroundAnalysis?.markAllFilesDirty(e),this._program.markAllFilesDirty(e)}markFilesDirty(e,t){this._backgroundAnalysis?.markFilesDirty(e,t),this._program.markFilesDirty(e,t)}setCompletionCallback(e){this._onAnalysisCompletion=e,this._backgroundAnalysis?.setCompletionCallback(e)}startAnalysis(e){return this._backgroundAnalysis?(this._backgroundAnalysis.startAnalysis(e),!1):(0,a.analyzeProgram)(this._program,this._maxAnalysisTime,this._configOptions,this._onAnalysisCompletion,this._serviceProvider.console(),e)}async analyzeFile(e,t){return this._backgroundAnalysis?this._backgroundAnalysis.analyzeFile(e,t):this._program.analyzeFile(e,t)}libraryUpdated(){return!1}async getDiagnosticsForRange(e,t,n){return this._backgroundAnalysis?this._backgroundAnalysis.getDiagnosticsForRange(e,t,n):this._program.getDiagnosticsForRange(e,t)}async writeTypeStub(e,t,n,r){return this._backgroundAnalysis?this._backgroundAnalysis.writeTypeStub(e,t,n,r):((0,a.analyzeProgram)(this._program,void 0,this._configOptions,this._onAnalysisCompletion,this._serviceProvider.console(),r),this._program.writeTypeStub(e,t,n,r))}invalidateAndForceReanalysis(e){this._backgroundAnalysis?.invalidateAndForceReanalysis(e),this._importResolver.invalidateCache(),this._program.markAllFilesDirty(!0)}restart(){this._backgroundAnalysis?.restart()}dispose(){this._disposed||(this._disposed=!0,this._program.dispose(),this._backgroundAnalysis?.shutdown(),this._backgroundAnalysis?.dispose())}enterEditMode(){this._preEditAnalysis=this._backgroundAnalysis,this._backgroundAnalysis=void 0,this._program.enterEditMode()}exitEditMode(){return this._backgroundAnalysis=this._preEditAnalysis,this._preEditAnalysis=void 0,this._program.exitEditMode()}_ensurePartialStubPackages(e){return this._backgroundAnalysis?.ensurePartialStubPackages(e.root?.toString()),this._importResolver.ensurePartialStubPackages(e)}_reportDiagnosticsForRemovedFiles(e){0!==e.length&&!this._backgroundAnalysis&&this._onAnalysisCompletion&&this._onAnalysisCompletion({diagnostics:e,filesInProgram:this._program.getFileCount(),requiringAnalysisCount:this._program.getFilesToAnalyzeCount(),checkingOnlyOpenFiles:this._program.isCheckingOnlyOpenFiles(),fatalErrorOccurred:!1,configParseErrorOccurred:!1,elapsedTime:0,reason:"tracking"})}}},9295:function(e,t,n){var a=this&&this.__createBinding||(Object.create?function(e,t,n,a){void 0===a&&(a=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,a,r)}:function(e,t,n,a){void 0===a&&(a=n),e[a]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&a(t,e,n);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.DummyScopeGenerator=t.ReturnFinder=t.YieldFinder=t.Binder=void 0;const i=n(6033),o=n(2607),l=n(9034),p=n(5636),c=n(7976),d=n(9484),u=n(8643),m=n(5385),y=s(n(2677)),g=n(1973),h=n(391),f=s(n(755)),T=n(1698),v=n(3195),b=s(n(518)),_=n(4343),C=n(8127);class I extends T.ParseTreeWalker{constructor(e,t=!1){super(),this._moduleSymbolOnly=t,this._deferredBindingTasks=[],this._currentExceptTargets=[],this._finallyTargets=[],this._typingImportAliases=[],this._sysImportAliases=[],this._dataclassesImportAliases=[],this._typingSymbolAliases=new Map,this._dataclassesSymbolAliases=new Map,this._dunderAllStringNodes=[],this._usesUnsupportedDunderAllForm=!1,this._isInExceptSuite=!1,this._isInAnnotatedAnnotation=!1,this._potentialHiddenSymbols=new Map,this._potentialPrivateSymbols=new Map,this._codeFlowComplexity=0,this._fileInfo=e}bindModule(e){const t=void 0===this._fileInfo.builtinsScope;this._addTypingImportAliasesFromBuiltinsScope(),this._createNewScope(t?5:4,this._fileInfo.builtinsScope,void 0,(()=>{y.setScope(e,this._currentScope),y.setFlowNode(e,this._currentFlowNode),this._addImplicitSymbolToCurrentScope("__name__",e,"str"),this._addImplicitSymbolToCurrentScope("__loader__",e,"Any"),this._addImplicitSymbolToCurrentScope("__package__",e,"str | None"),this._addImplicitSymbolToCurrentScope("__spec__",e,"Any"),this._addImplicitSymbolToCurrentScope("__path__",e,"Iterable[str]"),this._addImplicitSymbolToCurrentScope("__file__",e,"str"),this._addImplicitSymbolToCurrentScope("__cached__",e,"str"),this._addImplicitSymbolToCurrentScope("__dict__",e,"Dict[str, Any]"),this._addImplicitSymbolToCurrentScope("__annotations__",e,"Dict[str, Any]"),this._addImplicitSymbolToCurrentScope("__builtins__",e,"Any"),this._addImplicitSymbolToCurrentScope("__doc__",e,"str | None"),this._currentFlowNode=this._createStartFlowNode(),this._walkStatementsAndReportUnreachable(e.d.statements),y.setAfterFlowNode(e,this._currentFlowNode),y.setCodeFlowExpressions(e,this._currentScopeCodeFlowExpressions),y.setCodeFlowComplexity(e,this._codeFlowComplexity)})),this._bindDeferred(),this._potentialHiddenSymbols.forEach(((e,t)=>{this._dunderAllNames?.some((e=>e===t))||(this._fileInfo.isStubFile?e.setIsExternallyHidden():e.setPrivatePyTypedImport())})),this._potentialPrivateSymbols.forEach(((e,t)=>{this._dunderAllNames?.some((e=>e===t))||e.setIsPrivateMember()})),this._dunderAllNames?y.setDunderAllInfo(e,{names:this._dunderAllNames,stringNodes:this._dunderAllStringNodes,usesUnsupportedDunderAllForm:this._usesUnsupportedDunderAllForm}):y.setDunderAllInfo(e,void 0);const n=y.getScope(e);if(n&&this._dunderAllNames)for(const e of this._dunderAllNames)n.symbolTable.get(e)?.setIsInDunderAll()}visitModule(e){return(0,o.fail)("We should never get here"),!1}visitSuite(e){return this._walkStatementsAndReportUnreachable(e.d.statements),!1}visitModuleName(e){const t=y.getImportInfo(e);if((0,o.assert)(void 0!==t),t.isNativeLib)return!0;if(!t.isImportFound)return this._addDiagnostic(l.DiagnosticRule.reportMissingImports,m.LocMessage.importResolveFailure().format({importName:t.importName,venv:this._fileInfo.executionEnvironment.name}),e),!0;if(!t.isStubFile&&1===t.importType&&!t.pyTypedInfo){const n=this._addDiagnostic(l.DiagnosticRule.reportMissingTypeStubs,m.LocMessage.stubFileMissing().format({importName:t.importName}),e);if(n){const e={action:"pyright.createtypestub",moduleName:t.importName};n.addAction(e)}}return!0}visitClass(e){this.walkMultiple(e.d.decorators);const t={type:6,node:e,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e.d.name,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite},n=this._bindNameToScope(this._currentScope,e.d.name);let a;return n&&n.addDeclaration(t),y.setDeclaration(e,t),e.d.typeParams&&(this.walk(e.d.typeParams),a=y.getScope(e.d.typeParams)),this.walkMultiple(e.d.arguments),this._createNewScope(3,a??this._getNonClassParentScope(),void 0,(()=>{y.setScope(e,this._currentScope),this._addImplicitSymbolToCurrentScope("__doc__",e,"str | None"),this._addImplicitSymbolToCurrentScope("__module__",e,"str"),this._addImplicitSymbolToCurrentScope("__qualname__",e,"str"),this._dunderSlotsEntries=void 0,this._moduleSymbolOnly||this.walk(e.d.suite),this._dunderSlotsEntries&&this._addSlotsToCurrentScope(this._dunderSlotsEntries),this._dunderSlotsEntries=void 0})),this._createAssignmentTargetFlowNodes(e.d.name,!1,!1),!1}visitFunction(e){this._createVariableAnnotationFlowNode(),y.setFlowNode(e,this._currentFlowNode);const t=this._bindNameToScope(this._currentScope,e.d.name),n=f.getEnclosingClass(e,!0),a={type:5,node:e,isMethod:!!n,isGenerator:!1,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e.d.name,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite};let r;return t&&t.addDeclaration(a),y.setDeclaration(e,a),e.d.params.forEach((e=>{e.d.defaultValue&&this.walk(e.d.defaultValue)})),e.d.typeParams&&(this.walk(e.d.typeParams),r=y.getScope(e.d.typeParams)),this.walkMultiple(e.d.decorators),e.d.params.forEach((e=>{e.d.annotation&&this.walk(e.d.annotation),e.d.annotationComment&&this.walk(e.d.annotationComment)})),e.d.returnAnnotation&&this.walk(e.d.returnAnnotation),e.d.funcAnnotationComment&&this.walk(e.d.funcAnnotationComment),this._createNewScope(2,r??this._getNonClassParentScope(),void 0,(()=>{y.setScope(e,this._currentScope),f.getEnclosingClass(e)&&this._addImplicitSymbolToCurrentScope("__class__",e,"type[self]"),this._deferBinding((()=>{this._currentFlowNode=this._createStartFlowNode(),this._codeFlowComplexity=0,e.d.params.forEach((e=>{if(e.d.name){const t=this._bindNameToScope(this._currentScope,e.d.name);if(t){const n={type:2,node:e,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite};t.addDeclaration(n),y.setDeclaration(e.d.name,n)}this._createFlowAssignment(e.d.name)}})),this._targetFunctionDeclaration=a,this._currentReturnTarget=this._createBranchLabel(),this.walk(e.d.suite),this._targetFunctionDeclaration=void 0,y.setAfterFlowNode(e.d.suite,this._currentFlowNode),this._addAntecedent(this._currentReturnTarget,this._currentFlowNode);const t=this._finishFlowLabel(this._currentReturnTarget);y.setAfterFlowNode(e,t),y.setCodeFlowExpressions(e,this._currentScopeCodeFlowExpressions),y.setCodeFlowComplexity(e,this._codeFlowComplexity)}))})),this._createAssignmentTargetFlowNodes(e.d.name,!1,!1),!1}visitLambda(e){return this._createVariableAnnotationFlowNode(),y.setFlowNode(e,this._currentFlowNode),e.d.params.forEach((e=>{e.d.defaultValue&&this.walk(e.d.defaultValue)})),this._createNewScope(2,this._getNonClassParentScope(),void 0,(()=>{y.setScope(e,this._currentScope),this._deferBinding((()=>{this._currentFlowNode=this._createStartFlowNode(),e.d.params.forEach((e=>{if(e.d.name){const t=this._bindNameToScope(this._currentScope,e.d.name);if(t){const n={type:2,node:e,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite};t.addDeclaration(n),y.setDeclaration(e.d.name,n)}this._createFlowAssignment(e.d.name),this.walk(e.d.name),y.setFlowNode(e,this._currentFlowNode)}})),this.walk(e.d.expr),y.setCodeFlowExpressions(e,this._currentScopeCodeFlowExpressions)}))})),!1}visitCall(e){if(this._disableTrueFalseTargets((()=>{this.walk(e.d.leftExpr),f.getArgsByRuntimeOrder(e).forEach((e=>{this._currentFlowNode&&y.setFlowNode(e,this._currentFlowNode),this.walk(e)}))})),f.isNodeContainedWithinNodeType(e,16)||this._isInAnnotatedAnnotation||this._createCallFlowNode(e),4===this._currentScope.type&&35===e.d.leftExpr.nodeType&&38===e.d.leftExpr.d.leftExpr.nodeType&&"__all__"===e.d.leftExpr.d.leftExpr.d.value){let t=!0;if("extend"===e.d.leftExpr.d.member.d.value&&1===e.d.args.length){const n=e.d.args[0].d.valueExpr;if(34===n.nodeType)n.d.items.every((e=>48===e.nodeType&&1===e.d.strings.length&&49===e.d.strings[0].nodeType&&(this._dunderAllNames?.push(e.d.strings[0].d.value),this._dunderAllStringNodes?.push(e.d.strings[0]),!0)))&&(t=!1);else if(35===n.nodeType&&38===n.d.leftExpr.nodeType&&"__all__"===n.d.member.d.value){const e=this._getDunderAllNamesFromImport(n.d.leftExpr.d.value);e&&e.length>0&&e.forEach((e=>{this._dunderAllNames?.push(e)})),t=!1}}else if("remove"===e.d.leftExpr.d.member.d.value&&1===e.d.args.length){const n=e.d.args[0].d.valueExpr;48===n.nodeType&&1===n.d.strings.length&&49===n.d.strings[0].nodeType&&this._dunderAllNames&&(this._dunderAllNames=this._dunderAllNames.filter((e=>e!==n.d.strings[0].d.value)),this._dunderAllStringNodes=this._dunderAllStringNodes.filter((e=>e.d.value!==n.d.strings[0].d.value)),t=!1)}else if("append"===e.d.leftExpr.d.member.d.value&&1===e.d.args.length){const n=e.d.args[0].d.valueExpr;48===n.nodeType&&1===n.d.strings.length&&49===n.d.strings[0].nodeType&&(this._dunderAllNames?.push(n.d.strings[0].d.value),this._dunderAllStringNodes?.push(n.d.strings[0]),t=!1)}t&&(this._usesUnsupportedDunderAllForm=!0,this._addDiagnostic(l.DiagnosticRule.reportUnsupportedDunderAll,m.LocMessage.unsupportedDunderAllOperation(),e))}return!1}visitTypeParameterList(e){const t=new v.Scope(0,this._getNonClassParentScope(),this._currentScope);e.d.params.forEach((e=>{e.d.boundExpr&&this.walk(e.d.boundExpr)}));const n=new Set;return e.d.params.forEach((a=>{const r=a.d.name,s=t.addSymbol(r.d.value,0),i={type:3,node:a,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite};s.addDeclaration(i),y.setDeclaration(r,i),n.has(r.d.value)?this._addSyntaxError(m.LocMessage.typeParameterExistingTypeParameter().format({name:r.d.value}),r):n.add(r.d.value)})),e.d.params.forEach((e=>{e.d.defaultExpr&&this.walk(e.d.defaultExpr)})),y.setScope(e,t),!1}visitTypeAlias(e){let t;this._bindNameToScope(this._currentScope,e.d.name),this.walk(e.d.name),e.d.typeParams&&(this.walk(e.d.typeParams),t=y.getScope(e.d.typeParams));const n={type:4,node:e,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e.d.name,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite,docString:this._getVariableDocString(e.d.expr)},a=this._bindNameToScope(this._currentScope,e.d.name);a&&a.addDeclaration(n),y.setDeclaration(e,n),this._createAssignmentTargetFlowNodes(e.d.name,!0,!1);const r=this._currentScope;return this._currentScope=t??this._currentScope,this.walk(e.d.expr),this._currentScope=r,!1}visitAssignment(e){if(this._handleTypingStubAssignmentOrAnnotation(e))return!1;if(this._bindPossibleTupleNamedTarget(e.d.leftExpr),e.d.annotationComment&&(this.walk(e.d.annotationComment),this._addTypeDeclarationForVariable(e.d.leftExpr,e.d.annotationComment)),e.d.chainedAnnotationComment&&this._addDiagnostic(l.DiagnosticRule.reportInvalidTypeForm,m.LocMessage.annotationNotSupported(),e.d.chainedAnnotationComment),27===e.d.leftExpr.nodeType){const t=e.d.leftExpr;if(1===t.d.items.length&&!t.d.trailingComma&&48===t.d.items[0].d.valueExpr.nodeType&&(0,g.isCodeFlowSupportedForReference)(t.d.leftExpr)){const e=(0,g.createKeyForReference)(t.d.leftExpr);this._currentScopeCodeFlowExpressions.add(e)}}this.walk(e.d.rightExpr);let t=!0;if((f.getEnclosingFunction(e)||9===e.d.rightExpr.nodeType&&this._fileInfo.isTypingStubFile||f.isWithinLoop(e))&&(t=!1),this._addInferredTypeAssignmentForVariable(e.d.leftExpr,e.d.rightExpr,t),this._createAssignmentTargetFlowNodes(e.d.leftExpr,!0,!1),4===this._currentScope.type&&(38===e.d.leftExpr.nodeType&&"__all__"===e.d.leftExpr.d.value||54===e.d.leftExpr.nodeType&&38===e.d.leftExpr.d.valueExpr.nodeType&&"__all__"===e.d.leftExpr.d.valueExpr.d.value)){const t=e.d.rightExpr;this._dunderAllNames=[];let n=!1;34===t.nodeType?t.d.items.forEach((e=>{48===e.nodeType&&1===e.d.strings.length&&49===e.d.strings[0].nodeType?(this._dunderAllNames.push(e.d.strings[0].d.value),this._dunderAllStringNodes.push(e.d.strings[0])):n=!0})):52===t.nodeType?t.d.items.forEach((e=>{48===e.nodeType&&1===e.d.strings.length&&49===e.d.strings[0].nodeType?(this._dunderAllNames.push(e.d.strings[0].d.value),this._dunderAllStringNodes.push(e.d.strings[0])):n=!0})):n=!0,n&&(this._usesUnsupportedDunderAllForm=!0,this._addDiagnostic(l.DiagnosticRule.reportUnsupportedDunderAll,m.LocMessage.unsupportedDunderAllOperation(),e))}if(3===this._currentScope.type&&(38===e.d.leftExpr.nodeType&&"__slots__"===e.d.leftExpr.d.value||54===e.d.leftExpr.nodeType&&38===e.d.leftExpr.d.valueExpr.nodeType&&"__slots__"===e.d.leftExpr.d.valueExpr.d.value)){const t=e.d.rightExpr;this._dunderSlotsEntries=[];let n=!0;48===t.nodeType?this._dunderSlotsEntries.push(t):34===t.nodeType?t.d.items.forEach((e=>{48===e.nodeType&&1===e.d.strings.length&&49===e.d.strings[0].nodeType?this._dunderSlotsEntries.push(e):n=!1})):52===t.nodeType?t.d.items.forEach((e=>{48===e.nodeType&&1===e.d.strings.length&&49===e.d.strings[0].nodeType?this._dunderSlotsEntries.push(e):n=!1})):n=!1,n||(this._dunderSlotsEntries=void 0)}return!1}visitAssignmentExpression(e){this._disableTrueFalseTargets((()=>{this.walk(e.d.rightExpr)}));const t=f.getEvaluationNodeForAssignmentExpression(e);if(t){const n=y.getScope(t);let a=this._currentScope;for(;a&&a!==n;){if(a.lookUpSymbol(e.d.name.d.value)){this._addSyntaxError(m.LocMessage.assignmentExprComprehension().format({name:e.d.name.d.value}),e.d.name);break}a=a.parent}this._bindNameToScope(n,e.d.name),this._addInferredTypeAssignmentForVariable(e.d.name,e.d.rightExpr),this._createAssignmentTargetFlowNodes(e.d.name,!0,!1)}else this._addSyntaxError(m.LocMessage.assignmentExprContext(),e),this.walk(e.d.name);return!1}visitAugmentedAssignment(e){if(this.walk(e.d.leftExpr),this.walk(e.d.rightExpr),this._bindPossibleTupleNamedTarget(e.d.destExpr),this._createAssignmentTargetFlowNodes(e.d.destExpr,!1,!1),this._addInferredTypeAssignmentForVariable(e.d.destExpr,e.d.rightExpr),1===e.d.operator&&4===this._currentScope.type&&38===e.d.leftExpr.nodeType&&"__all__"===e.d.leftExpr.d.value){const t=e.d.rightExpr;let n=!0;if(34===t.nodeType)t.d.items.forEach((e=>{48===e.nodeType&&1===e.d.strings.length&&49===e.d.strings[0].nodeType&&(this._dunderAllNames?.push(e.d.strings[0].d.value),this._dunderAllStringNodes.push(e.d.strings[0]))})),n=!1;else if(35===t.nodeType&&38===t.d.leftExpr.nodeType&&"__all__"===t.d.member.d.value){const e=this._getDunderAllNamesFromImport(t.d.leftExpr.d.value);e&&(e.forEach((e=>{this._dunderAllNames?.push(e)})),n=!1)}n&&(this._usesUnsupportedDunderAllForm=!0,this._addDiagnostic(l.DiagnosticRule.reportUnsupportedDunderAll,m.LocMessage.unsupportedDunderAllOperation(),e))}return!1}visitDel(e){return e.d.targets.forEach((e=>{this._bindPossibleTupleNamedTarget(e),this.walk(e),this._createAssignmentTargetFlowNodes(e,!1,!0)})),!1}visitTypeAnnotation(e){if(this._handleTypingStubAssignmentOrAnnotation(e))return!1;const t=3===e.parent?.nodeType&&void 0!==f.getEnclosingClass(e,!0);t||this.walk(e.d.annotation),this._createVariableAnnotationFlowNode(),this._bindPossibleTupleNamedTarget(e.d.valueExpr),this._addTypeDeclarationForVariable(e.d.valueExpr,e.d.annotation),t&&this.walk(e.d.annotation);const n=[];return this._isNarrowingExpression(e.d.valueExpr,n)&&n.forEach((e=>{const t=(0,g.createKeyForReference)(e);this._currentScopeCodeFlowExpressions.add(t)})),this.walk(e.d.valueExpr),!1}visitFor(e){this._bindPossibleTupleNamedTarget(e.d.targetExpr),this._addInferredTypeAssignmentForVariable(e.d.targetExpr,e),this.walk(e.d.iterableExpr);const t=this._createLoopLabel(),n=this._createBranchLabel(),a=this._createBranchLabel();this._addAntecedent(t,this._currentFlowNode),this._currentFlowNode=t,this._addAntecedent(n,this._currentFlowNode);const r=this._trackCodeFlowExpressions((()=>{this._createAssignmentTargetFlowNodes(e.d.targetExpr,!0,!1)}));if(this._bindLoopStatement(t,a,(()=>{this.walk(e.d.forSuite),this._addAntecedent(t,this._currentFlowNode),r.forEach((e=>{this._currentScopeCodeFlowExpressions?.add(e)}))})),this._currentFlowNode=this._finishFlowLabel(n),e.d.elseSuite&&this.walk(e.d.elseSuite),this._addAntecedent(a,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(a),e.d.asyncToken&&!this._fileInfo.ipythonMode){const t=f.getEnclosingFunction(e);t&&t.d.isAsync||this._addSyntaxError(m.LocMessage.asyncNotInAsyncFunction(),e.d.asyncToken)}return!1}visitContinue(e){return this._currentContinueTarget&&this._addAntecedent(this._currentContinueTarget,this._currentFlowNode),this._currentFlowNode=I._unreachableFlowNode,!1}visitBreak(e){return this._currentBreakTarget&&this._addAntecedent(this._currentBreakTarget,this._currentFlowNode),this._currentFlowNode=I._unreachableFlowNode,!1}visitReturn(e){return this._targetFunctionDeclaration&&(this._targetFunctionDeclaration.returnStatements||(this._targetFunctionDeclaration.returnStatements=[]),this._targetFunctionDeclaration.returnStatements.push(e)),e.d.expr&&this.walk(e.d.expr),y.setFlowNode(e,this._currentFlowNode),this._currentReturnTarget&&this._addAntecedent(this._currentReturnTarget,this._currentFlowNode),this._finallyTargets.forEach((e=>{this._addAntecedent(e,this._currentFlowNode)})),this._currentFlowNode=I._unreachableFlowNode,!1}visitYield(e){return this._isInComprehension(e,!0)&&this._addSyntaxError(m.LocMessage.yieldWithinComprehension(),e),this._bindYield(e),!1}visitYieldFrom(e){return this._isInComprehension(e,!0)&&this._addSyntaxError(m.LocMessage.yieldWithinComprehension(),e),this._bindYield(e),!1}visitMemberAccess(e){return this.walk(e.d.leftExpr),y.setFlowNode(e,this._currentFlowNode),!1}visitName(e){return y.setFlowNode(e,this._currentFlowNode),!1}visitIndex(e){y.setFlowNode(e,this._currentFlowNode),this.walk(e.d.leftExpr);const t=this._isInAnnotatedAnnotation;return this._isTypingAnnotation(e.d.leftExpr,"Annotated")&&(this._isInAnnotatedAnnotation=!0),e.d.items.forEach((e=>{this.walk(e)})),this._isInAnnotatedAnnotation=t,!1}visitIf(e){const t=this._currentFlowNode,n=this._createBranchLabel(),a=this._createBranchLabel(),r=this._createBranchLabel(t);return r.affectedExpressions=this._trackCodeFlowExpressions((()=>{const t=b.evaluateStaticBoolLikeExpression(e.d.testExpr,this._fileInfo.executionEnvironment,this._fileInfo.definedConstants,this._typingImportAliases,this._sysImportAliases);this._bindConditional(e.d.testExpr,n,a),this._currentFlowNode=!1===t?I._unreachableFlowNode:this._finishFlowLabel(n),this.walk(e.d.ifSuite),this._addAntecedent(r,this._currentFlowNode),this._currentFlowNode=!0===t?I._unreachableFlowNode:this._finishFlowLabel(a),e.d.elseSuite?this.walk(e.d.elseSuite):this._bindNeverCondition(e.d.testExpr,r,!1),this._addAntecedent(r,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(r)})),!1}visitWhile(e){const t=this._createBranchLabel(),n=this._createBranchLabel(),a=this._createBranchLabel(),r=b.evaluateStaticBoolLikeExpression(e.d.testExpr,this._fileInfo.executionEnvironment,this._fileInfo.definedConstants,this._typingImportAliases,this._sysImportAliases),s=this._createLoopLabel();return this._addAntecedent(s,this._currentFlowNode),this._currentFlowNode=s,this._bindConditional(e.d.testExpr,t,n),this._currentFlowNode=!1===r?I._unreachableFlowNode:this._finishFlowLabel(t),this._bindLoopStatement(s,a,(()=>{this.walk(e.d.whileSuite)})),this._addAntecedent(s,this._currentFlowNode),this._currentFlowNode=!0===r?I._unreachableFlowNode:this._finishFlowLabel(n),e.d.elseSuite&&this.walk(e.d.elseSuite),this._addAntecedent(a,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(a),!1}visitAssert(e){const t=this._createBranchLabel(),n=this._createBranchLabel();return this._bindConditional(e.d.testExpr,t,n),e.d.exceptionExpr&&(this._currentFlowNode=this._finishFlowLabel(n),this.walk(e.d.exceptionExpr)),this._currentFlowNode=this._finishFlowLabel(t),!1}visitExcept(e){if(e.d.typeExpr&&this.walk(e.d.typeExpr),e.d.name){this.walk(e.d.name);const t=this._bindNameToScope(this._currentScope,e.d.name);if(this._createAssignmentTargetFlowNodes(e.d.name,!0,!1),t){const n={type:1,node:e.d.name,isConstant:(0,C.isConstantName)(e.d.name.d.value),inferredTypeSource:e,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e.d.name,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite,isExplicitBinding:void 0!==this._currentScope.getBindingType(e.d.name.d.value)};t.addDeclaration(n)}}const t=this._isInExceptSuite;return this._isInExceptSuite=!0,this.walk(e.d.exceptSuite),this._isInExceptSuite=t,e.d.name&&this._createFlowAssignment(e.d.name,!0),!1}visitRaise(e){return this._currentFlowNode&&this._addExceptTargets(this._currentFlowNode),this._targetFunctionDeclaration&&(this._targetFunctionDeclaration.raiseStatements||(this._targetFunctionDeclaration.raiseStatements=[]),this._targetFunctionDeclaration.raiseStatements.push(e)),e.d.expr&&this.walk(e.d.expr),e.d.fromExpr&&this.walk(e.d.fromExpr),this._finallyTargets.forEach((e=>{this._addAntecedent(e,this._currentFlowNode)})),this._currentFlowNode=I._unreachableFlowNode,!1}visitTry(e){const t=this._currentFlowNode,n=e.d.exceptClauses.map((()=>this._createBranchLabel())),a=this._createBranchLabel(t);let r=!1;const s=this._createBranchLabel(t),i={flags:g.FlowFlags.PreFinallyGate,id:this._getUniqueFlowNodeId(),antecedent:s};if(a.affectedExpressions=this._trackCodeFlowExpressions((()=>{e.d.finallySuite&&this._addAntecedent(a,i),e.d.exceptClauses.some((e=>!e.d.typeExpr))||n.push(s),n.forEach((e=>{this._addAntecedent(e,this._currentFlowNode)})),e.d.finallySuite&&this._finallyTargets.push(s),this._useExceptTargets(n,(()=>{this.walk(e.d.trySuite)})),e.d.elseSuite&&this.walk(e.d.elseSuite),this._addAntecedent(a,this._currentFlowNode),this._isCodeUnreachable()||(r=!0),e.d.exceptClauses.forEach(((e,t)=>{this._currentFlowNode=this._finishFlowLabel(n[t]),this.walk(e),this._addAntecedent(a,this._currentFlowNode),this._isCodeUnreachable()||(r=!0)})),e.d.finallySuite&&this._finallyTargets.pop(),this._currentFlowNode=this._finishFlowLabel(a)})),e.d.finallySuite){this.walk(e.d.finallySuite);const t={flags:g.FlowFlags.PostFinally,id:this._getUniqueFlowNodeId(),finallyNode:e.d.finallySuite,antecedent:this._currentFlowNode,preFinallyGate:i};this._currentFlowNode=r?t:I._unreachableFlowNode}return!1}visitAwait(e){const t=f.getExecutionScopeNode(e);if(31!==t?.nodeType||!t.d.isAsync){if(this._fileInfo.ipythonMode&&36===t?.nodeType)return!0;11===e.parent?.nodeType&&34!==e.parent?.parent?.nodeType&&45!==e.parent?.parent?.nodeType&&18!==e.parent?.parent?.nodeType||this._addSyntaxError(m.LocMessage.awaitNotInAsync(),e.d.awaitToken)}return!0}visitGlobal(e){const t=this._currentScope.getGlobalScope().scope;return e.d.targets.forEach((e=>{const n=e.d.value;0===this._currentScope.getBindingType(n)&&this._addSyntaxError(m.LocMessage.nonLocalRedefinition().format({name:n}),e);const a=this._currentScope.lookUpSymbolRecursive(n);a&&a.scope===this._currentScope&&this._addSyntaxError(m.LocMessage.globalReassignment().format({name:n}),e),this._bindNameToScope(t,e),this._currentScope!==t&&this._currentScope.setBindingType(n,1)})),!0}visitNonlocal(e){const t=this._currentScope.getGlobalScope().scope;return this._currentScope===t?this._addSyntaxError(m.LocMessage.nonLocalInModule(),e):e.d.targets.forEach((e=>{const n=e.d.value;1===this._currentScope.getBindingType(n)&&this._addSyntaxError(m.LocMessage.globalRedefinition().format({name:n}),e);const a=this._currentScope.lookUpSymbolRecursive(n);a&&a.scope===this._currentScope?this._addSyntaxError(m.LocMessage.nonLocalReassignment().format({name:n}),e):a&&a.scope!==t||this._addSyntaxError(m.LocMessage.nonLocalNoBinding().format({name:n}),e),a&&this._currentScope.setBindingType(n,0)})),!0}visitImportAs(e){if(e.d.module.d.nameParts.length>0){const t=e.d.module.d.nameParts[0].d.value;let n,a;e.d.alias?(n=e.d.alias.d.value,a=e.d.alias):(n=t,a=e.d.module.d.nameParts[0]);const r=this._bindNameToScope(this._currentScope,a);!r||4!==this._currentScope.type&&5!==this._currentScope.type||e.d.alias&&1===e.d.module.d.nameParts.length&&e.d.module.d.nameParts[0].d.value===e.d.alias.d.value||(this._fileInfo.isStubFile||this._fileInfo.isInPyTypedPackage)&&this._potentialHiddenSymbols.set(n,r);const s=y.getImportInfo(e.d.module);(0,o.assert)(void 0!==s),r&&this._createAliasDeclarationForMultipartImportName(e,e.d.alias,s,r),this._createFlowAssignment(e.d.alias?e.d.alias:e.d.module.d.nameParts[0]),1===e.d.module.d.nameParts.length&&("typing"===t||"typing_extensions"===t?this._typingImportAliases.push(e.d.alias?.d.value??t):"sys"===t?this._sysImportAliases.push(e.d.alias?.d.value??t):"dataclasses"===t&&this._dataclassesImportAliases.push(e.d.alias?.d.value??t))}return!0}visitImportFrom(e){const t=["Final","ClassVar","Annotated"],n=["InitVar"],a=y.getImportInfo(e.d.module);y.setFlowNode(e,this._currentFlowNode);let r=u.Uri.empty();a&&a.isImportFound&&!a.isNativeLib&&(r=a.resolvedUris[a.resolvedUris.length-1]);const s=(0,p.stripFileExtension)(this._fileInfo.fileUri.fileName),i="__init__"===s&&1===e.d.module.d.leadingDots&&1===e.d.module.d.nameParts.length;let o=!1,l=!1;if(1===e.d.module.d.nameParts.length){const t=e.d.module.d.nameParts[0].d.value;"typing"!==t&&"typing_extensions"!==t||(o=!0),"dataclasses"===t&&(l=!0)}if(e.d.isWildcardImport){if((f.getEnclosingClass(e)||f.getEnclosingFunction(e))&&this._addSyntaxError(m.LocMessage.wildcardInFunction(),e),a){const s=[];this._currentScopeCodeFlowExpressions?.add(g.wildcardImportReferenceKey);const p=this._fileInfo.importLookup(r);if(p){const t=this._getWildcardImportNames(p);i&&(t.some((t=>t===e.d.module.d.nameParts[0].d.value))||this._addImplicitFromImport(e,a)),t.forEach((t=>{const n=this._bindNameValueToScope(this._currentScope,t);if(n){if(p.symbolTable.get(t)){const a={type:8,node:e,uri:r,loadSymbolsFromPath:!0,range:(0,d.getEmptyRange)(),usesLocalName:!1,symbolName:t,moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite};n.addDeclaration(a),s.push(t)}else if(a&&a.filteredImplicitImports){const i=a.filteredImplicitImports.get(t);if(i){const a={type:8,node:e,uri:i.uri,loadSymbolsFromPath:!0,range:(0,d.getEmptyRange)(),usesLocalName:!1,moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite},o={type:8,node:e,uri:r,loadSymbolsFromPath:!0,usesLocalName:!1,symbolName:t,submoduleFallback:a,range:(0,d.getEmptyRange)(),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite};n.addDeclaration(o),s.push(t)}}o&&n.setTypingSymbolAlias(t)}}))}this._createFlowWildcardImport(e,s),o&&t.forEach((e=>{this._typingSymbolAliases.set(e,e)})),l&&n.forEach((e=>{this._dataclassesSymbolAliases.set(e,e)}))}}else i&&this._addImplicitFromImport(e,a),e.d.imports.forEach((i=>{const p=i.d.name.d.value,u=i.d.alias||i.d.name;y.setFlowNode(i,this._currentFlowNode);const m=this._bindNameToScope(this._currentScope,u);if(m){let y,g;e.d.module.d.nameParts.length>0&&(4!==this._currentScope.type&&5!==this._currentScope.type||i.d.alias&&i.d.alias.d.value===i.d.name.d.value||(this._fileInfo.isStubFile||this._fileInfo.isInPyTypedPackage)&&this._potentialHiddenSymbols.set(u.d.value,m)),a&&a.filteredImplicitImports&&(y=a.filteredImplicitImports.get(p));let h=!0;y&&(g={type:8,node:i,uri:y.uri,loadSymbolsFromPath:!0,range:(0,d.getEmptyRange)(),usesLocalName:!1,moduleName:this._formatModuleName(e.d.module),isInExceptSuite:this._isInExceptSuite},"__init__"===s&&(1===e.d.module.d.leadingDots&&0===e.d.module.d.nameParts.length||r.equals(this._fileInfo.fileUri))&&(h=!1));const f={type:8,node:i,uri:r,loadSymbolsFromPath:h,usesLocalName:!!i.d.alias,symbolName:p,submoduleFallback:g,range:(0,c.convertTextRangeToRange)(u,this._fileInfo.lines),moduleName:this._formatModuleName(e.d.module),isInExceptSuite:this._isInExceptSuite,isNativeLib:a?.isNativeLib};m.addDeclaration(f),this._createFlowAssignment(i.d.alias||i.d.name),o&&t.some((e=>e===i.d.name.d.value))&&(this._typingSymbolAliases.set(u.d.value,i.d.name.d.value),o&&m.setTypingSymbolAlias(u.d.value)),l&&n.some((e=>e===i.d.name.d.value))&&this._dataclassesSymbolAliases.set(u.d.value,i.d.name.d.value)}}));return!0}visitWith(e){e.d.withItems.forEach((e=>{this.walk(e.d.expr),e.d.target&&(this._bindPossibleTupleNamedTarget(e.d.target),this._addInferredTypeAssignmentForVariable(e.d.target,e),this._createAssignmentTargetFlowNodes(e.d.target,!0,!1))}));const t=this._createContextManagerLabel(e.d.withItems.map((e=>e.d.expr)),!!e.d.isAsync,!1);this._addAntecedent(t,this._currentFlowNode);const n=this._createContextManagerLabel(e.d.withItems.map((e=>e.d.expr)),!!e.d.isAsync,!0);this._currentExceptTargets.forEach((e=>{this._addAntecedent(e,n)}));const a=this._currentFlowNode,r=this._createBranchLabel(a);return this._addAntecedent(r,t),r.affectedExpressions=this._trackCodeFlowExpressions((()=>{if(this._useExceptTargets([t,n],(()=>{this.walk(e.d.suite)})),this._addAntecedent(r,this._currentFlowNode),this._currentFlowNode=r,this._isCodeUnreachable()||this._addExceptTargets(this._currentFlowNode),e.d.asyncToken&&!this._fileInfo.ipythonMode){const t=f.getEnclosingFunction(e);t&&t.d.isAsync||this._addSyntaxError(m.LocMessage.asyncNotInAsyncFunction(),e.d.asyncToken)}})),!1}visitTernary(e){const t=this._currentFlowNode,n=this._createBranchLabel(),a=this._createBranchLabel(),r=this._createBranchLabel(t);return r.affectedExpressions=this._trackCodeFlowExpressions((()=>{this._bindConditional(e.d.testExpr,n,a),this._currentFlowNode=this._finishFlowLabel(n),this.walk(e.d.ifExpr),this._addAntecedent(r,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(a),this.walk(e.d.elseExpr),this._addAntecedent(r,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(r)})),!1}visitUnaryOperation(e){return 38===e.d.operator&&this._currentFalseTarget&&this._currentTrueTarget?this._bindConditional(e.d.expr,this._currentFalseTarget,this._currentTrueTarget):this._disableTrueFalseTargets((()=>{this.walk(e.d.expr)})),!1}visitBinaryOperation(e){if(36===e.d.operator||37===e.d.operator){let t,n=this._currentTrueTarget,a=this._currentFalseTarget;n&&a||(t=this._createBranchLabel(),n=a=t);const r=this._createBranchLabel();36===e.d.operator?this._bindConditional(e.d.leftExpr,r,a):this._bindConditional(e.d.leftExpr,n,r),this._currentFlowNode=this._finishFlowLabel(r),this._bindConditional(e.d.rightExpr,n,a),t&&(this._currentFlowNode=this._finishFlowLabel(t))}else this._disableTrueFalseTargets((()=>{this.walk(e.d.leftExpr),this.walk(e.d.rightExpr)}));return!1}visitComprehension(e){const t=f.getEnclosingFunction(e);return e.d.forIfNodes.length>0&&12===e.d.forIfNodes[0].nodeType&&this.walk(e.d.forIfNodes[0].d.iterableExpr),this._createNewScope(1,this._getNonClassParentScope(),void 0,(()=>{y.setScope(e,this._currentScope);const n=this._createBranchLabel();for(let n=0;n<e.d.forIfNodes.length;n++){const a=e.d.forIfNodes[n],r=new Map;12===a.nodeType&&(this._bindPossibleTupleNamedTarget(a.d.targetExpr,r),this._addInferredTypeAssignmentForVariable(a.d.targetExpr,a),a.d.asyncToken&&!this._fileInfo.ipythonMode&&(t&&t.d.isAsync||34!==e.parent?.nodeType&&45!==e.parent?.nodeType&&18!==e.parent?.nodeType||this._addSyntaxError(m.LocMessage.asyncNotInAsyncFunction(),a.d.asyncToken)))}for(let t=0;t<e.d.forIfNodes.length;t++){const a=e.d.forIfNodes[t];if(12===a.nodeType)0!==t&&this.walk(a.d.iterableExpr),this._createAssignmentTargetFlowNodes(a.d.targetExpr,!0,!1);else{const e=this._createBranchLabel();this._bindConditional(a.d.testExpr,e,n),this._currentFlowNode=this._finishFlowLabel(e)}}this.walk(e.d.expr),this._addAntecedent(n,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(n)})),!1}visitMatch(e){this.walk(e.d.expr);const t=[];let n=this._isNarrowingExpression(e.d.expr,t);52===e.d.expr.nodeType&&e.d.expr.d.items.forEach((e=>{this._isNarrowingExpression(e,t)&&(n=!0)})),n&&t.forEach((e=>{const t=(0,g.createKeyForReference)(e);this._currentScopeCodeFlowExpressions.add(t)}));const a=this._createBranchLabel();let r=!1;return e.d.cases.forEach((t=>{const n=this._createBranchLabel(),s=this._createBranchLabel(),i=this._createBranchLabel();this._addAntecedent(s,this._currentFlowNode),t.d.isIrrefutable?t.d.guardExpr||(r=!0):this._addAntecedent(n,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(s),this._currentMatchSubjExpr=e.d.expr,this.walk(t.d.pattern),this._currentMatchSubjExpr&&(this._createFlowNarrowForPattern(e.d.expr,t),this._currentMatchSubjExpr=void 0),t.d.guardExpr?this._bindConditional(t.d.guardExpr,i,n):this._addAntecedent(i,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(i),this.walk(t.d.suite),this._addAntecedent(a,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(n)})),n&&this._createFlowNarrowForPattern(e.d.expr,e),r||this._createFlowExhaustedMatch(e),this._addAntecedent(a,this._currentFlowNode),this._currentFlowNode=this._finishFlowLabel(a),!1}visitPatternAs(e){const t=this._createBranchLabel();if(e.d.orPatterns.forEach((e=>{this.walk(e),this._addAntecedent(t,this._currentFlowNode)})),this._currentFlowNode=this._finishFlowLabel(t),e.d.target){this.walk(e.d.target);const t=this._bindNameToScope(this._currentScope,e.d.target);if(this._createAssignmentTargetFlowNodes(e.d.target,!1,!1),t){const n={type:1,node:e.d.target,isConstant:(0,C.isConstantName)(e.d.target.d.value),inferredTypeSource:e,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e.d.target,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite,isExplicitBinding:void 0!==this._currentScope.getBindingType(e.d.target.d.value)};t.addDeclaration(n)}}return!1}visitPatternCapture(e){return e.d.isWildcard||this._addPatternCaptureTarget(e.d.target),!0}visitPatternMappingExpandEntry(e){return"_"!==e.d.target.d.value&&this._addPatternCaptureTarget(e.d.target),!0}_addTypingImportAliasesFromBuiltinsScope(){this._fileInfo.builtinsScope&&this._fileInfo.builtinsScope.symbolTable.forEach(((e,t)=>{const n=e.getTypingSymbolAlias();n&&!e.isExternallyHidden()&&this._typingSymbolAliases.set(t,n)}))}_formatModuleName(e){return".".repeat(e.d.leadingDots)+e.d.nameParts.map((e=>e.d.value)).join(".")}_getNonClassParentScope(){let e=this._currentScope;for(;3===e.type;)e=e.parent;return e}_addSlotsToCurrentScope(e){(0,o.assert)(3===this._currentScope.type);let t=!1;for(const n of e){const e=n.d.strings[0].d.value;if("__dict__"===e){t=!0;continue}let a=this._currentScope.lookUpSymbol(e);if(!a){a=this._currentScope.addSymbol(e,5);const t="none"!==this._fileInfo.diagnosticRuleSet.reportPrivateUsage;(0,C.isPrivateOrProtectedName)(e)&&t&&a.setIsPrivateMember()}const r={type:1,node:n,isConstant:(0,C.isConstantName)(e),isDefinedBySlots:!0,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(n,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite,isExplicitBinding:void 0!==this._currentScope.getBindingType(e)};a.addDeclaration(r)}t||this._currentScope.setSlotsNames(e.map((e=>e.d.strings[0].d.value)))}_isInComprehension(e,t=!1){let n,a,r=e;for(;r;){if(11===r.nodeType){if(t&&r.d.forIfNodes.length>0){const e=r.d.forIfNodes[0];if(n===e&&12===e.nodeType&&a===e.d.iterableExpr)return!1}return!0}a=n,n=r,r=r.parent}return!1}_addPatternCaptureTarget(e){const t=this._bindNameToScope(this._currentScope,e);if(this._createAssignmentTargetFlowNodes(e,!1,!1),this._currentMatchSubjExpr&&(f.isMatchingExpression(e,this._currentMatchSubjExpr)||f.isPartialMatchingExpression(e,this._currentMatchSubjExpr))&&(this._currentMatchSubjExpr=void 0),t){const n={type:1,node:e,isConstant:(0,C.isConstantName)(e.d.value),inferredTypeSource:e.parent,uri:this._fileInfo.fileUri,range:(0,c.convertTextRangeToRange)(e,this._fileInfo.lines),moduleName:this._fileInfo.moduleName,isInExceptSuite:this._isInExceptSuite,isExplicitBinding:void 0!==this._currentScope.getBindingType(e.d.value)};t.addDeclaration(n)}}_useExceptTargets(e,t){const n=this._currentExceptTargets;this._currentExceptTargets=e,t(),this._currentExceptTargets=n}_getDunderAllNamesFromImport(e){const t=this._currentScope.lookUpSymbol(e);if(!t)return;const n=t.getDeclarations().find((e=>8===e.type)),a=n?.uri&&!n.uri.isEmpty()&&n.loadSymbolsFromPath?n.uri:n?.submoduleFallback?.uri&&!n.submoduleFallback.uri.isEmpty()&&n.submoduleFallback.loadSymbolsFromPath?n.submoduleFallback.uri:void 0;if(!a)return;let r=this._fileInfo.importLookup(a);return r?.dunderAllNames?r.dunderAllNames:n?.submoduleFallback?.uri&&!n.submoduleFallback.uri.isEmpty()?(r=this._fileInfo.importLookup(n.submoduleFallback.uri),r?.dunderAllNames):void 0}_addImplicitFromImport(e,t){const n=e.d.module.d.nameParts[0].d.value,a=this._bindNameValueToScope(this._currentScope,n);a&&this._createAliasDeclarationForMultipartImportName(e,void 0,t,a),this._createFlowAssignment(e.d.module.d.nameParts[0])}_createAliasDeclarationForMultipartImportName(e,t,n,a){const r=e.d.module.d.nameParts[0].d.value;let s;y.setFlowNode(e,this._currentFlowNode),n&&n.isImportFound&&!n.isNativeLib&&n.resolvedUris.length>0&&(s=n.resolvedUris[0]);const i=a.getDeclarations().find((e=>8===e.type&&e.firstNamePart===r&&(!s||s.equals(e.uri))));let o,l;l=n&&n.isImportFound&&!n.isNativeLib&&n.resolvedUris.length>0?n.resolvedUris[n.resolvedUris.length-1]:h.UnresolvedModuleMarker;const p=n&&n.isImportFound&&!n.isNativeLib&&n.resolvedUris.length>0;o=i||(p?{type:8,node:e,uri:l,loadSymbolsFromPath:!1,range:(0,d.getEmptyRange)(),usesLocalName:!!t,moduleName:t?this._formatModuleName(e.d.module):".".repeat(e.d.module.d.leadingDots)+r,firstNamePart:r,isInExceptSuite:this._isInExceptSuite}:{type:8,node:e,uri:l,loadSymbolsFromPath:!0,range:(0,d.getEmptyRange)(),usesLocalName:!!t,moduleName:n?.importName??"",firstNamePart:t?this._formatModuleName(e.d.module):".".repeat(e.d.module.d.leadingDots)+r,isUnresolved:!0,isInExceptSuite:this._isInExceptSuite});const c=y.getImportInfo(e.d.module.d.nameParts[0]);if(c&&c.resolvedUris.length&&(o.uri=c.resolvedUris[0],o.loadSymbolsFromPath=!0,this._addImplicitImportsToLoaderActions(c,o)),t||1===e.d.module.d.nameParts.length)o.uri=l,o.loadSymbolsFromPath=!0,o.isUnresolved=!1,n&&this._addImplicitImportsToLoaderActions(n,o);else{let t=o;for(let a=1;a<e.d.module.d.nameParts.length;a++){const r=e.d.module.d.nameParts[a].d.value;let s=t.implicitImports?t.implicitImports.get(r):void 0;if(s||(s={uri:n&&a<n.resolvedUris.length?n.resolvedUris[a]:h.UnresolvedModuleMarker,loadSymbolsFromPath:!1,implicitImports:new Map,isUnresolved:!p},t.implicitImports||(t.implicitImports=new Map),t.implicitImports.set(r,s)),a===e.d.module.d.nameParts.length-1)n&&a<n.resolvedUris.length&&(s.uri=n.resolvedUris[a],s.loadSymbolsFromPath=!0,this._addImplicitImportsToLoaderActions(n,s));else{const t=y.getImportInfo(e.d.module.d.nameParts[a]);t&&t.resolvedUris.length&&(s.uri=t.resolvedUris[a],s.loadSymbolsFromPath=!0,this._addImplicitImportsToLoaderActions(t,s))}t=s}}i||a.addDeclaration(o)}_getWildcardImportNames(e){const t=[];if(e.dunderAllNames){if(!e.usesUnsupportedDunderAllForm)return e.dunderAllNames;(0,i.appendArray)(t,e.dunderAllNames)}return e.symbolTable.forEach(((e,n)=>{e.isExternallyHidden()||n.startsWith("_")||t.push(n)})),t}_walkStatementsAndReportUnreachable(e){let t=!1;for(const n of e)y.setFlowNode(n,this._currentFlowNode),t||(t=this._isCodeUnreachable()),t?(this._targetFunctionDeclaration&&!this._targetFunctionDeclaration.isGenerator&&(new k).checkContainsYield(n)&&(this._targetFunctionDeclaration.isGenerator=!0),this._moduleSymbolOnly||new S(this._currentScope).walk(n)):this.walk(n);return!1}_createStartFlowNode(){return{flags:g.FlowFlags.Start,id:this._getUniqueFlowNodeId()}}_createBranchLabel(e){return{flags:g.FlowFlags.BranchLabel,id:this._getUniqueFlowNodeId(),antecedents:[],preBranchAntecedent:e,affectedExpressions:void 0}}_createFlowNarrowForPattern(e,t){const n={flags:g.FlowFlags.NarrowForPattern,id:this._getUniqueFlowNodeId(),subjectExpression:e,statement:t,antecedent:this._currentFlowNode};this._currentFlowNode=n}_createContextManagerLabel(e,t,n){return{flags:g.FlowFlags.PostContextManager|g.FlowFlags.BranchLabel,id:this._getUniqueFlowNodeId(),antecedents:[],expressions:e,affectedExpressions:void 0,isAsync:t,blockIfSwallowsExceptions:n}}_createLoopLabel(){return{flags:g.FlowFlags.LoopLabel,id:this._getUniqueFlowNodeId(),antecedents:[],affectedExpressions:void 0}}_finishFlowLabel(e){return 0===e.antecedents.length?I._unreachableFlowNode:1===e.antecedents.length&&e.flags===g.FlowFlags.BranchLabel?e.antecedents[0]:(this._codeFlowComplexity+=e.antecedents.length-1,e)}_bindNeverCondition(e,t,n){const a=[];if(55===e.nodeType&&38===e.d.operator)this._bindNeverCondition(e.d.expr,t,!n);else if(7!==e.nodeType||36!==e.d.operator&&37!==e.d.operato