DEV Community

antusystem
antusystem

Posted on

Best practice for starting with python in VSC?

Hi, I would like to ask for your recommendation about coding in Python, mainly with VSC. I have time coding, but "never" that serious; now, I want to do it like it should be. I have read several Python standards but I have some doubts mainly in Linting, Testing, Virtuals Environments, and Docstrings. I have find some good extensions in VSC marketplace and (to me) the more relevant are installed with Python Official Extension.

Linting

I was reading about linting here and found several Linters for Python, before that I was using the only one I knew, Flake8. Now, I believe I will switch to Pylama (which has all from Flake8) with Bandit. Both of them are supported in the Python Official Extension by VSC, so I don't know if some knows an argument that will improve the use of both of them. Or if another extension is better to use them both.

I don't like that much code formatting, I feel like it causes more trouble when it changes things

Testing

I have little experience with test and I have only use the unittest, but reading here I believe Pytest is far more complete, should I change to it?

A "basic" test extension is installed with Python Official Extension from VSC, but I don't know if there are better extensions for this. I supposse it is compatible with unittest, pytest and nose. What I don't is how to do test in several Python version with VSC, I believe is a good practice, but I don't know if I must have installed all the other python's versions to do this.

Virtual Environments

I know VSC let you have at least 1 virtual environment but I don't know if I can have a venv for each folder (different projects but same workspace) without me changing it manually every time. Maybe is better to have a workspace from each project in this case?

Also, I don't know if I should use pyenv or venv to create the environment, their differences so far seems meaningless to me. I know that you can create conda environments too, but I have never done it, and VSC supports it. Maybe there is good extension for this, I don't trust the ones I have found yet.

Docstrings

I use the Numpy format, which is in the Python Official Extension, I complement this with Python Type Hint to write better documentation in my code. I don't think there is another extension that can help me to document my code.

Well, I know I might be asking for a lot, but I have read about it on my own, so I needed someone else's recommendation for this. Thanks for your help.

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more