Title: `turtle.teleport` has incorrect-ish signature · Issue #107805 · python/cpython · GitHub
Open Graph Title: `turtle.teleport` has incorrect-ish signature · Issue #107805 · python/cpython
X Title: `turtle.teleport` has incorrect-ish signature · Issue #107805 · python/cpython
Description: 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: Th...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/107805
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`turtle.teleport` has incorrect-ish signature","articleBody":"\r\n# Bug report\r\n\r\n`turtle.teleport` added in https://github.com/python/cpython/pull/103974 seems not quite correct.\r\n\r\nWhy?\r\n1. It is produced automagically from `Turtle.teleport` instance method. It has this signature: `def teleport(self, x=None, y=None, *, fill_gap: bool = False) -\u003e None:`\r\n2. The result function `turtle.teleport` has this signature: `def teleport(x, y=None, fill_gap=None)`\r\n\r\nNotice that it is missing `x=None` default and for some reason `fill_gap` is not a kw-only anymore.\r\n\r\nThe second problem happens because inside it uses `inspect.getargs`: https://github.com/python/cpython/blob/52fbcf61b5a70993c2d32332ff0ad9f369d968d3/Lib/turtle.py#L3927 which translates kw-only to positional-or-keyword params.\r\n\r\nSo, when I try to run `turtle.teleport` I get:\r\n\r\n```python\r\nTraceback (most recent call last):\r\n File \"/Users/sobolev/Desktop/cpython/ex.py\", line 60, in \u003cmodule\u003e\r\n print(teleport())\r\n ^^^^^^^^^^\r\nTypeError: teleport() missing 1 required positional argument: 'x'\r\n \r\n```\r\n\r\nAnd with just one arg:\r\n\r\n```python\r\nTraceback (most recent call last):\r\n File \"/Users/sobolev/Desktop/cpython/ex.py\", line 60, in \u003cmodule\u003e\r\n print(teleport(1))\r\n ^^^^^^^^^^^\r\n File \"\u003cstring\u003e\", line 4, in teleport\r\nTypeError: Turtle.teleport() takes from 1 to 3 positional arguments but 4 were given\r\n \r\n```\r\n\r\nAnnotations are also missing. It is not a big problem, but it is inconvenient.\r\n\r\nI propose using `inspect.signature` instead. It will allow us using pos-only and keyword-only params with ease.\r\n\r\nI have a PR ready.\r\n\r\nFound while working on https://github.com/python/typeshed/pull/10548\r\nCC @AlexWaygood and @terryjreedy \n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-107807\n* gh-108749\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2023-08-09T10:34:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/107805/cpython/issues/107805"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:70d26b50-6728-15dc-8085-44d9a5f3f258 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A828:2B0FFD:97ECF:C8415:696AD159 |
| html-safe-nonce | 6378263669076ced22eaf798f347cb2720b2b44b0776b3ba04b8172e15e93c66 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODI4OjJCMEZGRDo5N0VDRjpDODQxNTo2OTZBRDE1OSIsInZpc2l0b3JfaWQiOiI2NTA3MzY0NDk2MTAyNDAzNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 39a3a66dd7606c8398080526129ef98f185eb78e84262c67d0c45711c76d572f |
| hovercard-subject-tag | issue:1842949805 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/107805/issue_layout |
| twitter:image | https://opengraph.githubassets.com/58f1e34a6a82906dc51cf7e907d2aac64482ae0dc2c7af6fd335bb32ba83ecc8/python/cpython/issues/107805 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/58f1e34a6a82906dc51cf7e907d2aac64482ae0dc2c7af6fd335bb32ba83ecc8/python/cpython/issues/107805 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | c785f4ce187e9e7331257791b36ddee01625bb8e292a9b4fe2c16d4c006abf5d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c718a376fcf780eb22089171adb84a543f660bf7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width