python-3.x - pep8 合规性测试失败
问题描述
我遵循了 Head First Python 2nd Edition,第 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 个错误
=============== 错误 =================================== ===================== _______________ERROR 收集测试会话 ____ 直接构建 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))
不知道为什么没有收集物品?
解决方案
尝试pep8 searchV.py
而不是代替py.test --pep8 searchV.py
并且它起作用了。
但是 pep8 已重命名为 pycodestyle (GitHub issue #466) 。pep8 工具的使用将在未来的版本中删除。
所以,我使用了 pycodestyle 并且成功了!
pycodestyle searchV.py
推荐阅读
- algorithm - 有没有一种有效的方法来生成具有给定总和或平均值的范围内的 N 个随机整数?
- compression - phpThumb - 压缩 GIF 会丢失它的动画
- mysql - 如何将 Apache Superset 连接到本地数据库
- python - 成功登录后无法获取html源
- scala - 为什么 3/2 等于 1 而不是 1.5?
- angular - 如何读取 maxLength 验证器的值以便将其打印到表单中?
- html - 溢出一个孩子到固定高度的父母
- c++ - 我们如何迭代 Map 链接线性结构,即使它们被实现为红黑或 AVL 树?
- angular - BehaviorSubject 不会在不同的路径中更新
- java - Java SWT 列表错误,“空指针异常”