Title: [Regression 1.6.x -> 1.7] Invalid "Returning Any from function declared..." · Issue #16499 · python/mypy · GitHub
Open Graph Title: [Regression 1.6.x -> 1.7] Invalid "Returning Any from function declared..." · Issue #16499 · python/mypy
X Title: [Regression 1.6.x -> 1.7] Invalid "Returning Any from function declared..." · Issue #16499 · python/mypy
Description: To Reproduce from __future__ import annotations from functools import partialmethod import operator from typing import Any, Union ScalarType = Union[int, bool, float] ArrayOrScalar = Union["Array", ScalarType] class Array: def _binary_op...
Open Graph Description: To Reproduce from __future__ import annotations from functools import partialmethod import operator from typing import Any, Union ScalarType = Union[int, bool, float] ArrayOrScalar = Union["Array",...
X Description: To Reproduce from __future__ import annotations from functools import partialmethod import operator from typing import Any, Union ScalarType = Union[int, bool, float] ArrayOrScalar = Union["Ar...
Opengraph URL: https://github.com/python/mypy/issues/16499
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Regression 1.6.x -> 1.7] Invalid \"Returning Any from function declared...\"","articleBody":"**To Reproduce**\r\n\r\n```python\r\nfrom __future__ import annotations\r\nfrom functools import partialmethod\r\nimport operator\r\nfrom typing import Any, Union\r\n\r\nScalarType = Union[int, bool, float]\r\nArrayOrScalar = Union[\"Array\", ScalarType]\r\n\r\n\r\nclass Array:\r\n def _binary_op(self,\r\n op: Any,\r\n other: ArrayOrScalar,\r\n ) -> Array:\r\n\r\n return Array()\r\n\r\n __mul__ = partialmethod(_binary_op, operator.mul)\r\n\r\n\r\ndef dot(a: ArrayOrScalar, b: ArrayOrScalar) -> ArrayOrScalar:\r\n assert isinstance(a, Array)\r\n assert isinstance(b, Array)\r\n\r\n return a * b\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nType-checks correctly, as it does with 1.6.1.\r\n\r\n**Actual Behavior**\r\n\r\n```\r\n/home/andreas/tmp/mypy-array-repro.py:30: error: Returning Any from function declared to return \"Array | int | bool | float\" [no-any-return]\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.7.0 (compiled: yes)\r\n- Mypy command-line flags: `--strict`\r\n- Mypy configuration options from `mypy.ini` (and other config files): none\r\n- Python version used: 3.12","author":{"url":"https://github.com/inducer","@type":"Person","name":"inducer"},"datePublished":"2023-11-15T17:53:14Z","url":"https://github.com/python/mypy/issues/16499"}
| 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:43a3fc8f-6790-8a95-92e5-fe577ec848fe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D74C:23D776:D0B17F:1126459:6AFFFBA7 |
| html-safe-nonce | 9412be9ef5655b8e7a3e6a5f918a0866b2e236a4455394e59757ee4b67b7127d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzRDOjIzRDc3NjpEMEIxN0Y6MTEyNjQ1OTo2QUZGRkJBNyIsInZpc2l0b3JfaWQiOiIzNTg0ODU5NTU0MjIwODY2NDcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fb155a52ed8f4c252531c3ab1147f264e7c24338ff19ae2d63affcf0e137abc4 |
| hovercard-subject-tag | issue:1995260133 |
| 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/16499/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4405e07779994d6fbb2d88c383040fa4f20d985398ad72c1d21b91fd563d4901/python/mypy/issues/16499 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4405e07779994d6fbb2d88c383040fa4f20d985398ad72c1d21b91fd563d4901/python/mypy/issues/16499 |
| og:image:alt | To Reproduce from __future__ import annotations from functools import partialmethod import operator from typing import Any, Union ScalarType = Union[int, bool, float] ArrayOrScalar = Union["Array",... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | inducer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width