Title: `pow(complex(…),
Open Graph Title: `pow(complex(…),
X Title: `pow(complex(…),
Description: complex's versions of __pow__ and __rpow__ invite the third modulo argument. That means that the following validates, when it shouldn't: This applies to floats as well. pow(complex(1), 2, 2) # no type error? pow(float(1), 2, 2) # still n...
Open Graph Description: complex's versions of __pow__ and __rpow__ invite the third modulo argument. That means that the following validates, when it shouldn't: This applies to floats as well. pow(complex(1), 2, 2) # no t...
X Description: complex's versions of __pow__ and __rpow__ invite the third modulo argument. That means that the following validates, when it shouldn't: This applies to floats as well. pow(complex(1), 2, 2...
Opengraph URL: https://github.com/python/typeshed/issues/6303
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`pow(complex(…), \u003cvalue>, \u003cvalue>)` and `pow(float(…), \u003cvalue>, \u003cvalue>)` should produce type errors","articleBody":"`complex`'s versions of [`__pow__`](https://github.com/python/typeshed/blob/aa7e277adb9049e24ea3434fc9848defbfa87673/stdlib/builtins.pyi#L335) and `__rpow__` invite the third modulo argument. That means that the following validates, when it shouldn't:\r\n\r\nThis [applies to `float`s](https://github.com/python/typeshed/blob/aa7e277adb9049e24ea3434fc9848defbfa87673/stdlib/builtins.pyi#L285) as well.\r\n\r\n``` python\r\npow(complex(1), 2, 2) # no type error?\r\npow(float(1), 2, 2) # still no type error?\r\n```\r\n\r\nThese are guaranteed to fail at runtime, even if the first arguments are losslessly convertible to `int`s:\r\n\r\n``` python\r\n>>> pow(complex(1), 2, 2)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin>\", line 1, in \u003cmodule>\r\nValueError: complex modulo\r\n>>> pow(float(1), 2, 2)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin>\", line 1, in \u003cmodule>\r\nTypeError: pow() 3rd argument not allowed unless all arguments are integers\r\n```\r\n\r\nI can't find an issue tracking this, and I don't _think_ this is fixed by #6287.\r\n\r\n---\r\n\r\nAs an aside, this \"works\" (in the sense it properly generates _some_ error, but not what I would expect):\r\n\r\n``` python\r\nfrom numbers import Complex\r\nmy_complex: Complex = complex(1) # type: ignore [assignment] # see 3186\r\npow(my_complex, 2, 2) # No overload variant of \"pow\" matches argument types \"Complex\", \"int\", \"int\"\r\n```\r\n\r\nThat second error might just be some variation on python/mypy#3186, however?","author":{"url":"https://github.com/posita","@type":"Person","name":"posita"},"datePublished":"2021-11-15T17:40:16Z","url":"https://github.com/python/typeshed/issues/6303"}
| 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:06a54d41-28e4-20b5-41f0-00c292cd4749 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D93A:2C0A92:2D8420F:3BE07E4:6B001BFA |
| html-safe-nonce | c291a80063c820533848af2f0499f7ef54d16a9dd8b330b7b24f2d4a6dfd6d81 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTNBOjJDMEE5MjoyRDg0MjBGOjNCRTA3RTQ6NkIwMDFCRkEiLCJ2aXNpdG9yX2lkIjoiNzY1ODA5MzIxNTAzNTE2OTc4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1eb880393d589713edb6d79acd4ddc99c2811c9a9e38ec80cc9770f37615e5ff |
| hovercard-subject-tag | issue:1053928823 |
| 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/typeshed/6303/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8d9b15bd9ec36f3ff2f7530f7c78924b827d18adcfee9b50ddcd52750deb12ef/python/typeshed/issues/6303 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8d9b15bd9ec36f3ff2f7530f7c78924b827d18adcfee9b50ddcd52750deb12ef/python/typeshed/issues/6303 |
| og:image:alt | complex's versions of __pow__ and __rpow__ invite the third modulo argument. That means that the following validates, when it shouldn't: This applies to floats as well. pow(complex(1), 2, 2) # no t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | posita |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width