Hey! These docs are for version 2.0, which is no longer officially supported. Click here for the latest version, 2.7!

fmt

Autoformat source code.

See here for how to opt in to specific formatters, along with how to configure them:

  • Black
  • Docformatter
  • isort

If you activate multiple formatters, Pants will run them sequentially so that they do not overwrite each other. You may need to update each formatter's config file to ensure that it is compatible with the other activated formatters.

🚧

Possible issue with iSort 5's import classifier algorithm

Some Pants users had to explicitly set default_section = "THIRDPARTY" to get iSort 5 to correctly classify their first-party imports, even though this is the default value.

They report that this config works for them:

# pyproject.toml
[tool.isort]
known_first_party = ["my_org"]
default_section = "THIRDPARTY"

You may also want to try downgrading to iSort 4.x by setting version = "isort>=4.6,<5" in the [isort] options scope.


Did this page help you?