pep8 合规性测试失败

use*_*634 3 pep8 pytest python-3.x

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

运行 py.test --pep8 searchV.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 rootdir: D:\work\py-modules 插件:pep8-1.0.6 收集了 0 项/1 错误

=============== 错误==================================== ===================== _______________错误收集测试会话 ____ 直接构建 Pep8Item 已被弃用,请使用 Pep8Item.from_parent。有关更多详细信息,请参阅https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent 。==========简短的测试摘要信息===============错误!!!!!!!!!!!!!!!!!!!!!已中断:收集期间出现 1 个错误!!!!!!!!!!!!!!!!!!!!!

这是serachV.py中的代码

def search_letter(phrase: str , letter:str='aeiou')->set:
    """ Serach for letter in phrase"""
    return set(letter).intersection(set(phrase))
Run Code Online (Sandbox Code Playgroud)

不知道为什么没有收集到任何物品?

use*_*634 6

尝试pep8 searchV.py代替而不是并且py.test --pep8 searchV.py 有效。

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

所以,我使用了 pycodestyle 并且它有效!

pycodestyle searchV.py
Run Code Online (Sandbox Code Playgroud)