【问题标题】:pre-commit is failing with "Expected a Config map but got a list"预提交失败并显示“需要一个配置映射但得到了一个列表”
【发布时间】:2023-01-24 09:36:04
【问题描述】:

多年来我一直在使用pre-commit工具!直到最近它开始失败并出现一条神秘的错误消息时,它一直运行良好:

$ pre-commit run flake8 --all-files
An error has occurred: InvalidConfigError: 
==> File .pre-commit-config.yaml
=====> Expected a Config map but got a list
Check the log at /home/asottile/.cache/pre-commit/pre-commit.log

我该如何解决?

【问题讨论】:

    标签: pre-commit.com


    【解决方案1】:

    自 2020 年 7 月以来,您的特定案例一直在发出警告,并显示类似于以下的消息:

    $ pre-commit run flake8 --all-files
    [WARNING] normalizing pre-commit configuration to a top-level map.  support for top level list will be removed in a future version.  run: `pre-commit migrate-config` to automatically fix this.
    flake8...................................................................Passed
    

    幸运的是,即使你已经升级到 pre-commit 3.0(它放弃了对这种格式的支持),你仍然可以运行pre-commit migrate-config,这会将你的配置更新为支持的格式:

    $ pre-commit migrate-config
    Configuration has been migrated.
    $ pre-commit run flake8 --all-files
    flake8...................................................................Passed
    

    免责声明:我撰写了预提交

    【讨论】:

      猜你喜欢
      • 2020-06-19
      • 2021-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-31
      • 2021-07-20
      相关资源
      最近更新 更多