Skip to content

Python language server didn't work properly when editing '__init__.py' #4226

Closed
@CamberLoid

Description

@CamberLoid

Issue Type: Bug

Python language server raised an exception and caused problems when handling this import (modules),(),
After double-checking on my Windows, I am sure this is because of the extra comma in the import expression in __init__.py ,

Using Anaconda distribution. Have not tried to reproduce on other OS.

Environment data

  • Version: 1.30.2 (user setup)
  • Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
  • Date: 2019-01-07T22:54:13.295Z
  • Electron: 2.0.12
  • Chrome: 61.0.3163.100
  • Node.js: 8.9.3
  • V8: 6.1.534.41
  • OS: Windows_NT x64 10.0.18323

Actual behaviour

Cannot access origin libraries by Ctrl+(Modules), and the exceptions below.
It acts like this

issue

Expected behaviour

Access origin libraries by Ctrl+(Modules)
and no Exceptions

Logs

[Error - 1:18:14 AM] System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.SZArrayHelper.get_Item[T](Int32 index)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.ImportModule(ImportStatement& node, IModule& module, DottedName& moduleImportExpression, NameExpression& asNameExpression)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(ImportStatement node)
   at Microsoft.PythonTools.Parsing.Ast.ImportStatement.Walk(PythonWalker walker)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.Walk(SuiteStatement node)
   at Microsoft.PythonTools.Parsing.Ast.SuiteStatement.Walk(PythonWalker walker)
   at Microsoft.PythonTools.Parsing.Ast.PythonAst.Walk(PythonWalker walker)
   at Microsoft.PythonTools.Analysis.AnalysisUnit.AnalyzeWorker(DDG ddg, CancellationToken cancel)
   at Microsoft.PythonTools.Analysis.Analyzer.DDG.Analyze(Deque`1 queue, CancellationToken cancel, Action`1 reportQueueSize, Int32 reportQueueInterval)
   at Microsoft.PythonTools.Analysis.PythonAnalyzer.AnalyzeQueuedEntries(CancellationToken cancel)
   at Microsoft.PythonTools.Intellisense.AnalysisQueue.GroupAnalysis.Analyze(CancellationToken cancel)
   at Microsoft.PythonTools.Intellisense.AnalysisQueue.HandleAnalyzable(IAnalyzable item, AnalysisPriority priority, CancellationToken cancellationToken)
   at Microsoft.PythonTools.Intellisense.AnalysisQueue.ConsumerLoop()

Extension version: 2019.1.0
VS Code version: Code 1.30.2 (61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8, 2019-01-07T22:54:13.295Z)
OS version: Windows_NT x64 10.0.18323

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2208)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.87GB (9.36GB free)
Process Argv
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions