I like to get inspiration from well designed python projects.
The last one that inspired me was the poetry repository.
I copied a lot from that, but the subject of this post are black and isort.
Both are well configured in pyproject.toml
:
[tool.isort]
profile = "black"
...
known_first_party = "poetry"
[tool.black]
line-length = 88
include = '\.pyi?$'
exclude = '''
/(
...
)/
'''
and formatting is configured in the Makefile
as:
format: clean
@poetry run black poetry/ tests/
I thought that running make format
would run black
which would internally run isort
, but when I ran isort .
, it correctly formated the import statements afterwards. It then seems black
did not run isort
.
Question: does black
run isort
internally?
Question: does black run isort internally?
No, it doesn't.
isort
has a profile = "black"
option that makes it adhere to Black's standards though.
The poetry
repository itself has a pre-commit hook defined here in .pre-commit-config.yaml that makes sure isort is run (along with a couple of other tools).