Search code examples
pythonisortpyproject.tomlautoflake

Configuring isort and autoflake with project.toml


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.


Solution

  • 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