DEV Community

Cover image for Boost your Python development in VS Code: Top picks for extensions πŸ’»πŸš€πŸ› οΈ
Simon Whelan
Simon Whelan

Posted on

1

Boost your Python development in VS Code: Top picks for extensions πŸ’»πŸš€πŸ› οΈ

As a software developer, I know the importance of having clear, readable, and consistent code. However, with so many opinions and personal coding styles out there, this can be difficult to get right. Luckily, in Python, we have an agreed-upon format known as PEP 8 to adhere to when writing our code. PEP 8 is a set of guidelines for writing Python code that was created by the Python community to improve the readability and maintainability of Python code.

In this post, we'll be discussing some of my favorite VS Code extensions, many of which can help you adhere to PEP 8 guidelines with ease and boost your Python development. We'll be discussing extensions such as Prettier, Black, flake8, Monokai Pro, SnapCode and GitHub. These are the tools that I've personally found to be the most useful and effective in my daily work. I'll be providing a brief overview of each extension, as well as specific examples of how they can be used in a real-world scenario, based on my own experience. So, whether you're a seasoned Python developer or just starting out, I hope you'll find this post helpful in your own development journey. Let's get started!

Prettier

Prettier is a code formatter that can automatically format your code to a consistent style. It supports a wide range of languages, including Python, and can be easily integrated with VS Code. It can improve your code by making it more readable and consistent, which can make it easier to collaborate with others and understand your own code later on. For example, you can set up Prettier to automatically format your code when you save a file by adding the following to your VS Code settings: "editor.formatOnSave": true.

Prettier has a whole host of customisable settings. Some of the most useful are -

  • printWidth: This setting controls the maximum line length for your code. It can help you keep your code looking clean and organized by wrapping lines that exceed the specified width. This is particularly useful when working with PEP 8, which recommends a line length of 79 characters.

  • singleQuote: This setting controls whether single or double quotes are used for strings in your code. In python, single quotes are more commonly used than double quotes, but it can be set based on the user preference.

  • trailingComma: This setting controls whether trailing commas should be added to the end of lists, objects, and function arguments in your code. This can help you keep your code organized and improve readability.

  • tabWidth: This setting controls the number of spaces used for each tab in your code. It can help you keep your code looking clean and consistent by ensuring that all tabs are the same width. PEP 8 dictates that 4 spaces is the correct width.

  • parser: This setting allows you to specify the parser that will be used to parse the code. For Python, the options are 'babylon' and 'flow', default is 'babylon' which supports most of the features of Python.

Keep in mind that there are many other options and configurations available, so it's worth exploring the documentation and experimenting with different settings to find the ones that work best for you and your codebase!

Black:

Black is another code formatter, but it is specifically designed for Python. This extension can improve your code by making it more consistent and easier to read, which can help you write more maintainable code. For example, you can use the --line-length 79 command to limit the line length to 79 characters. Black is an auto-formatter that is ran in the terminal using the β€˜black’ command.

You can install Black via the link above or with

pip install black
Enter fullscreen mode Exit fullscreen mode

flake8

Linting is the process of automatically checking the source code for potential errors, bugs, and other issues, including adherence to specific style guides like PEP 8. One popular and well-respected tool for this is Flake8, which can be integrated with VS Code. It supports PEP 8 and can improve your code by catching errors and style issues early on, helping you avoid bugs and write more readable code. To use it, you can configure Flake8 to run automatically every time you save a file by adding "python.linting.flake8Enabled": true to your VS Code settings.

It's worth mentioning that flake8 doesn't have an automatic formatting feature, it only checks the code and returns errors, warnings or info for you to alter yourself.

flake8 can be installed with

pip install flake8
Enter fullscreen mode Exit fullscreen mode

Monokai Pro:

Monokai Pro is a color scheme for VS Code that is designed to be easy on the eyes and make it easier to read your code. It can improve your code by making it more readable, which can help you understand your code better and make fewer mistakes. You can set it as your default color scheme by going to VS Code settings and searching for "color scheme" and selecting Monokai Pro. This is a paid theme, however there is also a fully functional, never-ending 'trial' with an occaisonal pop-up asking you to buy.

Monokai Pro stock image

CodeSnap:

CodeSnap is a VS Code extension that allows you to take screenshots of your code and share them with your friends and colleagues. It's a great way to show off your work and get feedback on your code. CodeSnap offers a variety of color options for the background of your screenshots, including the ability to add a custom colour. Furthermore, CodeSnap also allows you to add a custom watermark, such as a logo or copyright notice, to your screenshots for branding or credit purposes.

In addition to the custom color and watermark options, CodeSnap also has a feature that allows you to resize your screenshots. This means that you can easily adjust the size of your screenshots to fit your needs. This can be particularly useful when sharing your screenshots on social media or other platforms where image size may be a consideration.

CodeSnap also allows you to use a transparent background, which can help to create a more polished and professional look. With these additional features, CodeSnap is a great tool for enhancing the visual appeal and professionalism of your screenshots.

snapcode image - blue background

snapcode image

GitHub:

The GitHub Extension for VSCode is a powerful tool that can help you streamline your workflow and improve your collaboration with other developers. Some of the key features of this extension include:

  • Direct access to the GitHub website, allowing you to view and manage your repositories, issues, and pull requests directly from within VS Code.
  • The ability to create, review, and merge pull requests directly from VS Code, eliminating the need to switch between different tools.
  • Integrated support for Git, allowing you to perform common Git tasks such as committing, pushing, and pulling directly from within VS Code.
  • The ability to set up Black and Prettier to automatically format your code when you push to GitHub, ensuring that your code adheres to PEP 8 guidelines at all times and reducing the risk of introducing style issues into your codebase.

The GitHub Extension for VSCode is a must-have for any developer who is working with GitHub, whether you're a solo developer or part of a team. With this extension, you can easily manage your repositories, collaborate with other developers, and ensure that your code is always well-formatted and easy to read.

In conclusion, as a developer, it's essential to have tools that can help you write clear, readable, and consistent code. The VS Code extensions discussed in this post are all great choices for Python developers. They can help you adhere to PEP 8 guidelines, improve your code, and make your development process more efficient and enjoyable. With so many options and configurations available, it's worth experimenting with different settings to find the ones that work best for you and your codebase. Remember, there are many other extensions available for VS Code, so don't be afraid to explore and see what else is out there.

Feel free to add any extensions you enjoy using in the comments!

Thanks for reading, and happy coding! πŸ‘‹

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
πŸŽ₯ Audio/video file upload with real-time preview
πŸ—£οΈ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
πŸ“€ Export interview's subtitles in VTT format

Read full post

Top comments (0)

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

πŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay