10 Must-Have VS Code extensions for Python developers


Whether you’re creating simple Python scripts or extensive Jupyter notebooks. As a Python Developer or Data Scientist, you need the right tools to create the best possible quality of code.

I’ve tested and reviewed more than hundreds of extensions for Python for this article and curated my findings to a list that contain the 10 best VS Code extensions for Python developers to save time writing code.

So let’s get to it! Here are 10 must-have essential Visual Studio Code extensions for Python:

What are the best VS Code extensions for Python development?

1. Python by Microsoft

This VS Code extension published by Microsoft has rich support for Python. It contains the following features:

  • Linting for your code with Pylint or Flake8 support
  • Debugging your code within the VS Code editor
  • IntelliSense support for auto-completion, code navigation, and formatting.
  • Support for Jupyter Notebooks, Pytest, and Unittests
  • Easily switch Python environments within the editor

2. Pylance

Pylance is an incredibly fast static type checker and adds comprehensive feature-rich language support for Python. Basically, this is the official successor to the Pyright extension that got released back in 2019.

Pylance by Microsoft VS Code extension feature demo

This extension includes the following features:

  • Intelligent type completion of keywords, symbols, and import names
  • Automatically insert import statements for type completions when necessary
  • Show docstrings and type information when you hover over symbols
  • Quickly find the location of the symbol’s definition when you click on the hover over the symbols.
  • Quickly find or rename all references to a symbol within a codebase
  • Automatically reorder imports in your code according to PEP8 rules.
  • Third-party libraries have support for type stub generation
  • As-you-type reporting of code errors and warnings (diagnostics)
  • Code navigation
  • Native multi-root workspace support
  • IntelliCode compatibility
  • Jupyter Notebooks compatibility
  • Semantic highlighting

3. Visual Studio IntelliCode

This is a standalone extension that provides AI-assisted IntelliSense. As you might have noticed, the first extension on this list also contains IntelliSense.

But in my experience, I find that this extension works better because it scans your code using AI and then does a better job with autocomplete than the Python extension from Microsoft.

4. Sort lines

Like the name suggests it sorts lines of text. This can be handy if you import a lot of libraries in your scripts and don’t want to reorganize them manually. if you want to have them in alphabetical order for example.

You can sort your code in the following ways:

CommandSort lines functionality
sortLinesAscending, case-sensitive (default)
sortLinesCaseInsensitiveAscending, case-sensitive
sortLinesCaseInsensitiveUniqueUnique ascending, case-sensitive
sortLinesReverseDescending, case-sensitive
sortLinesLineLengthLine length ascending
sortLinesLineLengthReverseLine length descending
sortLinesVariableLengthVariable-length ascending
sortLinesVariableLengthReverseVariable-length descending
sortLinesNaturalSorts alphabetically except groups with multi-digit numbers
sortLinesUniqueRegular character code keeping only unique items
sortLinesShuffleShuffles output
removeDuplicateLinesRemoves duplicate lines
Table displaying all sort lines vs code extension functionalities

To invoke the Sort lines functionality type the following command

CMD + Shift + P -> Sort Lines

My most used sort function when I code in Python is Natural which Sorts alphabetically but groups multi-digit numbers.

5. Black Formatter

Black Formatter allows you to format your code using one of the most used Python formatters “Black”. Having a formatter in place improves productivity when working on Python projects with multiple developers.

That’s because the formatter is PEP8 compliant and makes sure the code style stays consistent through the projects and saves you time by not having discussions in pull requests about how the code should be formatted.

In order to enable Black as the default formatter of your Python code, you should add the following values in your vscode settings:

  "[python]": {
    "editor.defaultFormatter": "ms-python.black-formatter"
  }

6. Indent rainbow

Indent rainbow adds colors to your indents which makes readability even better, especially in a dark background like in VS Code.

Combine this with Indenticator to improve the reading fluency of your code.

Indent rainbow VS Code extension
Indent rainbow VS Code extension

You have the option to customize the indent colors to your liking by adding the following values in your vscode settings:

  // Defining custom colors instead of default "Rainbow" for dark backgrounds.
  "indentRainbow.colors": [
    "rgba(255,255,64,0.07)",
    "rgba(127,255,127,0.07)",
    "rgba(255,127,255,0.07)",
    "rgba(79,236,236,0.07)"
  ]
  // The indent color if the number of spaces is not a multiple of "tabSize".
  "indentRainbow.errorColor": "rgba(128,32,32,0.6)"
  // The indent color when there is a mix between spaces and tabs.
  // To be disabled this coloring set this to an empty string.
  "indentRainbow.tabmixColor": "rgba(128,32,96,0.6)"

