Title: [1.20 regression] Inconsistent narroving for unions involving Any · Issue #21364 · python/mypy · GitHub
Open Graph Title: [1.20 regression] Inconsistent narroving for unions involving Any · Issue #21364 · python/mypy
X Title: [1.20 regression] Inconsistent narroving for unions involving Any · Issue #21364 · python/mypy
Description: Consider this example: from typing import Any class B: x: int class C(B): y: int x: B | int y: C | Any assert x == y reveal_type(x) # Revealed type is "test.B | int", OK reveal_type(y) # Revealed type is "Any | test.B | int", why??? y.y ...
Open Graph Description: Consider this example: from typing import Any class B: x: int class C(B): y: int x: B | int y: C | Any assert x == y reveal_type(x) # Revealed type is "test.B | int", OK reveal_type(y) # Revealed t...
X Description: Consider this example: from typing import Any class B: x: int class C(B): y: int x: B | int y: C | Any assert x == y reveal_type(x) # Revealed type is "test.B | int", OK reveal_type(y) # ...
Opengraph URL: https://github.com/python/mypy/issues/21364
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[1.20 regression] Inconsistent narroving for unions involving Any","articleBody":"Consider this example:\n```python\nfrom typing import Any\n\nclass B:\n x: int\n\nclass C(B):\n y: int\n\nx: B | int\ny: C | Any\n\nassert x == y\nreveal_type(x) # Revealed type is \"test.B | int\", OK\nreveal_type(y) # Revealed type is \"Any | test.B | int\", why???\ny.y # Error here, previously this worked.\n```\ncc @hauntsaninja I didn't bisect, but there is high chance this may be caused by one of the recent narrowing changes.","author":{"url":"https://github.com/ilevkivskyi","@type":"Person","name":"ilevkivskyi"},"datePublished":"2026-04-29T00:27:45Z","url":"https://github.com/python/mypy/issues/21364"}
| 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:a3a9061e-c79b-54f0-cb4b-87f93259d3ff |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 90D2:3A13A0:205B916:2BD5C66:6B001CF9 |
| html-safe-nonce | 3459c333f766e2cd124b31aa73a2943f352b01ccca56169661a0f691b8a3d70f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MEQyOjNBMTNBMDoyMDVCOTE2OjJCRDVDNjY6NkIwMDFDRjkiLCJ2aXNpdG9yX2lkIjoiMjAzNzE5OTg4NDc1MDE2NzI4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e74bfb5024e7549ea267828faeacb2d9f34e35895701b1f78888f7997966f94b |
| hovercard-subject-tag | issue:4347091921 |
| 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/21364/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b696cb9468f20e9d05f28f1ab5f66e99a8c530ae8d4e70fa46a000f35ac1c976/python/mypy/issues/21364 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b696cb9468f20e9d05f28f1ab5f66e99a8c530ae8d4e70fa46a000f35ac1c976/python/mypy/issues/21364 |
| og:image:alt | Consider this example: from typing import Any class B: x: int class C(B): y: int x: B | int y: C | Any assert x == y reveal_type(x) # Revealed type is "test.B | int", OK reveal_type(y) # Revealed t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilevkivskyi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width