Title: Modernize `test_inspect` by adding real pos-only parameters · Issue #103406 · python/cpython · GitHub
Open Graph Title: Modernize `test_inspect` by adding real pos-only parameters · Issue #103406 · python/cpython
X Title: Modernize `test_inspect` by adding real pos-only parameters · Issue #103406 · python/cpython
Description: Right now test_inspect uses several hacks to pretend that some parameters are positional only: cpython/Lib/test/test_inspect.py Lines 2465 to 2469 in ecad802 def test(po, pk, pod=42, pkd=100, *args, ko, **kwargs): pass sig = inspect.sign...
Open Graph Description: Right now test_inspect uses several hacks to pretend that some parameters are positional only: cpython/Lib/test/test_inspect.py Lines 2465 to 2469 in ecad802 def test(po, pk, pod=42, pkd=100, *args...
X Description: Right now test_inspect uses several hacks to pretend that some parameters are positional only: cpython/Lib/test/test_inspect.py Lines 2465 to 2469 in ecad802 def test(po, pk, pod=42, pkd=100, *args...
Opengraph URL: https://github.com/python/cpython/issues/103406
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Modernize `test_inspect` by adding real pos-only parameters","articleBody":"Right now `test_inspect` uses several hacks to pretend that some parameters are positional only:\r\n\r\nhttps://github.com/python/cpython/blob/ecad802e3f9ef7063e7d7fe9f0c037561396ef8e/Lib/test/test_inspect.py#L2465-L2469\r\n\r\nhttps://github.com/python/cpython/blob/ecad802e3f9ef7063e7d7fe9f0c037561396ef8e/Lib/test/test_inspect.py#L2519-L2522\r\n\r\nhttps://github.com/python/cpython/blob/ecad802e3f9ef7063e7d7fe9f0c037561396ef8e/Lib/test/test_inspect.py#L3047-L3052\r\n\r\nhttps://github.com/python/cpython/blob/ecad802e3f9ef7063e7d7fe9f0c037561396ef8e/Lib/test/test_inspect.py#L3559-L3565\r\n\r\nhttps://github.com/python/cpython/blob/ecad802e3f9ef7063e7d7fe9f0c037561396ef8e/Lib/test/test_inspect.py#L4160-L4166\r\n\r\nAnd maybe others.\r\n\r\nIt makes code more complex, unclear, and hides the real purpose of these tests.\r\n\r\nThis is not a design decision, but rather a limitation at the time. Commits are quite old and pos-only syntax was not available 9 and 11 years ago: \r\n- https://github.com/python/cpython/commit/3f73ca23cfe4e4058689bc5a46622c68ef1b6aa6\r\n- https://github.com/python/cpython/commit/7c7cbfc00fc8d655fc267ff57f8084357858b1db\r\n\r\nSo, I propose to simplify these tests and make them more correct by using explicit pos only parameters. \r\n\r\nPlus, we can keep one test like this to be sure that chaning a parameter kind still works as before. But, there's no need in keeping these old tests the way they are.\r\n\r\nI will send a PR with the fix 👍 \n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-103407\n* gh-103536\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2023-04-10T08:14:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/103406/cpython/issues/103406"}
| 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:309cf10a-35e1-d109-a38a-0941b50a2efd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C382:22F528:477041:64C4DB:696A2168 |
| html-safe-nonce | cd06dc54ad92ae963b3df865353373c81515399ee710b61e0695d5677c5026a2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzgyOjIyRjUyODo0NzcwNDE6NjRDNERCOjY5NkEyMTY4IiwidmlzaXRvcl9pZCI6IjM2NTcwNTE1NTkyMzM3MjQ3NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b302710271ec82b8101c26e708c31e25b0f399ea1293d1d10226d16d98eedb6b |
| hovercard-subject-tag | issue:1660424381 |
| 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/103406/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f448692d5e0d862b77aa4d79514637a4933d0a8614e4efbc636b9902768df2b2/python/cpython/issues/103406 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f448692d5e0d862b77aa4d79514637a4933d0a8614e4efbc636b9902768df2b2/python/cpython/issues/103406 |
| og:image:alt | Right now test_inspect uses several hacks to pretend that some parameters are positional only: cpython/Lib/test/test_inspect.py Lines 2465 to 2469 in ecad802 def test(po, pk, pod=42, pkd=100, *args... |
| 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 | 014f3d193f36b7d393f88ca22d06fbacd370800b40a547c1ea67291e02dc8ea3 |
| 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 | d515f6f09fa57a93bf90355cb894eb84ca4f458f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width