Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

349
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda