Configuring isort and autoflake with project.toml
Asked Answered
T

2

9

I have a series of tools running locally and on Jenkins to check and format my Python code:

  • autoflake
  • isort
  • black

I use pyproject.toml file to configure black, isort with .isort.cfg and autoflake with command line parameters because I haven't found any support to configure it with a configuration file.

Is there way to configure also isort and autoflake with pyproject.toml?

I would like to have all tools configured with just a single file.

Tripterous answered 28/5, 2020 at 16:20 Comment(0)
C
15

isort configuration can be found at https://pycqa.github.io/isort/docs/configuration/options.html

In general, config params are separated by underscores. The example below will provide configuration that makes black and isort compatible, as discussed here https://copdips.com/2020/04/making-isort-compatible-with-black.html

[tool.isort]
multi_line_output = 3
line_length = 88
include_trailing_comma = true

[tool.black]
line_length = 88
Carcanet answered 31/8, 2020 at 21:28 Comment(0)
E
3

You can just move your isort config to pyproject.toml but change [settings] to [tool.isort].

https://github.com/timothycrosley/isort#configuring-isort

I don't believe autoflake supports pyproject.toml configuration. You are welcome to open an issue on their github page.

Evacuate answered 5/6, 2020 at 9:58 Comment(2)
This is why we don't allow allow URLs as answers...Carcanet
Here's the updated url: pycqa.github.io/isort/docs/configuration/config_filesBarnie

© 2022 - 2024 — McMap. All rights reserved.