Fix black formatting failure on tokenize.pyi #513
Closed
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.
Summary
I noticed this file was mal-formatted when using
black .
toautoformat a different branch.
This was confusing to me, I rely on autoformatting after writing
messy code. The reason for it appears to be that black and isort
do not agree
To be specific:
profile = "black"
set, it seems that isort will add onlyone blank line on
.py
files unless otherwise specified. This is indirect contradiction to what's stated in isort github issues and docs,
which claim that
profile = "black"
should solve the problem on newerversions of isort (I tried against the latest and it makes no
difference)
blank_lines_after_imports = 2
as thepyproject.toml
currently does (and is necessary to not mess up themajority of our code in
*.py
files, then isort and black willargue with one another about how many blank lines to use in .pyi files
My solution is to skip isort on
*.pyi
files, which I think is betterthan having confusing behavior.
As an alternative, or in parallel, it might be worth me opening a PR
demonstrating that
profile = "black"
isn't working for us andreferencing it in an issue in isort.
Test Plan