Bug report
turtle.teleport added in #103974 seems not quite correct.
Why?
- It is produced automagically from
Turtle.teleport instance method. It has this signature: def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None:
- The result function
turtle.teleport has this signature: def teleport(x, y=None, fill_gap=None)
Notice that it is missing x=None default and for some reason fill_gap is not a kw-only anymore.
The second problem happens because inside it uses inspect.getargs:
|
args, varargs, varkw = inspect.getargs(ob.__code__) |
which translates kw-only to positional-or-keyword params.
So, when I try to run turtle.teleport I get:
Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython/ex.py", line 60, in <module>
print(teleport())
^^^^^^^^^^
TypeError: teleport() missing 1 required positional argument: 'x'
And with just one arg:
Traceback (most recent call last):
File "/Users/sobolev/Desktop/cpython/ex.py", line 60, in <module>
print(teleport(1))
^^^^^^^^^^^
File "<string>", line 4, in teleport
TypeError: Turtle.teleport() takes from 1 to 3 positional arguments but 4 were given
Annotations are also missing. It is not a big problem, but it is inconvenient.
I propose using inspect.signature instead. It will allow us using pos-only and keyword-only params with ease.
I have a PR ready.
Found while working on python/typeshed#10548
CC @AlexWaygood and @terryjreedy
Linked PRs
Bug report
turtle.teleportadded in #103974 seems not quite correct.Why?
Turtle.teleportinstance method. It has this signature:def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None:turtle.teleporthas this signature:def teleport(x, y=None, fill_gap=None)Notice that it is missing
x=Nonedefault and for some reasonfill_gapis not a kw-only anymore.The second problem happens because inside it uses
inspect.getargs:cpython/Lib/turtle.py
Line 3927 in 52fbcf6
So, when I try to run
turtle.teleportI get:And with just one arg:
Annotations are also missing. It is not a big problem, but it is inconvenient.
I propose using
inspect.signatureinstead. It will allow us using pos-only and keyword-only params with ease.I have a PR ready.
Found while working on python/typeshed#10548
CC @AlexWaygood and @terryjreedy
Linked PRs
turtle#107807turtle(GH-107807) #108749