How to disable instant linting from [Python (parser)] in Visual Studio Code - python

The Python parser in Visual Studio Code 1.25.1 lints any error directly while typing.
How can I turn that off?
I would like to disable the live-parser-linting.
I do not want to completely disable linting from pep8 or pylint too.
Maybe the issue got adressed here too:
https://github.com/Microsoft/vscode-python/issues/2270
I found a setting for "List of surpressed diagnostic message" but I do not know, what to insert here (or if this is even the right place) nor do I find any documentation for the python.analysis.disabled settings on the web.
Help appreciated.
"python.analysis.disabled": [
"",
],
Is there any workaround?

[I am assuming you have the latest version of the Python extension for VS code installed as this won't have anything directly to do with VS Code 1.25.1]
If you are using the new language server from the Python extension then errors as you type do not turn off at the moment (you referenced the specific issue suggesting having a setting to turn that off).
If you're not using the new language server than the extension only runs linters on save, which would mean you have automatic saving as you type turned on and that's triggering the constant linting of your code. Tweak your settings to not automatically save and that will stop constant linting (and you can specify settings in VS Code for specific languages if you only want to change this for Python).

Related

How to show pylint message codes/ids in PyCharm Problems view and get quick fix?

I get some pylint warnings in the Problems view of PyCharm Community Edition:
a) How can I tell PyCharm to include the corresponding message code/id in the Problems View, so that I am able to manually suppress the warning without manually searching the corresponding message code/id?
b) How can I teach PyCharm to provide a quick fix for suppressing the warning with a line comment?
For example
"PyLint: Too many local variables"
=>
# pylint: disable=too-many-locals
Related:
List of pylint human readable message ids?
How to show pylint message codes in VScode?
How do I automatically fix lint issues reported by pylint?
Visual Studio Code quick-fix & python
Edit
Also see related issue ticket of PyCharm Pylint Plugin:
https://github.com/leinardi/pylint-pycharm/issues/92
While the standard Problems view does not show the message ids, the extra Pylint view does (after running a scan):
Unfortunately, quick fixes are not provided by that view.
The answer to
b) How can I teach PyCharm to provide a quick fix for suppressing the warning with a line comment?
Is sadly: Go back and wait at https://github.com/leinardi/pylint-pycharm/issues/92 (or someone starts implementing it 😅. and, btw, upstream actually accepts that OR someone goes ahead and creates a yet-another new plugin)
There do not seem be alternative PyLint Plugins for PyCharm. Unfortunately, for VsCodium (Visual Studio Code without tracking) the situation seems to be similar.
Well, there is the extension ms-python and it supports many linting tools for Python (Strg+Shift+P: Python: Select linter).
For PyLint it shows the message ids in the VsCodium PROBLEMS view.
If the language server would be set to Pylance, Quick fixes for PyLint would be available, too.
Unfortunately, the language server Pylance does not support VSCodium:
https://github.com/microsoft/pylance-release/issues/791
Related:
Visual Studio Code quick-fix & python

How to get Intellisense on Visual Studio (VS) Code to work on Python

