Pytest-pep8:来自 Head First Python 2'nd 版本的弃用错误



我一直在遵循Python Head第二版第4章中的代码。这是代码:

def search4vowels(phrase:str) -> set: #set - lots of
"""Returns the vowels found in the specified word."""
vowels = set('aeiou')
return vowels.intersection(set(phrase))
def search4letters(phrase:str, letters:str='aeiou') -> set:
"""Returns the set of letters from 'letters' found in the specified line"""
return set(letters).intersection(set(phrase))

上面的片段有俄语评论,并被翻译成英语

然后我用cmd:中的指令编写

> py.test --pep8 vsearch.py

Output:
================== test session starts ==========================
platform win32 -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: C:UsersnikitOneDriveРабочий столSchoolКнигиPythonPYfiles
plugins: pep8-1.0.6
collected 0 items / 1 error
================== ERRORS =======================================
__________________ ERROR collecting test session ________________
Direct construction of Pep8Item has been deprecated, please use Pep8Item.from_parent.
See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
for more details.
================== short test summary info ======================
ERROR
!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!
================== 1 error in 0.15s =============================

是什么原因造成的?

改为使用pycodestylehttps://pypi.org/project/pycodestyle/

pip install pep8
pep8 --first optparse.py