pep8 合规性测试失败

pep8 compliance testing is failing

我遵循了 Head First Python 第 2 版,第 4 章演示了 pep8 合规性测试。

当运行py.test--pep8searchV.py报错

appdata\local\programs\python\python38\lib\site-packages\pep8.py:110: FutureWarning: 位置 1 可能存在嵌套集 EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]') ===============测试会话开始================================ ========= 平台 win32 -- Python 3.8.6、pytest-6.2.1、py-1.10.0、pluggy-0.13.1 根目录:D:\work\py-modules 插件:pep8-1.0.6 收集了 0 个项目/1 个错误

===============错误============================= ========================== _______________ERROR 收集测试会话 ____ 直接构建 Pep8Item 已被弃用,请使用 Pep8Item.from_parent。 有关详细信息,请参阅 https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent。 ==========简短的测试摘要信息=============== 错误 !!!!!!!!!!!!!!!!!!!!!!!!!Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!

这是serachV.py

中的代码
def search_letter(phrase: str , letter:str='aeiou')->set:
    """ Serach for letter in phrase"""
    return set(letter).intersection(set(phrase))

不确定为什么没有收集到任何项目?

尝试 pep8 searchV.py 而不是 py.test --pep8 searchV.py 并且成功了。

但是 pep8 已重命名为 pycodestyle(GitHub 问题 #466)。在未来的版本中将不再使用 pep8 工具。

所以,我使用了 pycodestyle,它成功了!

pycodestyle searchV.py