The functions mentioned are generated by code. PyLint only does static analysis.
I have written an astroid brain (plugin) to help the Python parser used by PyLint to add these functions.
Find the location where you have installed PyLint (directory ends with Lib\site-packages\pylint
or Lib/site-packages/pylint
.
Next to pylint
is a directory astroid
.
In the directory Lib\site-packages\astroid\brain
or Lib/site-packages/astroid/brain
create a file brain_turtle.py
with the content:
import astroid
def register(linter):
pass
def transform():
import turtle
def _make_global_funcs(functions, cls):
funcs = []
for methodname in functions:
method = getattr(cls, methodname)
paramslist, argslist = turtle.getmethparlist(method)
if paramslist == "": continue
funcs.append(f"def {methodname}{paramslist}: return")
return funcs
funcs = []
funcs.extend(_make_global_funcs(turtle._tg_screen_functions, turtle._Screen))
funcs.extend(_make_global_funcs(turtle._tg_turtle_functions, turtle.Turtle))
return astroid.parse('\n'.join(funcs))
astroid.register_module_extender(astroid.MANAGER, "turtle", transform)
Depending on the IDE integration of PyLint you might need to restart the IDE.
I have also created an astroid issue to add this brain to the next update of PyLint (Astroid)
You can also use this file with the --load-plugins
command line option of pylint
. See the PyLint documentation for IDE integration. The used file needs to be on your PYTHONPATH