Title: mypy errors if file to analyze is called types.py · Issue #3173 · python/mypy · GitHub
Open Graph Title: mypy errors if file to analyze is called types.py · Issue #3173 · python/mypy
X Title: mypy errors if file to analyze is called types.py · Issue #3173 · python/mypy
Description: Example: /tmp/types.py #!/usr/bin/env python3 from typing import ( NamedTuple, ) from enum import Enum class SomeEnum(Enum): FOO = 1 BAR = 2 class ExtendedNamedTuple(NamedTuple): field: SomeEnum $ mypy --version mypy 0.510-dev-db96af3899...
Open Graph Description: Example: /tmp/types.py #!/usr/bin/env python3 from typing import ( NamedTuple, ) from enum import Enum class SomeEnum(Enum): FOO = 1 BAR = 2 class ExtendedNamedTuple(NamedTuple): field: SomeEnum $ ...
X Description: Example: /tmp/types.py #!/usr/bin/env python3 from typing import ( NamedTuple, ) from enum import Enum class SomeEnum(Enum): FOO = 1 BAR = 2 class ExtendedNamedTuple(NamedTuple): field: SomeEnum $ ...
Opengraph URL: https://github.com/python/mypy/issues/3173
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mypy errors if file to analyze is called types.py","articleBody":"Example:\r\n\r\n/tmp/types.py\r\n```\r\n#!/usr/bin/env python3\r\nfrom typing import (\r\n NamedTuple,\r\n)\r\nfrom enum import Enum\r\n\r\n\r\nclass SomeEnum(Enum):\r\n FOO = 1\r\n BAR = 2\r\n\r\n\r\nclass ExtendedNamedTuple(NamedTuple):\r\n field: SomeEnum\r\n```\r\n\r\n```\r\n$ mypy --version\r\nmypy 0.510-dev-db96af3899030263bd9d79b0fad004808dde9ef7\r\n$ mypy --show-traceback /tmp/types.py\r\n/usr/local/lib/mypy/typeshed/stdlib/3/typing.pyi:5: error: Module 'types' has no attribute 'CodeType'\r\n/usr/local/lib/mypy/typeshed/stdlib/3/typing.pyi:5: error: Module 'types' has no attribute 'FrameType'\r\n/tmp/types.py:13: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues\r\nTraceback (most recent call last):\r\n File \"/usr/local/bin/mypy\", line 6, in \u003cmodule>\r\n main(__file__)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/main.py\", line 46, in main\r\n res = type_check_only(sources, bin_dir, options)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/main.py\", line 93, in type_check_only\r\n options=options)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/build.py\", line 188, in build\r\n graph = dispatch(sources, manager)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/build.py\", line 1559, in dispatch\r\n process_graph(graph, manager)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/build.py\", line 1802, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/build.py\", line 1895, in process_stale_scc\r\n graph[id].semantic_analysis()\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/build.py\", line 1459, in semantic_analysis\r\n self.manager.semantic_analyzer.visit_file(self.tree, self.xpath, self.options)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/semanal.py\", line 264, in visit_file\r\n self.accept(d)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/semanal.py\", line 3395, in accept\r\n node.accept(self)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/nodes.py\", line 749, in accept\r\n return visitor.visit_class_def(self)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/semanal.py\", line 714, in visit_class_def\r\n with self.analyze_class_body(defn) as should_continue:\r\n File \"/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py\", line 82, in __enter__\r\n return next(self.gen)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/semanal.py\", line 725, in analyze_class_body\r\n if self.analyze_namedtuple_classdef(defn):\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/semanal.py\", line 962, in analyze_namedtuple_classdef\r\n defn.name, items, types, default_items)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/semanal.py\", line 2184, in build_namedtuple_typeinfo\r\n info = self.basic_new_typeinfo(name, fallback)\r\n File \"/usr/local/lib/python3.6/site-packages/mypy/semanal.py\", line 2165, in basic_new_typeinfo\r\n info.mro = [info] + basetype_or_fallback.type.mro\r\nTypeError: can only concatenate list (not \"NoneType\") to list\r\n/tmp/types.py:13: note: use --pdb to drop into pdb\r\n```\r\n\r\nBasically loading the file seems to be overwriting and breaking the internal types module. Is it possible to load the module to analyze with a random prefix to avoid issues?","author":{"url":"https://github.com/bisho","@type":"Person","name":"bisho"},"datePublished":"2017-04-14T07:39:38Z","url":"https://github.com/python/mypy/issues/3173"}
| 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:b2faad9d-20f2-d5eb-e347-5c97d79ed1e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8266:18020:533E67:6F5111:6B002FF9 |
| html-safe-nonce | 12bec482aa1f7ad6cc0f0b747be15ed565fcca239380fff64dd31e2203a965cb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjY2OjE4MDIwOjUzM0U2Nzo2RjUxMTE6NkIwMDJGRjkiLCJ2aXNpdG9yX2lkIjoiNzIwOTM2NzQ1MTk3MTIxNTI5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e316ee95b0862297ec1ba2b29df3dc6759c290bc3d9d22834db45eeed0583edf |
| hovercard-subject-tag | issue:221759644 |
| 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/3173/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3871a4e063be8f8487be0c4964e29e5c98d68560f43b87f640431f110d05b872/python/mypy/issues/3173 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3871a4e063be8f8487be0c4964e29e5c98d68560f43b87f640431f110d05b872/python/mypy/issues/3173 |
| og:image:alt | Example: /tmp/types.py #!/usr/bin/env python3 from typing import ( NamedTuple, ) from enum import Enum class SomeEnum(Enum): FOO = 1 BAR = 2 class ExtendedNamedTuple(NamedTuple): field: SomeEnum $ ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bisho |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width