I have Visual Studio Code on my laptop and setting it up for the first time and am having trouble making Intellisense work. I downloaded the python extension. When I tried to type a syntax, I don't see a drop down of the available methods.
What I did so far was press F1> type 'open settings'> and see that the option is turned on. It looks like the setting is on, screenshot below line 18. I'm not sure if there is something I'm missing. Would anyone happen to have an idea of how I can have the auto complete functionality to work?
Intellisense was provided by the Language Server, The default value of it is Default.
Default: Automatically select a language server: Pylance if installed
and available, otherwise fallback to Jedi.
So, it's a little weird of your problem, could you try to install the Pylance and set it as the Language Server? Add this in the settings.json file:
"python.languageServer": "Pylance",
Have you tried Ctrl+Space or hovering some code?
Also do you have "Visual Studio IntelliCode" extension installed?
If neither Ctrl+Space nor hovering work, it is recommended to restart VS Code (https://code.visualstudio.com/docs/editor/intellisense#_troubleshooting)

VS code python attribute suggestion

I have a problem with Intellisense. Even though Python, Pylance and even Visual Studio IntelliCode extensions are installed, VS code is still unable to suggest object attributes.
Could you please advise any settings.json parameters which will trigger python attribute suggestion globally ?
Sometime it's tedious to remember all object attributes without documentation being opened.
You can use ctrl + space for windows for activating intelliSense in VsCode.
However it also depends on processing speed of computer.
Intellisense was provided by the Language Server. The search paths depend on the python interpreter you have selected.
If you modify the PYTHONPATH manually to import the package, you need to add these locations to the Language Server too(settings.json), like this:
"python.autoComplete.extraPaths": [
"C:/Program Files (x86)/Google/google_appengine",
"C:/Program Files (x86)/Google/google_appengine/lib/flask-0.12"]
You can refer to here.
Or, there are some problems of your Language Server, you can have a look at the
OUTPUT panel --> Python Language Server channel. And attach the error message on the question.
Open the Command Palette (Command+Shift+P on macOS and Ctrl+Shift+P on Windows/Linux) and type:
Python: Select Interpreter
then choose Interpreter.

Python auto import extension for VSCode

Is there a Python auto import extension/plugin available for Visual Studio Code?
By auto import I mean, auto import of python modules. Eclipse and Intellij has this feature with Java.
VSCode team recently released Pylance
Features
Docstrings
Signature help, with type information
Parameter suggestions
Code completion
Auto-imports (as well as add and remove import code actions)
As-you-type reporting of code errors and warnings (diagnostics)
Code outline
Code navigation
Code lens (references/implementations)
Type checking mode
Native multi-root workspace support
IntelliCode compatibility
Jupyter Notebooks compatibility
No, but it will soon be a part of vscode-python: https://github.com/Microsoft/vscode-python/pull/636
EDIT: See answer by #Eric, who built such an extension.
EDIT 2: See answer by #Eyal Levin, mentioning such an extension (Pylance).
I have built an automatic import extension that supports Python. It lets you fully customize how the imports get written to the file, modifying import paths, names, sorting relative to other imports. The Python plugin even lets you "group" imports together with extra line breaks.
From https://github.com/microsoft/python-language-server/issues/19#issuecomment-587303061:
For those who wonder how to trigger auto-importing as I did, here are
the steps.
Enable Microsoft Python Language Server by removing the check of
Python: Jedi Enabled in your settings.
Reload the VSCode window.
Hover your mouse over the variable that you want to import, and click Quick
fix...
For the last step, if it shows No quick fixes available or
Checking for quick fixes, you may need to wait for a while until the
extension has finished code analysis. It is also possible to set a
shortcut that triggers a quick fix.
I use this package it works very well
https://marketplace.visualstudio.com/items?itemName=codeavecjonathan.importmagic
You can find it in VSCode extension store. it's name is IMPORTMAGIC. It works fantastic. It will include all modules which you use in your script.
It has code action ctrl + . , which will also import library.
This is supported in the official Microsoft python extension, but for some reason I found it was recently disabled or no longer default. The setting I had to toggle was
"python.analysis.autoImportCompletions": true,
(Updated answer as of January 2023)
These three together did it for me:
"python.analysis.autoImportCompletions": true,
"python.analysis.autoImportUserSymbols": true,
"python.analysis.indexing": true,
If that is slowing down your computer too much because it's indexing too many files, then look into specifying patterns and depths of directories to include in the indexing using "python.analysis.packageIndexDepths".
Note that I am using Pylance (currently the default, as of January 2023).
Check out the VSCode python settings reference for more info on each of those settings.
You might find This Python-Based Module useful if you wish to auto import and auto download missing modules from a script or sub-scripts. Not only for VSCode, but also for any IDE or Editor.

Editing autocomplete settings in Visual Studio 2013 (PTVS)

I am trying to switch from Pycharm to Visual Studio 2013 (PTVS), however I cannot find how to change settings for auto-completion popups. For example, in Pycharm whenever you start writing something, it automatically gives you a list of possible keywords, like in screenshots below.
If I start to write 'co' pycharm lets me choose 'consecutive' which is an already defined boolean. Is there any way to change these settings in visual studio? I have went through the settings menu like 20 times now, and I am completely stuck.
screenshot of pycharm:
http://i61.tinypic.com/20960wn.png
screenshot of visual studio 2013:
http://i62.tinypic.com/2qtilg1.png
I found the answer by myself - PTVS doesn't support this feature, however there is a plugin, which can be downloaded here, which supposedly fixes this issue:
http://visualstudiogallery.msdn.microsoft.com/644b4359-5eeb-4ba5-9374-78a8507761f0
However, after further inspection, it is broken and doesnt work half as good as pycharm's autocomplete. Most of the time it popups a message saying 'no suggestions' which becomes seriously annoying getting that msg after every single letter.
Bottomline - it is broken.
This is now supported with PTVS. Per the completions section found on the GitHub wiki.
Completions can be shown at any time by pressing Ctrl+J or Ctrl+Space, or may be triggered automatically by certain commands (such as import), operators (such as a period/full stop), or by typing at any place where completions are likely to be helpful.

Categories