Flake8 Errors not shown in VS Code - visual-studio-code

I have been using flake8 for linting but somehow it stopped showing me errors in the code in any of my workspaces (the squiggly underlines in the editor).
flake8 is installed in my conda environment.
Here is my settings.json:
{
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--max-line-length=80",
"--docstring-convention=google",
"--verbose"
]
}
When I run flake8 from the console, it does show me the errors.
I am using VS Code version 1.72.2 on Windows, and I installed flake8 version 5.0.4. Any idea what could be wrong with it?

Open Command Palette and type in Linter. Select the option Python: Select Linter and it opens up all the available linters.
In the drop down, select Flake8 and if required install it.
That should work now!

Related

Adding pep8-naming to VSCode

I am trying to get PEP8-naming working on my VSCode (Version: 1.72.2 (Universal)) without luck.
I have flake8, isort and mypy enabled in my code and this all works as expected. I have installed pep8-naming (conda install -c conda-forge pep8-naming) and it shows in my flake8 version info:
flake8 --version
4.0.1 (mccabe: 0.7.0, naming: 0.13.2, pycodestyle: 2.8.0, pyflakes: 2.4.0) CPython 3.8.13 on Darwin
However, I am not seeing the errors for naming conventions showing in my VSCode editor.
I have the following set in my settings.json file
{
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"python.linting.pycodestyleEnabled": true,
"python.linting.pycodestyleArgs": ["--max-line-length=120"]
}
What am I missing so as to be able to see (for instance) that variables are named in Camel case rather than lower case with underscores?
I have tried this without any luck.

arduino settings for Visual Studio Code

This is driving me crazy! I see solutions all over the web and I still can't get this to work. Here is my settings.json file:
{
"C_Cpp.updateChannel": "Insiders",
"workbench.editorAssociations": {
"*.ipynb": "jupyter.notebook.ipynb"
},
"arduino.additionalUrls": "",
"arduino.path": "C:\\Program Files (x86)\\Arduino",
"arduino.commandPath": "arduino.exe",
"files.autoSave": "onWindowChange",
}
I am running on Windows 10 and Arduino is installed in:
C:\Program Files (x86)\Arduino
I have four executables there:
arduino.exe
arduino_debug.exe (I downloaded this for good measure!)
arduino-cli.exe
uninstall.exe
When I click "Select Programmer" in VSC, I get"
"Cannot find Arduino IDE. Please specify the "arduino.path" in the User Settings. Requires a restart after change.
I have restarted the IDE and still get the same problem.
I have rebooted the laptop.
I have tried uninstalling both VSC and Arduino.
The Arduino IDE works fine stand-alone.
Wow! I finally stumbled on these installation instructions:
https://nortronics.com.au/setting-up-visual-studio-code-for-arduino-programming/
This is what my .vscode/settings.json (you can find it in the left pane under .vscode in your project folder) now looks like:
{
"arduino.path": "C:\\Program Files (x86)\\Arduino",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.intelliSenseEngine": "Tag Parser",
"arduino.enableUSBDetection": true,
}

How to show warnings in VSCode editor for a .cpp file?

Is it possible to tweak VSC somehow to see GCC warnings in the text editor?
Refer to the screenshot below - it shows only errors in the console.
I'm using 1.43.2 version with C/C++ extension 0.26.3 installed.
Tried adding -Wall compiler flag to "args" in tasks.json but it didn't help.
Below are my settings:
{
"editor.fontSize": 13,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 100,
"files.insertFinalNewline": true,
}
The warning and errors are shown in Problem Panel.
You can see Problems 4 on it.
You might need to install Visual Studio IntelliCode or C++ Intellisense to help you identify mistakes before compilation.

vscode giving me invalid symbol error everywhere

I'm going crazy, VSCode is giving me this error EVERYWHERE (including js files and .gitignore .dockerignore files, even for simple lines such as node_modules in .gitignore)
I need some ideas
my config file
{
"workbench.iconTheme": "vscode-icons",
"workbench.colorTheme": "One Monokai",
"vsicons.dontShowNewVersionMessage": true,
"editor.formatOnSave": true,
"editor.tabSize": 4,
"prettier.tabWidth": 4,
"editor.tabCompletion": "on",
"prettier.singleQuote": true,
"prettier.printWidth": 80,
"window.zoomLevel": 0,
"editor.acceptSuggestionOnEnter": "off",
"editor.minimap.enabled": false
}
My extensions are pretty standard
prettier
react snippets
docker
sass
eslint
some random themes
editor config
graphql
auto-import
This issue randomly appeared for me today as well.
This process worked to solve it on my system, although I don't know what actually caused the issue.
restart vscode
check for a vscode update
(optional) Restart system
If 1-3 don't work you can try
In the command palette run Extensions: Disable All Installed Extension
These steps worked for me when this issue started popping up after installing macOS 10.15 Catalina.
Reinstall node.js using nvm, e.g. nvm install 10 && nvm use 10 to install and use the latest node.js 10.x version (pick your preferred version)
Reinstall eslint via npm i -g eslint
Restart VS Code

Getting ModuleNotFoundError in python, package exists in virtual environment though

I am new to python and writing my first python file using Visual Studio Code. Till yesterday the code was working fine. But today it is starting to give ModuleNotFoundError. I double-checked the package and the package is there under lib folder of the virtual environment. Moreover, IntelliSense is also working fine, whenever I write import it shows the requests module in the available list. I am facing problems with IntelliSense also, as sometimes it stops working for no reason.
The major change that I did before executing the code is the integration of GitLab with my project.
Python Version: 3.6.2
Operating System: Windows
Git Version: 2.23.0
Pylint Version: 2.3.1
pip Version: 19.2.2
Requests Version: 2.22.0
Pytest Version: 5.1.1
Enabled Extensions:
Npm
Npm Intellisense
Ayu
Code Runner
AYU
Markdownlint
Predawn Themekit
Python by Microsoft
Can anyone have gone through with the same problem? Please help me to resolve this issue.
Attachments
Issue resolved I was running it using Ctrl+Alt+N (code-runner shortcut to run a project)which was creating this issue. But running the file in terminal using Run Python File in Terminal (option in the context menu when we do right-click in source .py file) giving me the expected result without any error.
Then I googled for how to alter this behavior so that I can get the same results by using Ctrl+Alt+N as well.
I found that; I need to add the following script under user's settings.json.
"code-runner.executorMap": {
"python": "h:\\practice\\virtualenv\\Scripts\\activate.bat && python -u"
}
Here is my complete user's settings.json
{
"workbench.colorTheme": "Predawn",
"workbench.iconTheme": "ayu",
"window.zoomLevel": 0,
"code-runner.executorMap": {
"python": "h:\\practice\\virtualenv\\Scripts\\activate.bat && python -u"
}
}