question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intellisense doesn't respect absolute imports (Jedi)

See original GitHub issue

Environment data

  • VS Code version: 1.25.1
  • Extension version (available under the Extensions sidebar): 2018.7.0
  • OS and version: MacOS 10.13.5
  • Python version (& distribution if applicable, e.g. Anaconda): all
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv, virtualenv, conda, or none
  • Relevant/affected Python packages and their versions: any

Actual behavior

Given a local package or module that has the same name as an installed package, for example:

my_project
|   my_package
    |    __init__.py
    |    celery.py

Contents of my_project/my_package/celery.py:

from __future__ import absolute_import # for compatibility with python 2

import celery


celery.Celery('tasks')

Contents of my_project/my_package/__init__.py:

Intellisense treats import celery line as importing local module (the current file) into its self instead of the top level package.

Expected behavior

Intellisense should import the global package (celery in this example), not the local module (my_project.celery)

Steps to reproduce:

  1. create a package or module with the same local name as another package or module in python’s path.
  2. import the package or module

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
brettcannoncommented, Sep 27, 2019

@moi90 best option would be to use the Microsoft language server.

I’m going to re-open this issue to be triaged so we can see if there’s anything we can do or if it’s entirely up to Jedi to fix.

1reaction
ericsnowcurrentlycommented, Aug 14, 2018

FYI, with that last bit of info I was able to reproduce the problem under Python 3.7 on linux. Intellisense is showing completions for the local module rather than the installed package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode Intellisense doesn't resolve imports with absolute paths
I'm maintaining an electron app using Typescript. I'm trying to implement absolute paths for imports in my project.
Read more >
Modern IDEs are magic. Why are so many coders still using ...
Setting it up involves picking your board from a menu, and there's a nice dialog for importing libraries too. The whole compile-and-deploy thing ......
Read more >
Absolute imports and intellisense with create-react-app (no ...
By default create-react-app does not allow absolute imports that means you always need to check the location of the file.
Read more >
Valloric/YouCompleteMe - Gitter
I only get first/second level autocompletion like tf.data.Dataset. Also GetDoc doesn't work. There was some problem with tensorflow lazy imports which jedi ......
Read more >
IPython Documentation - Read the Docs
Requiring widgets/js/widget doesn't import the WidgetManager class, instead it imports a dictionary that exposes the classes within that module:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found