python - 如何从 check-yaml git hook 中排除 !Ref 标签?

标签 python git yaml pre-commit-hook

有一个 serverless.yaml 文件,其中包含如下行:

VpcId: !Ref MyVpc

Yaml 文件通过 check-yaml git 钩子(Hook)进行验证,该钩子(Hook)由 pre-commit 命令调用。因此,预提交运行 --all-files 运行失败并出现错误:

could not determine a constructor for the tag '!Ref'
  in "serverless.yml", line 172, column 29

有没有办法配置check-yaml来跳过此错误?

最佳答案

hooks:
- id: check-yaml
  args: ['--unsafe']

应该可以解决问题。它只是检查语法而不是尝试加载 YAML。

关于python - 如何从 check-yaml git hook 中排除 !Ref 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59413979/

相关文章:

python - pandas 数据框中相应行之间的日期之间的差异

python - python中使用@符号装饰和不使用@符号的区别

python - 我想通过在我的数据框中添加 2 个连续的列来插入新列

git - 'adding to the index' 在 Git 中的真正含义是什么?

svn - "git svn fetch"失败,ls-tree 因缺少树对象而死亡

Git: merge 到master,然后推回到所有分支

yaml - YAML 文件中的内联注释

Docker 组成 : expected a mapping or list of mappings for merging, 但发现标量

Python - Pandas — 如何检查 DataFrame 是按哪一列分组的?

json - 没有固定属性列表的对象的 Swagger Yaml 模式定义