我已经使用这个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
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
Ant*_*ile 13
自 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
Run Code Online (Sandbox Code Playgroud)
幸运的是,即使您已经升级到 pre-commit 3.0(放弃了对此格式的支持),您仍然可以运行pre-commit migrate-config它将您的配置更新为支持的格式:
$ pre-commit migrate-config
Configuration has been migrated.
$ pre-commit run flake8 --all-files
flake8...................................................................Passed
Run Code Online (Sandbox Code Playgroud)
免责声明:我编写了预提交