The best VS Code extensions for Python developers
I’m more at comfortable with the editor now, and some of the areas where PyCharm...
I’m more at comfortable with the editor now, and some of the areas where PyCharm was previously used are now performing much better on their own or with the aid of plugins. There’s one new plugin in particular that has completely altered the way I use VS Code and how much more comfortable I feel coding in it. But I don’t want to get ahead of myself, so please read the entire article to learn more.
Let’s discover my favorite VS Code extensions for Python, and please let note that they are not in order. They are all just awesome!
This extension is required if you work with Python. Although VS Code already includes Python functionality, this extension takes it to a whole new level. When you open a Python file in VS Code, it will advise that you install the extension.
The extension is officially sponsored by Microsoft, the same company that makes Visual Studio Code, so it’s a no-brainer, but what will it do for you? Let’s look at the most important feature:
- IntelliSense: Edit your code with auto-completion, code navigation, syntax checking, and more
- Linting: Get additional code analysis with Pylint, Flake8, and more
- Code formatting: Format your code with black, autopep or yapf
- Debugging: Debug your Python scripts, web apps, remote or multi-threaded processes
- Testing: Run and debug tests through the Test Explorer with unittest, pytest, or nose
- Jupyter Notebooks: Create and edit Jupyter Notebooks, add and run code cells, render plots, visualize variables through the variable explorer, visualize dataframes with the data viewer, and more
- Environments: Automatically activate and switch between virtualenv, venv, pipenv, conda, and pyenv environments
- Refactoring: Restructure your Python code with variable extraction, method extraction, and import sorting
Look at it in action:
Python Docstring Generator
Documentation is important, but it’s a time-consuming effort, and we often take shortcuts since we don’t have the tools to make it easier or more efficient. Python Docstring Generator reduces developers’ effort by automatically writing docstrings, and while it may seem insignificant, it is a significant time saver. Perhaps PyCharm has spoiled me, but finding this extension was a big achievement for me.
The best part about this extension is that it supports all common docstring formats (including Google, docBlockr, Numpy, Sphinx, and PEP0257, which will be available soon). This docstring generator now includes multiline commenting for args, kwargs, decorators, errors, and parameter types.
Just see it in action and be amazed:
Python Test Explorer for Visual Studio Code
The Python Test Explorer extension allows you to run your Python unittest or Pytest tests with the Test Explorer UI. This small and handy tool will enable you to test your code from VS Code’s comfort with an excellent user interface and debugging capabilities.
We know the importance of unit testing so having a tool like this on your IDE or code editor is a must-have.
Python Type Hint
I believe the same will apply to Python. Over time, we will see more codebases using type hints, and modern frameworks will be directly built on top of them like FastAPI .
Python Type Hint provides type hint completion items for built-in types, estimated types, and the typing module. Moreover, it can search for Python files in the workspace for type estimation purposes.
Another of my favorite features of PyCharm, now available for VS Code. Code, run and analyze with Jupyter Notebooks directly in VS Code, without ever having to leave to your browser.
Edit your notebooks with the help of VS Code auto-completion, checks, syntax highlighting, and all you love about VS Code.
Python Preview is a Python plugin that allows you to debug your Python code visually. It turns debugging code into an interactive experience with animations and graphics to reflect the condition of your program. All you have to do is look at it:
Python Snippets is an extension full of in-built snippets packs developed by Ferhat Yalçın. This extension is great for any developer but especially for beginners in Python. It contains numerous in-built snippets such as string, list, sets, tuple, dictionary, class, and much more. Another advantage of using this plugin is that it also provides at least one example of each snippet, making it awesome while learning Python.
AREPL for Python
Have you ever needed to build a basic script for one-time usage, or needed a little program to execute a certain task, so you opened your terminal and began coding in Python? What was your impression of the place? Terrible?
AREPL for Python aims to solve that problem, by providing a real-time Python scratchpad. Do you want to see how it works?
- Real-time evaluation: no need to run – AREPL evaluates your code automatically. You can control this (or even turn it off) in the settings.
- Variable display: The final state of your local variables are displayed in a collapsible JSON format.
- Error display: The instant you make a mistake, an error with stack trace is shown.
- Settings: AREPL offers many settings to fit your user experience. Customize the look and feel, debounce time, python options, and more!
In the introduction, I described a plugin that changed my mind on VS Code. That’s TabNine for you. Because I was so used to PyCharm, autocompletion was one of the most difficult aspects of VS Code for me. And, don’t get me wrong, VS Code is good, but PyCharm is on another level compared.
By applying AI-based ideas, TabNine was able to modify that. The models are trained with open-source projects, but once installed, it will also learn from your projects while keeping all operations local, ensuring that your code is not transferred to the cloud.
Let’s discuss some of their features:
- Insane code completion
- Ability to learn from your own and your team’s projects
- Privacy, users can choose to run models locally or get cloud completions, in which case the developer’s code is encrypted and immediately deleted.
- The models are trained on open-source code
- No licensing issues
- Free and paid versions
VS Code is a great editor, but what makes it so special is the ecosystem of extensions that takes it to the next level.
It still doesn’t surpass the experience I get from Jetbrains products, but for a free ecosystem, it is really good.
I hope you enjoyed this article, and as always, if you have any suggestions on what are your favorite VS Code extensions, please let me know in the comments