Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

341
Vistas
How to make VSCode honor black excluded files in pyproject.toml configuration when using formatOnSave

I have the following pyproject.toml for configuring black:

[tool.black]
exclude = 'foo.py'

If I run black . from the project's root folder that only contains foo.py, I get No Python files are present to be formatted. Nothing to do �😴 as expected.

However, when I save foo.py from within VS Code (I have black configured as the formatter and enabled Format On Save), the file is still formatted by black.

Interestingly, VS Code seems to honor other configurations, e.g. line-length.

Is there a way to make VSCode honor the exclude configuration?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you list a file explicitly, this takes precedence over the any excluded files. This seems to be what black's developers consider the expected behaviour, see for example this issue. Also, this won't be fixed within vscode, see this issue.

This is also a problem when using pre-commit.

Since I didn't want to maintain yet another list (I do this for pre-commit already) of files for which I do not want to use FormatOnSave I ended up using a different approach. Since all of the files that I don't want to auto-format on save reside in a specific folder within my project, I ended up using the workaround described in this answer and deactivate FormatOnSave in the sub-folder settings.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda