Python >> Tutoriel Python >  >> Python Tag >> VScode

Comment utiliser yapf (ou noir) dans VSCode

Le problème était dans les mauvais paramètres. Pour utiliser yapf, black ou autopep8, vous avez besoin :

  1. Installez yapf / noir / autopep8 (pip install noir)
  2. Configurer .vscode/settings.json de la manière suivante :

partie du fichier :

{
    "python.linting.enabled": true,
    "python.linting.pylintPath": "pylint",
    "editor.formatOnSave": true,
    "python.formatting.provider": "yapf", // or "black" here
    "python.linting.pylintEnabled": true,
}

Option clé - "editor.formatOnSave": true, cela signifie yapf formate votre document à chaque fois que vous l'enregistrez.