Title: bpo-43224: Fix Tuple[()].__args__ by mrahtz · Pull Request #31845 · python/cpython · GitHub
Open Graph Title: bpo-43224: Fix Tuple[()].__args__ by mrahtz · Pull Request #31845 · python/cpython
X Title: bpo-43224: Fix Tuple[()].__args__ by mrahtz · Pull Request #31845 · python/cpython
Description: Here's a fun inconsistency: >>> Tuple[()].__args__ ((),) >>> tuple[()].__args__ () Even though there's an explicit test for the former behaviour, I don't think it's right: Argument 1: If foo.__args__ is (bar,), that says that foo is being parameterised by bar. When we do Tuple[()], it's really just to get around the fact that Tuple[] is invalid syntax - what we're really meaning to say is that we're not parameterising it with anything. Tuple[()].__args__ should therefore be empty. Argument 2: Everything in Tuple[...].__args__ should be a type. () is not a type. This matters for PEP 646, where we were expecting that a TypeVarTuple with no arguments would expand to nothing rather than (). If we were to change things so it was consistent with the current behaviour of Tuple[()], we'd have T = TypeVar('T') Ts = TypeVarTuple('Ts') class C(Generic[T, *Ts]): pass Alias = C[int, *Ts] Alias[()] # C[int, ()] which definitely isn't what we want. @ilevkivskyi who added the test for the former behaviour, according to the git blame. Is there something I'm missing here? https://bugs.python.org/issue43224
Open Graph Description: Here's a fun inconsistency: >>> Tuple[()].__args__ ((),) >>> tuple[()].__args__ () Even though there's an explicit test for the former behaviour, I don't think it'...
X Description: Here's a fun inconsistency: >>> Tuple[()].__args__ ((),) >>> tuple[()].__args__ () Even though there's an explicit test for the former beha...
Opengraph URL: https://github.com/python/cpython/pull/31845
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:4935d2c6-8ecf-42fb-0e62-093c98c40922 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B8D0:14FC13:1D232E8:269DC83:696AFE46 |
| html-safe-nonce | e5cea072bc6f4085f6ee0c90dbf8bdca7423f8aef283bd8bc0db254203258371 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEQwOjE0RkMxMzoxRDIzMkU4OjI2OURDODM6Njk2QUZFNDYiLCJ2aXNpdG9yX2lkIjoiNDUxOTE5ODAwNTQ2NTM4MjQ3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 94114eef72f6d146080a815d22c01f485b667a638ce0057233fffde2f81cee7f |
| hovercard-subject-tag | pull_request:878385732 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/31845/files |
| twitter:image | https://avatars.githubusercontent.com/u/4431336?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4431336?s=400&v=4 |
| og:image:alt | Here's a fun inconsistency: >>> Tuple[()].__args__ ((),) >>> tuple[()].__args__ () Even though there's an explicit test for the former behaviour, I don't think it'... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width