Title: Crash on type: ignore in import · Issue #1327 · python/mypy · GitHub
Open Graph Title: Crash on type: ignore in import · Issue #1327 · python/mypy
X Title: Crash on type: ignore in import · Issue #1327 · python/mypy
Description: We have some code to the effect of if IS_LINUX: from linux_class import SomeClass elif IS_MAC: from mac_class import SomeClass elif IS_WINDOWS: from windows_class import SomeClass assert SomeClass Because SomeClass doesn't have quite the...
Open Graph Description: We have some code to the effect of if IS_LINUX: from linux_class import SomeClass elif IS_MAC: from mac_class import SomeClass elif IS_WINDOWS: from windows_class import SomeClass assert SomeClass ...
X Description: We have some code to the effect of if IS_LINUX: from linux_class import SomeClass elif IS_MAC: from mac_class import SomeClass elif IS_WINDOWS: from windows_class import SomeClass assert SomeClass ...
Opengraph URL: https://github.com/python/mypy/issues/1327
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash on type: ignore in import","articleBody":"We have some code to the effect of\n\n```\nif IS_LINUX:\n from linux_class import SomeClass\nelif IS_MAC:\n from mac_class import SomeClass\nelif IS_WINDOWS:\n from windows_class import SomeClass\n\nassert SomeClass\n```\n\nBecause SomeClass doesn't have quite the same interface in all three places, I tried to add `type: ignore` to the second and third imports. This caused the following crash while running mypy:\n\n```\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/main.py\", line 51, in main\n type_check_only(sources, bin_dir, options)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/main.py\", line 95, in type_check_only\n python_path=options.python_path)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/build.py\", line 239, in build\n result = manager.process(initial_states)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/build.py\", line 456, in process\n next.process()\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/build.py\", line 964, in process\n self.type_checker().visit_file(self.tree, self.tree.path)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/checker.py\", line 416, in visit_file\n self.accept(d)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/checker.py\", line 457, in accept\n typ = node.accept(self)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/nodes.py\", line 632, in accept\n return visitor.visit_assert_stmt(self)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/checker.py\", line 1710, in visit_assert_stmt\n self.accept(s.expr)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/checker.py\", line 457, in accept\n typ = node.accept(self)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/nodes.py\", line 902, in accept\n return visitor.visit_name_expr(self)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/checker.py\", line 1961, in visit_name_expr\n return self.expr_checker.visit_name_expr(e)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/checkexpr.py\", line 75, in visit_name_expr\n result = self.analyze_ref_expr(e)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/checkexpr.py\", line 103, in analyze_ref_expr\n result = type_object_type(node, self.named_type)\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/checkmember.py\", line 320, in type_object_type\n init_method = info.get_method('__init__')\n File \"/code/client-all/client/.mypy_lint/mypy/mypy/nodes.py\", line 1593, in get_method\n for cls in self.mro:\nTypeError: 'NoneType' object is not iterable\n```\n\nI've spent some time trying to get a small example of how to repro this, but haven't been able to yet.\n","author":{"url":"https://github.com/drewhaven","@type":"Person","name":"drewhaven"},"datePublished":"2016-04-04T22:32:23Z","url":"https://github.com/python/mypy/issues/1327"}
| 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:48d37e8c-0859-c5be-d767-4d18fb0b7450 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 85E0:144E47:2C18961:39FE620:6B00157A |
| html-safe-nonce | 4b1e8f87f777fda260c50878b509278aff0ff18ba5d1cf35cfd2772162903205 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUUwOjE0NEU0NzoyQzE4OTYxOjM5RkU2MjA6NkIwMDE1N0EiLCJ2aXNpdG9yX2lkIjoiODE3NDQ3NzMxNzcxNjg0MTg1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 68d6aa253f1f0d3d9f8ed3bf7d1e69424065d4dcfcc8e5d945d320964fd4df00 |
| hovercard-subject-tag | issue:145822520 |
| 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/1327/issue_layout |
| twitter:image | https://opengraph.githubassets.com/934aa9994dd632d0f6f05a56a409b92344300e2898f35674dc5d64e35dab7f4f/python/mypy/issues/1327 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/934aa9994dd632d0f6f05a56a409b92344300e2898f35674dc5d64e35dab7f4f/python/mypy/issues/1327 |
| og:image:alt | We have some code to the effect of if IS_LINUX: from linux_class import SomeClass elif IS_MAC: from mac_class import SomeClass elif IS_WINDOWS: from windows_class import SomeClass assert SomeClass ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | drewhaven |
| hostname | github.com |
| expected-hostname | github.com |
| None | a2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4 |
| 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 | 70121d4e855ee0bb7b75cf15d061d91f8863c0f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width