Title: False negative with a constrained generic type in the presence of `Any` · Issue #9186 · python/mypy · GitHub
Open Graph Title: False negative with a constrained generic type in the presence of `Any` · Issue #9186 · python/mypy
X Title: False negative with a constrained generic type in the presence of `Any` · Issue #9186 · python/mypy
Description: from typing import Any, AnyStr def foo(arg1: AnyStr, arg2: AnyStr) -> None: ... bar: Any = "" foo(1, "") # Error correctly reported foo(b"", bar) # No error (correct) foo(1, bar) # No error (false negative) In the presence of Any, I woul...
Open Graph Description: from typing import Any, AnyStr def foo(arg1: AnyStr, arg2: AnyStr) -> None: ... bar: Any = "" foo(1, "") # Error correctly reported foo(b"", bar) # No error (correct) foo(1, bar) # No error (false ...
X Description: from typing import Any, AnyStr def foo(arg1: AnyStr, arg2: AnyStr) -> None: ... bar: Any = "" foo(1, "") # Error correctly reported foo(b"", bar) # No error (correc...
Opengraph URL: https://github.com/python/mypy/issues/9186
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False negative with a constrained generic type in the presence of `Any`","articleBody":"```python\r\nfrom typing import Any, AnyStr\r\ndef foo(arg1: AnyStr, arg2: AnyStr) -> None: ...\r\nbar: Any = \"\"\r\nfoo(1, \"\") # Error correctly reported\r\nfoo(b\"\", bar) # No error (correct)\r\nfoo(1, bar) # No error (false negative)\r\n```\r\n\r\nIn the presence of `Any`, I would expect mypy to allow any of the values of the constraint (in this case, `str` or `bytes`), but not any arbitrary type.\r\n\r\nPlayground link: https://mypy-play.net/?mypy=latest&python=3.8&flags=strict&gist=6970b49fa90d7767b0ef26c9f977e182\r\n","author":{"url":"https://github.com/russelldavis","@type":"Person","name":"russelldavis"},"datePublished":"2020-07-21T18:40:52Z","url":"https://github.com/python/mypy/issues/9186"}
| 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:aa52f677-9d82-3db2-803e-6f1521b9704b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7F6:7F150:12F02EC:18DADEE:6B000695 |
| html-safe-nonce | 7853bbe9c3c67349009fc7a007652d4926611d6e0f4dd9db2358c7516d3a600e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0Y2OjdGMTUwOjEyRjAyRUM6MThEQURFRTo2QjAwMDY5NSIsInZpc2l0b3JfaWQiOiI3NzAyMzQwNjU5NjA4MjkwOTY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | bcafa1d310c8f9b76b0d6205652da053e1dd48fd8dac14822652dfffddc2de3d |
| hovercard-subject-tag | issue:663227831 |
| 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/9186/issue_layout |
| twitter:image | https://opengraph.githubassets.com/64b7b6fe501b9088b3d1e8de740da50dbf8a21034fb7a0db7dfc333ac12eb102/python/mypy/issues/9186 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/64b7b6fe501b9088b3d1e8de740da50dbf8a21034fb7a0db7dfc333ac12eb102/python/mypy/issues/9186 |
| og:image:alt | from typing import Any, AnyStr def foo(arg1: AnyStr, arg2: AnyStr) -> None: ... bar: Any = "" foo(1, "") # Error correctly reported foo(b"", bar) # No error (correct) foo(1, bar) # No error (false ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | russelldavis |
| 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