【问题标题】:Configuring isort and autoflake with project.toml使用 project.toml 配置 isort 和 autoflake
【发布时间】:2020-05-28 16:20:54
【问题描述】:

我有一系列在本地和 Jenkins 上运行的工具来检查和格式化我的 Python 代码:

  • 自动切片
  • 分类
  • 黑色

我使用pyproject.toml 文件配置黑色,使用.isort.cfg 排序和使用命令行参数的autoflake,因为我没有找到任何支持使用配置文件对其进行配置。

有没有办法使用pyproject.toml 来配置 isort 和 autoflake?

我希望所有工具都只配置一个文件。

【问题讨论】:

    标签: python isort pyproject.toml autoflake


    【解决方案1】:

    isort 配置可以在https://pycqa.github.io/isort/docs/configuration/options/找到

    一般来说,配置参数用下划线分隔。下面的示例将提供使 black 和 isort 兼容的配置,如这里所讨论的 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
    

    【讨论】:

      【解决方案2】:

      您可以将您的 isort 配置移动到 pyproject.toml 但将 [settings] 更改为 [tool.isort]

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

      我不相信 autoflake 支持 pyproject.toml 配置。欢迎您在他们的 github 页面上打开一个问题。

      【讨论】:

      • 这就是为什么我们不允许允许 URL 作为答案...
      猜你喜欢
      • 2021-07-07
      • 2022-06-10
      • 2022-11-01
      • 2022-11-07
      • 2022-08-06
      • 2020-11-23
      • 1970-01-01
      • 2017-10-06
      • 2023-03-09
      相关资源
      最近更新 更多