Title: Importing generic type aliases · Issue #2887 · python/mypy · GitHub
Open Graph Title: Importing generic type aliases · Issue #2887 · python/mypy
X Title: Importing generic type aliases · Issue #2887 · python/mypy
Description: lib.py: from typing import Callable, TypeVar, Tuple T = TypeVar('T') R = TypeVar('R') Transform = Callable[[T, int], Tuple[T, R]] main.py: from typing import Tuple from lib import Transform def int_tf(m: int) -> Transform[int, str]: # Ba...
Open Graph Description: lib.py: from typing import Callable, TypeVar, Tuple T = TypeVar('T') R = TypeVar('R') Transform = Callable[[T, int], Tuple[T, R]] main.py: from typing import Tuple from lib import Transform def int...
X Description: lib.py: from typing import Callable, TypeVar, Tuple T = TypeVar('T') R = TypeVar('R') Transform = Callable[[T, int], Tuple[T, R]] main.py: from typing import Tuple from lib import T...
Opengraph URL: https://github.com/python/mypy/issues/2887
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Importing generic type aliases","articleBody":"`lib.py`:\r\n```python\r\nfrom typing import Callable, TypeVar, Tuple\r\n\r\nT = TypeVar('T')\r\nR = TypeVar('R')\r\n\r\nTransform = Callable[[T, int], Tuple[T, R]]\r\n```\r\n`main.py`:\r\n\r\n```python\r\nfrom typing import Tuple\r\nfrom lib import Transform\r\n\r\n\r\ndef int_tf(m: int) -> Transform[int, str]: # Bad number of arguments for type alias, expected: 0, given: 2\r\n def transform(i: int, pos: int) -> Tuple[int, str]:\r\n a = (i + pos) % m # Name 'T' is not defined Name 'R' is not defined\r\n return (a, 'ok')\r\n\r\n return transform\r\n```\r\n\r\nIt works when an alias is defined in the same file","author":{"url":"https://github.com/dmzkrsk","@type":"Person","name":"dmzkrsk"},"datePublished":"2017-02-21T09:06:20Z","url":"https://github.com/python/mypy/issues/2887"}
| 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:2f90acf8-8b42-ea5a-e21c-72b712186d1c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD6A:59CDA:2820141:343FE20:6B00039E |
| html-safe-nonce | f31665150ed3ac611b79a42827c848ad82e4bcb9c3a6658a425babd5853dcea1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDZBOjU5Q0RBOjI4MjAxNDE6MzQzRkUyMDo2QjAwMDM5RSIsInZpc2l0b3JfaWQiOiI1NjI5NDgyNjgyNTU2NjEzNTM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6743a069e4f9831883f8544c1c7af535daa4da8bedb4f305964a76dcca80698f |
| hovercard-subject-tag | issue:209081151 |
| 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/2887/issue_layout |
| twitter:image | https://opengraph.githubassets.com/20ffba6e09b56467744e63fecbdf2ada5bd1e29444b3b49c7274db6212b43b8f/python/mypy/issues/2887 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/20ffba6e09b56467744e63fecbdf2ada5bd1e29444b3b49c7274db6212b43b8f/python/mypy/issues/2887 |
| og:image:alt | lib.py: from typing import Callable, TypeVar, Tuple T = TypeVar('T') R = TypeVar('R') Transform = Callable[[T, int], Tuple[T, R]] main.py: from typing import Tuple from lib import Transform def int... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dmzkrsk |
| 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