-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
turtle.teleport
has incorrect-ish signature
#107805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@gpshead merged the PR. inspect.getargs it not currently documented, likely because it was replaced by inspect.getfullargspec when keyword-only args were added. The latter was replaced by inspect.signature, but kept for 2.x compatibility for 2.x/3.x code. Turtle should definitely be updated to use inspect.signature. Separate issues: I suspect the same would be true of any stdlib code using either getargs or getfullargspec. We should probably deprecate and remove getargs and maybe eventually getfullargspec. The getargs call is part of |
FWIW the bug in the PR adding teleport was added by me as I decided fill_gap should be keyword only for a more readable API feel, without realizing that such gross hacks existed elsewhere within turtle that relied on |
…tle` (#107807) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…n `turtle` (pythonGH-107807) (cherry picked from commit 044b8b3) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Bug report
turtle.teleport
added in #103974 seems not quite correct.Why?
Turtle.teleport
instance method. It has this signature:def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None:
turtle.teleport
has this signature:def teleport(x, y=None, fill_gap=None)
Notice that it is missing
x=None
default and for some reasonfill_gap
is 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.teleport
I get:And with just one arg:
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
turtle
#107807turtle
(GH-107807) #108749The text was updated successfully, but these errors were encountered: