DEV Community

Cover image for Setting up Python workspace in Visual Studio Code (vscode)

Setting up Python workspace in Visual Studio Code (vscode)

Idris Rampurawala on March 10, 2020

Whenever as a programmer we start a new project (in any language), we are required to set up an environment for our project to run. The environment...
Collapse
 
sobolevn profile image
Nikita Sobolev

There's also one more thing that you can add to this amazing setup: linting!

VSCode can automatically find bugs, refactoring opportunities, and things to improve inside your code. I recommend to use flake8 + wemake-python-styleguide. Here's how to set things up: code.visualstudio.com/docs/python/...

And don't forget to check out wemake-python-styleguide on its own. It is the strictest Python linter out there:

GitHub logo wemake-services / wemake-python-styleguide

The strictest and most opinionated python linter ever!

wemake-python-styleguide

wemake.services Supporters Build Status codecov Python Version wemake-python-styleguide


Welcome to the strictest and most opinionated Python linter ever.

wemake-python-styleguide logo

wemake-python-styleguide is actually a flake8 plugin with some other plugins as dependencies.

Quickstart

pip install wemake-python-styleguide
Enter fullscreen mode Exit fullscreen mode

You will also need to create a setup.cfg file with the configuration.

Try it online!

We highly recommend to also use:

  • flakeheaven for easy integration into a legacy codebase
  • nitpick for sharing and validating configuration across multiple projects

Running

flake8 your_module.py
Enter fullscreen mode Exit fullscreen mode

This app is still just good old flake8 And it won't change your existing workflow.

invocation results

See "Usage" section in the docs for examples and integrations.

We also support GitHub Actions as first class-citizens Try it out!

Strict is the new cool

Strict linting offers the following benefits to developers and companies:

  1. Ensures consistency - no matter who works on it, the end product will always be the same dependable code
  2. Helps avoid potential bugs - strict rules make…
Collapse
 
idrisrampurawala profile image
Idris Rampurawala

I have already added pylint for code linting. Choosing formatter and linter is I believe a personal choice. This post is just about how to get started and not a discussion around python linters.

On a personal note, thanks for sharing this, I will definitely give it a try for one of my side projects :)

Collapse
 
tarifa10 profile image
tarifa-man • Edited

Hi there good day dear Idris -many thanks for this great article - i am going through it all - since i now want to stick with VSCode (note i am on MX-Linux so i just picked VScodium )

hopefully i can do all the things you did - on vscodium too - this would be great!!

i like your ideas and thoughts that you share here - i will go this pathway - and install all the packages you suggest.

  • great text - keep up your project here. it rocks+
Collapse
 
muhimen123 profile image
Muhimen

Ahhh!!! I wanted to write exactly the same topic. 😤

Collapse
 
idrisrampurawala profile image
Idris Rampurawala

Haha... I would recommend you to still write a post for the same.

Everyone has a different style of expressing and even different style of understanding. Maybe the style in which you write will help other community members.

Also, you might have different settings in vscode which we might learn from you ☺️

Always write what you feel! 😉

Collapse
 
zyzmoz profile image
Daniel Cunha (he/him)

Cool! I did it, like, two days ago! However, I didn't know if it was right... Thanks anyway!

Collapse
 
idrisrampurawala profile image
Idris Rampurawala

Cool. Share your thoughts if you tried something different for the community.