7. Bracket Pair Colorizer 2

This VS Code extension allows you to colorize the brackets in your code so you can easily identify which brackets belong to each other.

Whenever I review JSON files for example (which contain a lot of brackets), this tool makes validating the file a lot quicker.

Bracket pair colorizer 2 VS Code extension
Bracket pair colorizer 2 VS Code extension

Update: Bracket Pair Colorizer has become a native VS Code feature. This means you don’t need to download a separate extension anymore.

To turn on the native bracket pair colorization, do the following:

  1. In VSCode, go under the File Menu -> Preferences -> Settings
  2. Search for the setting: bracketPair
  3. Click the checkbox to turn on the bracket pair colorization

8. Sourcery

Sourcery is an AI-powered coding assistant that helps you to write better Python code faster. It works by providing refactoring suggestions on the fly that you can instantly integrate into your code. This will tremendously improve code quality when it gets implemented into your python vscode project.

Python sourcery vscode extension demo

9. Python Docstring Generator

The Python Docstring Generator extension allows you to quickly generate docstrings for your python functions.

Essentially it is a template that you can use to add extensive comments to your code.

Python docstring generator vscode extension example

To initiate a new docstring in Python, start the line with triple quotes (""") to generate the template.

10. Dash

This is absolutely a necessary extension when you need to refer to the official Python documentation while you’re coding.

This VS Code extension allows you to invoke Dash from the editor. So if you need to get more information about Classes, Functions, or Types you highlight the code and press ctrl + h to access the official documentation offline.

If you compare this to going in the browser and visiting the official documentation website to search for the API, it goes a lot quicker doing it offline.

Dash Python docset vscode extension
Dash Python docset vscode extension

The benefit of having your docs offline is that you don’t need to have internet access in order to start coding and looking up references.

Finding pages that are stored locally can be accessed way quicker than trying to google and needing to find the specific thing you’re looking for.

These benefits boost your productivity and allow you to focus more on the coding part.

Additional python extension: Git Lens

If you’re developing Python projects or any project in general, then there’s a big chance you’re using git. The extension: GitLens improves the git functionality in VS Code. A couple of notable features that are worth mentioning are:

  • git blame – shows who modified each line within a file
  • git changes – highlights any local (unpublished) changes or lines changed by the most recent commit
  • git revision navigation – shows the git history of a file and allows you to effortlessly navigate it
Gitlens VS Code extension example of git blame

One of my favorite features is git blame. This feature shows author metadata attached to specific committed lines in a file.

This is helpful when you’re collaborating with other developers on the same project. Because it allows you to see who changed what within the code.

Their feature list is very comprehensive, if you want to see what it can do, please check out their readme on the VS Code marketplace.

Conclusion

To summarize, as a Python developer it can be a daunting task to find the right VS Code extensions to improve your workflow and productivity.

Therefore I created this list containing the 11 best VS Code extensions for Python including Python by Microsoft, Pylance, Visual Studio IntelliCode, Sort lines, Black Formatter, indent rainbow, bracket pair colorizer 2, Sourcery, Python docstring generator, Dash, and Git lens.

You’re daily productivity and focus will improve and next to that your code is less prone to bugs because of the guardrails and highlights that are present in these VS Code extensions.

If you’re interested in VS Code extensions for other programming languages. I wrote articles containing the best extensions for TypeScript, JavaScript, and Cloud Engineers.



Danny Steenman

A Senior AWS Cloud Engineer with over 9 years of experience migrating workloads from on-premises to AWS Cloud.

I have helped companies of all sizes shape their cloud adoption strategies, optimizing operational efficiency, reducing costs, and improving organizational agility.

Connect with me today to discuss your cloud aspirations, and let’s work together to transform your business by leveraging the power of AWS Cloud.

I need help with..
stacked cubes
Improving or managing my CDK App.Maximize the potential of your AWS CDK app by leveraging the expertise of a seasoned CDK professional.
Reducing AWS Costs.We can start by doing a thorough assessment of your current AWS infrastructure, identifying areas with potential for cost reduction and efficiency improvement.
Verifying if my infrastructure is reliable and efficient.We’ve created a comprehensive AWS Operations Checklist that you can utilize to quickly verify if your AWS Resources are set up reliably and efficiently.