Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
turtle.teleport added in#103974 seems not quite correct.
Why?
- It is produced automagically from
Turtle.teleportinstance method. It has this signature:def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None: - The result function
turtle.teleporthas this signature:def teleport(x, y=None, fill_gap=None)
Notice that it is missingx=None default and for some reasonfill_gap is not a kw-only anymore.
The second problem happens because inside it usesinspect.getargs:
Line 3927 in52fbcf6
| args,varargs,varkw=inspect.getargs(ob.__code__) |
So, when I try to runturtle.teleport I get:
Traceback (mostrecentcalllast):File"/Users/sobolev/Desktop/cpython/ex.py",line60,in<module>print(teleport())^^^^^^^^^^TypeError:teleport()missing1requiredpositionalargument:'x'
And with just one arg:
Traceback (mostrecentcalllast):File"/Users/sobolev/Desktop/cpython/ex.py",line60,in<module>print(teleport(1))^^^^^^^^^^^File"<string>",line4,inteleportTypeError:Turtle.teleport()takesfrom1to3positionalargumentsbut4weregiven
Annotations are also missing. It is not a big problem, but it is inconvenient.
I propose usinginspect.signature instead. It will allow us using pos-only and keyword-only params with ease.
I have a PR ready.
Found while working onpython/typeshed#10548
CC@AlexWaygood and@terryjreedy
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done