Skip to content

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

Description

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%

Activity

  1. ghost added
    triage-neededNeeds assignment to the proper sub-team
    on Jan 30, 2019
  2. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 31, 2019
  3. removed their assignment
    on Jan 31, 2019
  4. d3r3kk commented on Jan 31, 2019

    @d3r3kk

    Verified, here's another gif that might help figure out the issue:

    4226_intellisense_exception_on_import_trailing_comma

    This is using Microsoft Python Language Server version 0.1.78.0, Miniconda3 on Windows with Python 3.7.2

  5. CamberLoid commented on Feb 28, 2019

    @CamberLoid
    Author

    Upstream fixed.

  6. locked as resolved and limited conversation to collaborators on Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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