Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fixes #4232. This issue happening is different from what was stated. At least with the given bash script, black does correctly find and apply the settings from the
pyproject.toml
, the force exclude just doesn't get applied. This happens because the check for if formatting should be skipped when using stdin is constructed viaAnd in the case of the given bash script,
root_relative_path
ends up as/testfile.py
, which obviously doesn't includesubmodule
, so it passes the exclude.If I understand the intended use case correctly, this is for use with an editor, which is why I put the changelog entry into the integrations section. This should make the behavior of black always match what the docs say,
It also just makes sense to me, even if it's a bit redundant. If you give an input to
--stdin-filename
that matches the force exclude regex, it should get excluded. If there is something I'm missing with this please let me know.There might be a better way to do this that doesn't end up in two different calls to
path_is_excluded
, but it's a relatively cheap function so it should be fine.Checklist - did you ...
CHANGES.md
if necessary?