Title: Spurious error with dynamic keyword arguments · Issue #9676 · python/mypy · GitHub
Open Graph Title: Spurious error with dynamic keyword arguments · Issue #9676 · python/mypy
X Title: Spurious error with dynamic keyword arguments · Issue #9676 · python/mypy
Description: Bug Report The expression datetime.timedelta(**{"seconds": 1.0}) works correctly in python, but mypy reports it as an error if the python-version parameter is 3.6 or greater. (note that the typeshed definition of timedelta.__init__ is co...
Open Graph Description: Bug Report The expression datetime.timedelta(**{"seconds": 1.0}) works correctly in python, but mypy reports it as an error if the python-version parameter is 3.6 or greater. (note that the typeshe...
X Description: Bug Report The expression datetime.timedelta(**{"seconds": 1.0}) works correctly in python, but mypy reports it as an error if the python-version parameter is 3.6 or greater. (note that t...
Opengraph URL: https://github.com/python/mypy/issues/9676
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Spurious error with dynamic keyword arguments","articleBody":"\u003c!--\r\n If you're new to mypy and you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form\r\n instead.\r\n-->\r\n\r\n**Bug Report**\r\n\r\n\u003c!--\r\nNote: If the problem you are reporting is about a specific library function, then the typeshed tracker is better suited\r\nfor this report: https://github.com/python/typeshed/issues\r\n-->\r\n\r\nThe expression `datetime.timedelta(**{\"seconds\": 1.0})` works correctly in python, but mypy reports it as an error *if* the `python-version` parameter is 3.6 or greater. (note that the [typeshed definition of `timedelta.__init__` ](https://github.com/python/typeshed/blob/301325b55b1d523c67056be606d0bf771ca5551c/stdlib/2and3/datetime.pyi#L160-L183) is conditioned on the python version, which explains why that parameter has this effect)\r\n\r\n**To Reproduce**\r\n\r\n`test.py`:\r\n```\r\nimport datetime\r\n\r\ndatetime.timedelta(**{\"seconds\": 1.0})\r\n```\r\n\r\nRun `mypy --python-version 3.5 test.py` and `mypy --python-version 3.6 test.py`\r\n\r\n\r\n**Actual Behavior**\r\n\r\n\u003c!--\r\n Did something go wrong?\r\n Is something broken, or not behaving as you expected?\r\n-->\r\n\r\nWith `--python-version 3.5`, there are no errors. With `--python-version 3.6`, it reports:\r\n\r\n```\r\ntest.py:3: error: Argument 1 to \"timedelta\" has incompatible type \"**Dict[str, float]\"; expected \"int\"\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\n**Your Environment**\r\n\r\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n- Mypy version used: tested both 0.740 and 0.790\r\n- Mypy command-line flags: `--python-version`\r\n- Mypy configuration options from `mypy.ini` (and other config files): none\r\n- Python version used: 3.8\r\n- Operating system and version: linux \r\n\r\nMinimal test case: https://repl.it/@bdarnell/mypy-dynamic-keyword-args-bug-report\r\nCI build in which this was initially discovered: https://travis-ci.org/github/tornadoweb/tornado/jobs/740396440\r\n\r\n\u003c!--\r\nYou can freely edit this text, please remove all the lines\r\nyou believe are unnecessary.\r\n-->\r\n","author":{"url":"https://github.com/bdarnell","@type":"Person","name":"bdarnell"},"datePublished":"2020-10-31T11:56:44Z","url":"https://github.com/python/mypy/issues/9676"}
| 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:d21048cb-205a-2e6d-f5c8-40aaec58cba7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBD6:302FC:3F3B87:54C857:6B002A92 |
| html-safe-nonce | 6460596b980a00bb2b43d02b78977548018c310dc8e44d7b85a11ae35f65ecd4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkQ2OjMwMkZDOjNGM0I4Nzo1NEM4NTc6NkIwMDJBOTIiLCJ2aXNpdG9yX2lkIjoiNDEzNzM2ODQ3MjIxMDM4NTU1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8d724e3116e95cd87c5f2b649c661ffdb95101b2bcdc6a01dbf5e32558c64f1a |
| hovercard-subject-tag | issue:733703360 |
| 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/mypy/9676/issue_layout |
| twitter:image | https://opengraph.githubassets.com/590ddc8585e59aef85a8c1d94ad315db0c86ba4cd1188a7b4e0d6047db8313dc/python/mypy/issues/9676 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/590ddc8585e59aef85a8c1d94ad315db0c86ba4cd1188a7b4e0d6047db8313dc/python/mypy/issues/9676 |
| og:image:alt | Bug Report The expression datetime.timedelta(**{"seconds": 1.0}) works correctly in python, but mypy reports it as an error if the python-version parameter is 3.6 or greater. (note that the typeshe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bdarnell |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width