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 kn…


This content originally appeared on DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป and was authored by Simon Whelan

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

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

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! ๐Ÿ‘‹


This content originally appeared on DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป and was authored by Simon Whelan


Print Share Comment Cite Upload Translate Updates
APA

Simon Whelan | Sciencx (2023-01-15T11:13:53+00:00) Boost your Python development in VS Code: Top picks for extensions ๐Ÿ’ป๐Ÿš€๐Ÿ› ๏ธ. Retrieved from https://www.scien.cx/2023/01/15/boost-your-python-development-in-vs-code-top-picks-for-extensions-%f0%9f%92%bb%f0%9f%9a%80%f0%9f%9b%a0%ef%b8%8f/

MLA
" » Boost your Python development in VS Code: Top picks for extensions ๐Ÿ’ป๐Ÿš€๐Ÿ› ๏ธ." Simon Whelan | Sciencx - Sunday January 15, 2023, https://www.scien.cx/2023/01/15/boost-your-python-development-in-vs-code-top-picks-for-extensions-%f0%9f%92%bb%f0%9f%9a%80%f0%9f%9b%a0%ef%b8%8f/
HARVARD
Simon Whelan | Sciencx Sunday January 15, 2023 » Boost your Python development in VS Code: Top picks for extensions ๐Ÿ’ป๐Ÿš€๐Ÿ› ๏ธ., viewed ,<https://www.scien.cx/2023/01/15/boost-your-python-development-in-vs-code-top-picks-for-extensions-%f0%9f%92%bb%f0%9f%9a%80%f0%9f%9b%a0%ef%b8%8f/>
VANCOUVER
Simon Whelan | Sciencx - » Boost your Python development in VS Code: Top picks for extensions ๐Ÿ’ป๐Ÿš€๐Ÿ› ๏ธ. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/01/15/boost-your-python-development-in-vs-code-top-picks-for-extensions-%f0%9f%92%bb%f0%9f%9a%80%f0%9f%9b%a0%ef%b8%8f/
CHICAGO
" » Boost your Python development in VS Code: Top picks for extensions ๐Ÿ’ป๐Ÿš€๐Ÿ› ๏ธ." Simon Whelan | Sciencx - Accessed . https://www.scien.cx/2023/01/15/boost-your-python-development-in-vs-code-top-picks-for-extensions-%f0%9f%92%bb%f0%9f%9a%80%f0%9f%9b%a0%ef%b8%8f/
IEEE
" » Boost your Python development in VS Code: Top picks for extensions ๐Ÿ’ป๐Ÿš€๐Ÿ› ๏ธ." Simon Whelan | Sciencx [Online]. Available: https://www.scien.cx/2023/01/15/boost-your-python-development-in-vs-code-top-picks-for-extensions-%f0%9f%92%bb%f0%9f%9a%80%f0%9f%9b%a0%ef%b8%8f/. [Accessed: ]
rf:citation
» Boost your Python development in VS Code: Top picks for extensions ๐Ÿ’ป๐Ÿš€๐Ÿ› ๏ธ | Simon Whelan | Sciencx | https://www.scien.cx/2023/01/15/boost-your-python-development-in-vs-code-top-picks-for-extensions-%f0%9f%92%bb%f0%9f%9a%80%f0%9f%9b%a0%ef%b8%8f/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.