Title: New semantic analyzer: Name 'MyX' already defined (by an import) · Issue #7172 · python/mypy · GitHub
Open Graph Title: New semantic analyzer: Name 'MyX' already defined (by an import) · Issue #7172 · python/mypy
X Title: New semantic analyzer: Name 'MyX' already defined (by an import) · Issue #7172 · python/mypy
Description: Are you reporting a bug, or opening a feature request? Reporting a bug Please insert below the code you are checking with mypy, reproducer.zip I'm somewhat new to mypy so I'm sorry if this is a user error. If nothing else, the error mess...
Open Graph Description: Are you reporting a bug, or opening a feature request? Reporting a bug Please insert below the code you are checking with mypy, reproducer.zip I'm somewhat new to mypy so I'm sorry if this is a use...
X Description: Are you reporting a bug, or opening a feature request? Reporting a bug Please insert below the code you are checking with mypy, reproducer.zip I'm somewhat new to mypy so I'm sorry if this ...
Opengraph URL: https://github.com/python/mypy/issues/7172
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"New semantic analyzer: Name 'MyX' already defined (by an import)","articleBody":"* Are you reporting a bug, or opening a feature request?\r\nReporting a bug\r\n\r\n* Please insert below the code you are checking with mypy,\r\n[reproducer.zip](https://github.com/python/mypy/files/3368891/reproducer.zip)\r\n\r\nI'm somewhat new to mypy so I'm sorry if this is a user error. If nothing else, the error message produced doesn't seem particularly helpful in narrowing down what to do fix it (or what section I might look in in the documentation). This is an error from one of my projects that builds cleanly with `mypy --strict` as well as pylint, pyflakes, etc. (with a few suppressions where the different tools take different views over things). I've reduced it and suitably anonymized it. There is a kind of circular import taking place where I'm importing the `MyX` class in `MyBase.py` and the `MyBase` class from `MyX.py` but it's never previously caused any issues.\r\n\r\n* What is the actual behavior/output?\r\n```\r\n(py3.6) e:\\tmp\\mypy-issue>python --version\r\nPython 3.6.8\r\n\r\n(py3.6) e:\\tmp\\mypy-issue>mypy --version\r\nmypy 0.711\r\n\r\n(py3.6) e:\\tmp\\mypy-issue>mypy --strict .\r\n\r\n(py3.6) e:\\tmp\\mypy-issue>mypy --strict --new-semantic-analyzer .\r\nouter\\inner\\MyDerived2.py:1: error: Name 'MyX' already defined (by an import)\r\nouter\\inner\\MyDerived2.py:8: error: Invalid type \"outer.MyX\"\r\n```\r\n\r\nIf I remove the explicit import of `MyX` from `MyDerived2.py` then it obviously fails with:\r\n\r\n```\r\n(py3.6) e:\\tmp\\mypy-issue>mypy --strict --new-semantic-analyzer .\r\nouter\\inner\\MyDerived2.py:8: error: Name 'MyX' is not defined\r\n```\r\n\r\n* What is the behavior/output you expect?\r\nNo error with the new semantic analyzer (same as with the old semantic analyzer).\r\n","author":{"url":"https://github.com/gregbedwell","@type":"Person","name":"gregbedwell"},"datePublished":"2019-07-08T14:47:19Z","url":"https://github.com/python/mypy/issues/7172"}
| 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:ce5635b3-2dea-f216-e835-474e94015911 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C42:16605A:108606C:15A439B:6AFFFB77 |
| html-safe-nonce | 96eb92c2792c2fd7497f95edc6a79a5e761d1151cf52915c98a9836375673a7b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzQyOjE2NjA1QToxMDg2MDZDOjE1QTQzOUI6NkFGRkZCNzciLCJ2aXNpdG9yX2lkIjoiODM4MDgxODAxNzc0Njk0MjgzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bc9c167608ed60710b385bfa2e0089a1b1d4a5ec523a50bc0d091af245417d2a |
| hovercard-subject-tag | issue:465301184 |
| 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/7172/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ad1488b17a948f6a0fcf1729c844f01b0fa97cce9920b9ba44a019e1dc7d035b/python/mypy/issues/7172 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ad1488b17a948f6a0fcf1729c844f01b0fa97cce9920b9ba44a019e1dc7d035b/python/mypy/issues/7172 |
| og:image:alt | Are you reporting a bug, or opening a feature request? Reporting a bug Please insert below the code you are checking with mypy, reproducer.zip I'm somewhat new to mypy so I'm sorry if this is a use... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gregbedwell |
| 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