升级flake8后,执行pflake8时报错了:
Traceback (most recent call last):
File "/Users/lian/Library/Caches/pypoetry/virtualenvs/huiyuan-Ur7Wlhj0-py3.10/bin/pflake8", line 5, in <module>
from pflake8.__main__ import main
File "/Users/lian/.local/pipx/venvs/poetry/lib/python3.10/site-packages/pflake8/__init__.py", line 54, in <module>
class ModifiedConfigFileFinder(flake8.options.config.ConfigFileFinder):
AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder'
安装的包版本如下:
% pip list|grep flake8 :( 1 22-08-25 - 23:09:32
flake8 5.0.4
pyproject-flake8 0.0.1a5
原因是flake8最新版的5.0+与旧版不兼容,导致pflake8的补丁失效了
解决方法一:
用回4.0版本的flake8
pip install -U pyproject-flake8 # 会自动卸载掉最新版的flake8并安装匹配的版本
解决方法二:
使用开发版的pflake8
git clone https://github.com/csachs/pyproject-flake8.git -b patch-via-ast
pip install -e ./pyproject-flake8