PyLint 无法识别 turtle 模块的 mainloop() 成员
PyLint not recognizing mainloop() member of the turtle module
我正在试用 python 的 turtle 模块,虽然程序正确执行,但 PyLint 一直错误地将部分程序标记为错误。程序 polygon.py
包含以下内容:
import turtle
t = turtle.Turtle()
t.fd(100)
turtle.mainloop()
该程序按预期执行,乌龟向前移动了 100 像素。但是,在 VSCode 中,PyLint 将 turtle.mainloop()
下划线表示为错误,表示:
Module 'turtle' has no 'mainloop' member pylint(no-member)
此外,在实际的 turtle.py
模块中,提及 mainloop()
以及其他一些成员也被标记为错误,表示:
"mainloop" is not defined Pylance (reportUndefinedVariable)
我尝试卸载并重新安装 PyLint,但错误继续显示。考虑到程序可以正常运行,我该如何修复它们,或者至少隐藏它们?
经过一番搜索,我找到了针对误报无成员错误的解决方案。对于PyLint,进入相应的JSON文件并添加:
"python.linting.pylintArgs":[
"--generated-members"
]
代表问题作者添加。
我正在试用 python 的 turtle 模块,虽然程序正确执行,但 PyLint 一直错误地将部分程序标记为错误。程序 polygon.py
包含以下内容:
import turtle
t = turtle.Turtle()
t.fd(100)
turtle.mainloop()
该程序按预期执行,乌龟向前移动了 100 像素。但是,在 VSCode 中,PyLint 将 turtle.mainloop()
下划线表示为错误,表示:
Module 'turtle' has no 'mainloop' member pylint(no-member)
此外,在实际的 turtle.py
模块中,提及 mainloop()
以及其他一些成员也被标记为错误,表示:
"mainloop" is not defined Pylance (reportUndefinedVariable)
我尝试卸载并重新安装 PyLint,但错误继续显示。考虑到程序可以正常运行,我该如何修复它们,或者至少隐藏它们?
经过一番搜索,我找到了针对误报无成员错误的解决方案。对于PyLint,进入相应的JSON文件并添加:
"python.linting.pylintArgs":[
"--generated-members"
]
代表问题作者添加。