Title: MyPy disallows Tuple to be instantiated with variable number of items · Issue #8758 · python/mypy · GitHub
Open Graph Title: MyPy disallows Tuple to be instantiated with variable number of items · Issue #8758 · python/mypy
X Title: MyPy disallows Tuple to be instantiated with variable number of items · Issue #8758 · python/mypy
Description: Tuple in Python - is a fixed-length list ("frozen list"). But there's nothing in Python that prevents same-name Tuple to be instantiated with different number of items (which may well be based on some condition)... I have an issue relate...
Open Graph Description: Tuple in Python - is a fixed-length list ("frozen list"). But there's nothing in Python that prevents same-name Tuple to be instantiated with different number of items (which may well be based on s...
X Description: Tuple in Python - is a fixed-length list ("frozen list"). But there's nothing in Python that prevents same-name Tuple to be instantiated with different number of items (which may well...
Opengraph URL: https://github.com/python/mypy/issues/8758
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MyPy disallows Tuple to be instantiated with variable number of items","articleBody":"Tuple in Python - is a fixed-length list (\"frozen list\"). But there's nothing in Python that prevents same-name Tuple to be instantiated with different number of items (which may well be based on some condition)...\r\n\r\nI have an issue related to mypy, conditional import and validation of the ___all_ package attribute (defined as a Tuple containing variable number of items depending on the success of the conditional import). Consider following within package's __init__.py:\r\n\r\n```\r\ntry:\r\n from .__version__ import version as __version__\r\n __all__ = (\r\n '...........',\r\n '...........',\r\n '...........',\r\n '__version__'\r\n )\r\nexcept ImportError:\r\n __all__ = (\r\n '...........',\r\n '...........',\r\n '...........'\r\n )\r\n\r\n```\r\n\r\nWhen this code is checked by mypy, it raises following error:\r\n\r\n```\r\n______________________________ units/__init__.py _______________________________\r\n15: error: Incompatible types in assignment (expression has type \"Tuple[str, str, str]\", variable has type \"Tuple[str, str, str, str]\")\r\n_________________________________ test session _________________________________\r\nmypy exited with status 1.\r\n=============================== warnings summary ===============================\r\n```\r\n\r\nThis issue keeps me from building Python package in the presence of 'mypy' check; I had to explicitly disable mypy check in order to build this package. \r\n\r\nI'd like to have mypy recognize possibility of variable-size Tuple in the presence of conditional import (and in general - same-name Tuple can be instantiated having different size depending on some conditions), or be able to ignore this error (unfortunately, mypy output does not report error number that can be ignored), or entirely exclude given file from mypy check (similarly to flake8's \"exclude\" in the setup.cfg).","author":{"url":"https://github.com/vpogrebi","@type":"Person","name":"vpogrebi"},"datePublished":"2020-05-01T14:25:23Z","url":"https://github.com/python/mypy/issues/8758"}
| 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:f6039020-3121-51e8-af6d-be18a262e3d1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A6AE:5875E:1C87CAC:2690560:6B000843 |
| html-safe-nonce | be46b532b82982341e1ab75301492bc9306fa7220f0e22ba6dfe32840f3556be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkFFOjU4NzVFOjFDODdDQUM6MjY5MDU2MDo2QjAwMDg0MyIsInZpc2l0b3JfaWQiOiI3MjUzMTY1MzkwNTg1Mzk5MzYzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dccf3397babaef66806bf99370f194836586065426935a5c8121afb0dc6ba245 |
| hovercard-subject-tag | issue:610777420 |
| 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/8758/issue_layout |
| twitter:image | https://opengraph.githubassets.com/faf32de38243393bac09fa3fedd4d1241726b8864c24b721a8d62c68300e4a18/python/mypy/issues/8758 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/faf32de38243393bac09fa3fedd4d1241726b8864c24b721a8d62c68300e4a18/python/mypy/issues/8758 |
| og:image:alt | Tuple in Python - is a fixed-length list ("frozen list"). But there's nothing in Python that prevents same-name Tuple to be instantiated with different number of items (which may well be based on s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vpogrebi |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width