Skip to content

Python vscode tips

install useful libs

1
2
3
4
pip install black
pip install flake8
pip install pytest
pip install pylint

Linting

Pylint

Powerful one, mostly a good choice.

Prospector

I have a project which has no depence of Django, But Prospector keep reporting Django is not available on the PYTHONPATH for each py file, which I didn’t install on venv lib.

[Pylance]

For moudle developer: Steps To fix worng Hint could not be resolved Pylance(reportMissingImports) Shift+Ctrl+P, types setting, find Perference: Open Settings (JSON)

add following into settings.json

1
2
3
4
"python.analysis.extraPaths": [
    "./src",  
    "./modules"
]

flake8

add following into settings.json

1
2
3
"python.linting.flake8Args": [
    "--ignore=E203,W503"
],

Fromatting

black

add black as default formator for vscode

1
2
3
4
5
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
    "-l",
    "80"
],

Testing


Github based Comments, sign in Github required.