Title: Document typeshed better: a mypy upgrade suddenly triggers new errors due to typeshed changes · Issue #7735 · python/typeshed · GitHub
Open Graph Title: Document typeshed better: a mypy upgrade suddenly triggers new errors due to typeshed changes · Issue #7735 · python/typeshed
X Title: Document typeshed better: a mypy upgrade suddenly triggers new errors due to typeshed changes · Issue #7735 · python/typeshed
Description: I just updated MyPy in Jinja, and had to ignore the return type of sum in one of my functions because MyPy started saying it wasn't compatible with the TypeVar I was using. pallets/jinja@a24df26 I see a recent change related to the retur...
Open Graph Description: I just updated MyPy in Jinja, and had to ignore the return type of sum in one of my functions because MyPy started saying it wasn't compatible with the TypeVar I was using. pallets/jinja@a24df26 I ...
X Description: I just updated MyPy in Jinja, and had to ignore the return type of sum in one of my functions because MyPy started saying it wasn't compatible with the TypeVar I was using. pallets/jinja@a24df2...
Opengraph URL: https://github.com/python/typeshed/issues/7735
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Document typeshed better: a mypy upgrade suddenly triggers new errors due to typeshed changes","articleBody":"I just updated MyPy in Jinja, and had to ignore the return type of `sum` in one of my functions because MyPy started saying it wasn't compatible with the `TypeVar` I was using. https://github.com/pallets/jinja/commit/a24df26d54fa2ccbe9bdaa0bb9419075a00e2699\r\n\r\nI see a recent change related to the return type of `sum`: https://github.com/python/typeshed/pull/7578. Is this a bug in typeshed/mypy, or is there a better way I should be annotating that function in Jinja?\r\n\r\n```python\r\nV = t.TypeVar(\"V\")\r\n\r\ndef sync_do_sum(\r\n environment: \"Environment\",\r\n iterable: \"t.Iterable[V]\",\r\n attribute: t.Optional[t.Union[str, int]] = None,\r\n start: V = 0, # type: ignore\r\n) -> V:\r\n if attribute is not None:\r\n iterable = map(make_attrgetter(environment, attribute), iterable)\r\n\r\n return sum(iterable, start) # type: ignore[no-any-return, call-overload]\r\n```\r\n\r\n```\r\nsrc/jinja2/filters.py:1295: error: Returning Any from function declared to return \"V\" [no-any-return]\r\nsrc/jinja2/filters.py:1295: error: No overload variant of \"sum\" matches argument types \"Iterable[V]\", \"V\" [call-overload]\r\nsrc/jinja2/filters.py:1295: note: Possible overload variants:\r\nsrc/jinja2/filters.py:1295: note: def [_SumT \u003c: _SupportsSum] sum(Iterable[_SumT]) -> Union[_SumT, Literal[0]]\r\nsrc/jinja2/filters.py:1295: note: def [_SumT \u003c: _SupportsSum, _SumS \u003c: _SupportsSum] sum(Iterable[_SumT], _SumS) -> Union[_SumT, _SumS]\r\nFound 2 errors in 1 file (checked 25 source files)\r\n```","author":{"url":"https://github.com/davidism","@type":"Person","name":"davidism"},"datePublished":"2022-04-28T14:51:59Z","url":"https://github.com/python/typeshed/issues/7735"}
| 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:5c168e71-be6d-6e60-1b39-17ec82c155d4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A10:1DF7D7:75A33:A3C53:6B00511C |
| html-safe-nonce | 2d8531c034c1c52cbd14c4657c35a55961c821f71b86cb93157bd808d790c754 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTEwOjFERjdENzo3NUEzMzpBM0M1Mzo2QjAwNTExQyIsInZpc2l0b3JfaWQiOiI1NjgxOTUwMzAzNjkyMjgwMDkyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a2369c075e154c7c360033aef0141de5c7bf79734de04739ebd142cc5ee1ff56 |
| hovercard-subject-tag | issue:1218854920 |
| 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/7735/issue_layout |
| twitter:image | https://opengraph.githubassets.com/041e59aa7fa6b3df412bf7c2ffd4a77821d1a5edf0727e939bccaaaa5fae6287/python/typeshed/issues/7735 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/041e59aa7fa6b3df412bf7c2ffd4a77821d1a5edf0727e939bccaaaa5fae6287/python/typeshed/issues/7735 |
| og:image:alt | I just updated MyPy in Jinja, and had to ignore the return type of sum in one of my functions because MyPy started saying it wasn't compatible with the TypeVar I was using. pallets/jinja@a24df26 I ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | davidism |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width