Ai
1 Star 0 Fork 0

ai-performance/pre-commit-hooks

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
check_json.py 626 Bytes
一键复制 编辑 原始数据 按行查看 历史
Anthony Sottile 提交于 2020-05-15 07:29 +08:00 . check-json: resolve TODO
import argparse
import json
from typing import Optional
from typing import Sequence
def main(argv: Optional[Sequence[str]] = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
args = parser.parse_args(argv)
retval = 0
for filename in args.filenames:
with open(filename, 'rb') as f:
try:
json.load(f)
except ValueError as exc:
print(f'{filename}: Failed to json decode ({exc})')
retval = 1
return retval
if __name__ == '__main__':
exit(main())
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ai-performance/pre-commit-hooks.git
git@gitee.com:ai-performance/pre-commit-hooks.git
ai-performance
pre-commit-hooks
pre-commit-hooks
master

搜索帮助