Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

turtle.teleport has incorrect-ish signature #107805

Closed
Assignees
sobolevn
@sobolevn

Description

@sobolevn

Bug report

turtle.teleport added in#103974 seems not quite correct.

Why?

  1. It is produced automagically fromTurtle.teleport instance method. It has this signature:def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None:
  2. The result functionturtle.teleport has 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:

args,varargs,varkw=inspect.getargs(ob.__code__)
which translates kw-only to positional-or-keyword params.

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

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp