Title: [BUG] Autoreload: disabled positonal arguments cannot change their default · Issue #14145 · ipython/ipython · GitHub
Open Graph Title: [BUG] Autoreload: disabled positonal arguments cannot change their default · Issue #14145 · ipython/ipython
X Title: [BUG] Autoreload: disabled positonal arguments cannot change their default · Issue #14145 · ipython/ipython
Description: Issue Autoreload doesnt update the default values for "disabled positonal arguments" because it misses kwdefaults on list func_attrs. https://github.com/ipython/ipython/blob/main/IPython/extensions/autoreload.py#L295 Background In python...
Open Graph Description: Issue Autoreload doesnt update the default values for "disabled positonal arguments" because it misses kwdefaults on list func_attrs. https://github.com/ipython/ipython/blob/main/IPython/extensions...
X Description: Issue Autoreload doesnt update the default values for "disabled positonal arguments" because it misses kwdefaults on list func_attrs. https://github.com/ipython/ipython/blob/main/IPython/...
Opengraph URL: https://github.com/ipython/ipython/issues/14145
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[BUG] Autoreload: disabled positonal arguments cannot change their default","articleBody":"# Issue\r\n\r\nAutoreload doesnt update the default values for \"disabled positonal arguments\" because it misses __kwdefaults__ on list func_attrs.\r\nhttps://github.com/ipython/ipython/blob/main/IPython/extensions/autoreload.py#L295\r\n\r\n\r\n# Background\r\n\r\nIn python3 you can disable positonal arguments by using a \"naked star\" in the signature.\r\nthis is called reqkwargs (required keyword arguments).\r\nsee slide 21 of https://www.asmeurer.com/python3-presentation/python3-presentation.pdf\r\n\r\n# Demo\r\n\r\n```\r\n$ ipython --profile=default\r\n%load_ext autoreload\r\n%autoreload 3\r\n\r\nwith open('tmp.py', 'w') as f:\r\n f.write('def f(*, a=1): return a')\r\nimport tmp\r\n\r\nprint(tmp.f())\r\nwith open('tmp.py', 'w') as f:\r\n f.write('def f(*, a=2): return a')\r\nprint(tmp.f())\r\n```\r\n\r\n# Actual Output\r\n\r\n```\r\nPython 3.6.9 (default, Nov 25 2022, 14:10:45)\r\nType 'copyright', 'credits' or 'license' for more information\r\nIPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.\r\n\r\n1\r\n1\r\n```\r\n\r\n# Expected Output\r\n\r\n```\r\n1\r\n2\r\n```\r\n\r\n\r\n# Solution\r\n\r\nThe fix is simply to add the \"kwdefaults\" attribute to func_attrs dict in \r\n $VENV/lib/python3.9/site-packages/IPython/extensions/autoreload.py , around line 282\r\nhttps://github.com/ipython/ipython/blob/main/IPython/extensions/autoreload.py#L295\r\n\r\n```\r\nfunc_attrs = [\r\n \"__code__\",\r\n \"__defaults__\", # \u003c\u003c\u003c\u003c\u003c regular keyword arguments go here\r\n \"__doc__\",\r\n \"__closure__\",\r\n \"__globals__\",\r\n \"__dict__\",\r\n \"__kwdefaults__\", # \u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c just add this line to \"IPython/extensions/autoreload.py#L282\"\r\n]\r\n```","author":{"url":"https://github.com/pestrela","@type":"Person","name":"pestrela"},"datePublished":"2023-08-27T23:06:52Z","url":"https://github.com/ipython/ipython/issues/14145"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:6dc4e490-64a9-26a3-1fd9-323ebd806665 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9246:3C21B:8F18A0:BAB42A:6B00DDC6 |
| html-safe-nonce | 62829c7270a994203e64814f4e86cc320e50aaa5d98ec17e6d69088c2b65836e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjQ2OjNDMjFCOjhGMThBMDpCQUI0MkE6NkIwMEREQzYiLCJ2aXNpdG9yX2lkIjoiMjQ2NzgyNzQ3NDk0NDI4NjE1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 094075938463805ccc3b2f53266aef2f8d27f6a0c76caa2dff027e6df2c6c8aa |
| hovercard-subject-tag | issue:1868664949 |
| 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/ipython/ipython/14145/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8b2e626116fe0bcad175a9996557cb07b5770acc0cb91d9ec3eecb01b62c15bf/ipython/ipython/issues/14145 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8b2e626116fe0bcad175a9996557cb07b5770acc0cb91d9ec3eecb01b62c15bf/ipython/ipython/issues/14145 |
| og:image:alt | Issue Autoreload doesnt update the default values for "disabled positonal arguments" because it misses kwdefaults on list func_attrs. https://github.com/ipython/ipython/blob/main/IPython/extensions... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pestrela |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/ipython/ipython git https://github.com/ipython/ipython.git |
| octolytics-dimension-user_id | 230453 |
| octolytics-dimension-user_login | ipython |
| octolytics-dimension-repository_id | 658518 |
| octolytics-dimension-repository_nwo | ipython/ipython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 658518 |
| octolytics-dimension-repository_network_root_nwo | ipython/ipython |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width