Skip to content

isort loves black

Compatibility with black

Compatibility with black is very important to the isort project and comes baked in starting with version 5. All that's required to use isort alongside black is to set the isort profile to "black".


Beyond the profile, it is common to set skip_gitignore (which is not enabled by default for isort as it requires git to be installed) and line_length as it is common to deviate from black's default of 88.

Using a config file (such as .isort.cfg)

For projects that officially use both isort and black, we recommend setting the black profile in a config file at the root of your project's repository. That way it's independent of how users call isort (pre-commit, CLI, or editor integration) the black profile will automatically be applied.

For instance, your pyproject.toml file would look something like

profile = "black"

Read More about supported config files.


To use the profile option when calling isort directly from the commandline simply add the --profile black argument: isort --profile black.

A demo of how this would look like in your .travis.yml

language: python
  - "3.9"
  - "3.8"
  - "3.7"

  - pip install -r requirements-dev.txt
  - pip install isort black
  - pip install coveralls
  - pytest my-package
  - isort --profile black my-package
  - black --check --diff my-package
  - coveralls

See built-in profiles for more profiles.

Integration with pre-commit

You can also set the profile directly when integrating isort within pre-commit.

- repo:
    rev: 5.6.4
      - id: isort
        args: ["--profile", "black", "--filter-files"]