One of the most important parts of writing code is making sure your code is readable. There are so many positive downstream effects of clean code from its ease to maintain and add features, debug subtle programming errors or find uninitialized variables. Some people call this code hygiene. VS Code has linter extension support that enables you develop faster, produce cleaner code and is tweaked to your set up.
How VS Code handles Python linters
The linter development experience can live entirely within VS Code if you'd like. This means you do not need to pip install pylint for example.
🔥PRO-TIP: Set your default importStrategy
importStrategy is a field on any of the Python linter extensions for automatically setting the linter version in your IDE. I like to set mine to fromEnvironment in my User level settings so that it automatically checks the version in any project I'm working on with a team, but also allow VS Code to default to any Workspace level settings my team is sharing.settings.json
CODE// use the pylint version with extension
"pylint.importStrategy": "useBundled"
// use the pylint version found in requirements
"pylint.importStrategy": "fromEnvironment"
When you start your project, the first thing you will likely do is activate your virtual environment or open up a container to develop in (like
There are many packages for code quality. At the time of this post, VS Code and its active extension-contributing community supports , . The Ruff linter was created from the . The VS Code team encourages community contributed packages and you can
🔥PRO-TIP: Install isort
Install an import sorting extension like project
🔥PRO-TIP: Enable lintOnSave
When enablinglintOnSave, you might also want to enable genericfiles.autoSaveoption. The combination provides frequent linting feedback in your code as you type.
Want to dig more into the VS Code Linting documentation?
More Reading...
- VS Code Shortcuts |
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
SOCIAL SHARE CARD GENERATOR