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 gets in the way when writing import module as ... statements

See original GitHub issue

This is more of a quality of life enchancement request. I believe the current Intellisense suggestions during python import statements could be improved.

Basically, my problem is during import ... as ... statements and similar. Taking specifically:

import numpy as np

The suggestions are understandably not helpful since Intellisense can’t predict I will call it np or whatever I want to call it. However, it gives me suggestions such as NotImplementedError, presumeably because it contains an N and p. This happens with other packages too (i.e import pandas as pd).

The problem is that right after I type np, I want to click Return, which instead of going to the next line accepts the IntelliSense suggestion. I have to do something like click on the right arrow or first do a space to get out of IntelliSense if I want to go to the next line.

Unfortunately, suggestions to prevent that seem very broad. On StackOverflow the answer was to turn of snippet suggestions, but I think that was just for a specific question and wouldn’t solve everything, since their import tensorflow as tf was getting IntelliSensed as a try/except block.

So I was wondering if it’s possible for the autocomplete to be modified to not make those suggestions anymore. It seems unlikely that IntelliSense will be able to predict what a module reference will be called by a particular user.

Environment data

  • VS Code version: 1.24.0
  • Extension version (available under the Extensions sidebar): 2108.5.0
  • OS and version: Ubuntu 14.04 and 16.10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions: XXX

Actual behavior

import numpy as np

just after typing it suggests replacing np with NotImplementedError (this is just a specific example), not letting me Enter to the next line.

Expected behavior

On the import module as ... statement, I think IntelliSense shouldn’t try to predict what the module will be renamed as.

Steps to reproduce:

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

XXX

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
CoreyColecommented, Sep 11, 2018

@jkyeung hitting escape is how I get around this. It’s become a habit to hit escape before pressing enter if there are completions suggested. I also hit escape if I want to see the code the suggestion is blocking.

Btw I’ve rebound escape to caps lock so this is even easier 😄

Also, you can disable Enter as the key bind to select a suggestion: https://stackoverflow.com/questions/48099898/vs-code-how-to-make-intellisense-activate-with-ctrlspace-but-still-allow-quick

0reactions
luabudcommented, Sep 11, 2019

Since VS Code provides a setting for this, we’re closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keep imported modules from showing up in code completion?
When I import testmodule , I don't want os to show up every time I type testmodule. ; I only want the functions/classes...
Read more >
Get Started Tutorial for Python in Visual Studio Code
This tutorial introduces you to VS Code as a Python environment, primarily how to edit, run, and debug code through the following tasks:...
Read more >
Auto import | WebStorm Documentation - JetBrains
In JavaScript and TypeScript files, WebStorm automatically adds import statements for modules, classes, components, and any other symbols ...
Read more >
Fix Python Relative Imports and Auto-completion in VSCode
In this video, you will learn how to properly handle Python relative imports without extending the sys. path. Additionally, you will learn ...
Read more >
Edit Python code - Visual Studio (Windows) - Microsoft Learn
Features include IntelliSense syntax highlighting, autocompletion, ... The import and from ... import statements display a list of modules ...
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