报错信息
File “/usr/local/miniconda3/envs/occ/lib/python3.8/site-packages/mmcv/utils/config.py”, line 508, in pretty_text
text, _ = FormatCode(text, style_config=yapf_style, verify=True)
TypeError: FormatCode() got an unexpected keyword argument ‘verify’
方法一:更新或降级 yapf(不推荐,升级后可能会有其他错误)
更新或降级 yapf
如果 yapf 版本不符合 mmcv 需要的版本(即不支持某些参数),可能需要更新或降级 yapf
更新 yapf:
pip install -U yapf
pip install yapf==<version>
方法二:删除 verify 参数(我使用,work)
原来的
text, _ = FormatCode(text, style_config=yapf_style, verify=True)
text, _ = FormatCode(text, style_config=yapf_style)
中的verify的去掉
verify 参数在 yapf 0.31.0 版本中引入。如果您使用的是较早版本的 yapf,则不会遇到此错误。
如果您使用的是自定义 yapf 样式配置,请确保配置中未定义任何不受 FormatCode 函数支持的参数。