3.6 KiB
Visual Studio Code setup
-
Recommended vscode extensions for Python Development
-
Enable strict typehints in the setting
{ "python.analysis.typeCheckingMode": "strict", "python.analysis.inlayHints.pytestParameters": true, "python.analysis.inlayHints.functionReturnTypes": true } -
Format using
Blackand Lint usingRuffon save!!! warning
Set all these settings to false for existing projects that never use `Black` or `Ruff` before.{ "[python]": { "editor.defaultFormatter": "ms-python.black-formatter", "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true, "source.fixAll": true } }, "python.formatting.provider": "none", "notebook.formatOnSave.enabled": true } -
Test using
pytest{ "python.testing.pytestEnabled": true, "python.testing.pytestArgs": ["tests"] } -
Use
googledocumentation style{ "autoDocstring.docstringFormat": "google" } -
Guides from the internet
Virtual Environment Management
Pyenv and Poetry is typically used for managing Python package, while Conda is more popular in Data Science project.
Both features virtual environment creation, but Poetry offers finer details on installing packages for production or development, publishing the Python package.
-
!!! note "Pyenv Installation" Pyenv installation may requires executing more than one line in terminal, you also need to set your shell profile (
.zshrcor.bash_profile).Read carefully [here](https://github.com/pyenv/pyenv#installation)!!! note "Poetry Installation"
If you have old Poetry version (<1.2), you need to uninstall it and install the latest version.
Gitignore
Download gitignore template from gitignore.io.
Python and visualstudiocode are recommended arguments for starter.
Alternative Way
You may create command line function gi to download gitignore file. Follow the guide in here. Then, you can the command in the project root folder.
gi python,visualstudiocode >> .gitignore