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?
The
--force-exclude
option also excludes files if they are explicitly listed. Thus, it also works withformatOnSave
in VS Code.In the example above, simply use