Title: "Intermittent" import error when checking a module that import another module which imports a 3rd party package · Issue #7276 · python/mypy · GitHub
Open Graph Title: "Intermittent" import error when checking a module that import another module which imports a 3rd party package · Issue #7276 · python/mypy
X Title: "Intermittent" import error when checking a module that import another module which imports a 3rd party package · Issue #7276 · python/mypy
Description: Hi, Sorry for the title. I try to explain myself better. I have found a strange behaviour in mypy related to an import error in a imported module. That is, an error in a module 'b' importing a module 'c' while checking module 'a', which ...
Open Graph Description: Hi, Sorry for the title. I try to explain myself better. I have found a strange behaviour in mypy related to an import error in a imported module. That is, an error in a module 'b' importing a modu...
X Description: Hi, Sorry for the title. I try to explain myself better. I have found a strange behaviour in mypy related to an import error in a imported module. That is, an error in a module 'b' importin...
Opengraph URL: https://github.com/python/mypy/issues/7276
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Intermittent\" import error when checking a module that import another module which imports a 3rd party package","articleBody":"Hi,\r\n\r\nSorry for the title. I try to explain myself better.\r\n\r\nI have found a strange behaviour in `mypy` related to an import error in a imported module. That is, an error in a module 'b' importing a module 'c' while checking module 'a', which imports 'b'. 'c', of course, is a 3rd party package.\r\n\r\nIn such a case, `mypy` reports nothing on a first round. But if it is run again, it reported a `error: Cannot find module named 'c'`. On a third run, nothing is reported again, while on a fourth run the error re-appears, and so on...\r\n\r\nThis happens even when the type check has been disabled in the import line.\r\n\r\nA possible scenario to reproduce this \"bug\" is as follows:\r\n\r\n1. Create a 'strange_report' package (with an empty `__init__.py`).\r\n\r\n2. Create a subpackage called 'a' inside 'strange_report' (with an empty `__init__.py` too).\r\n\r\n3. Write an `a.py` module (importer module) such as:\r\n```\r\nfrom a.b import B\r\n\r\nb = B() # just for visually check that a.py was run\r\n```\r\n4. Write a `b.py` module (imported module)\r\n```\r\nfrom ruamel.yaml import YAMLError # type: ignore\r\n\r\n\r\nclass B:\r\n def __init__(self):\r\n print(f\"New 'B' object {self} has been created\")\r\n```\r\n\r\n5. Open terminal and change to directory 'strange_report'.\r\n\r\n6. Module `a.py` can be run with `python -m a.a`\r\n\r\n7. If you run `mypy a/a.py` for the first time, you do not get any reports (however, directory '.mypy_cache' is created).\r\n\r\n8. But if you run `mypy a/a.py` once again, you get an error:\r\n\r\n```\r\nmadera:strange_error jv$ mypy a/a.py\r\na/b.py:1: error: Cannot find module named 'ruamel'\r\na/a.py:1: error: Cannot find module named 'ruamel'\r\na/a.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports\r\n```\r\n9. You can repeat 7. and 8. again and again with similar results. Same results are gotten with or without `# type: ignore`.\r\n\r\nHowever, **if cache directory '.mypy_cache' is deleted** before running mypy every time, it **does not report anything**.\r\n\r\nCuriously enough, if you check `mypy a/b.py` it consistently reports nothing.\r\n\r\nI am running on:\r\n\r\n- macOS HIgh Sierra 10.13.6\r\n- Python 3.7.4\r\n- mypy 0.720\r\n- ruamel.yaml 0.16.0 (so, yes, ruamel.yaml is installed; I use this 3rd party package because it is causing the bug in my system; no any particular purposes, I imagined that same bug can appeared with similar packages but cannot confirm that)\r\n- Any mypy configuration beyond the default one.\r\n\r\nThank for your attention. I hope that will be helpful.","author":{"url":"https://github.com/Quibi","@type":"Person","name":"Quibi"},"datePublished":"2019-07-31T11:03:05Z","url":"https://github.com/python/mypy/issues/7276"}
| 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:1088c537-c0bd-0912-2b25-ed873430b545 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A172:BACA4:2E858D4:3D9B966:6B0029CC |
| html-safe-nonce | fcfee43806eeb6c7e0fbd0b7007636cb8d67b6753a00084e821f56a34c24d715 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTcyOkJBQ0E0OjJFODU4RDQ6M0Q5Qjk2Njo2QjAwMjlDQyIsInZpc2l0b3JfaWQiOiI2NTIwNTE0NDAzMDU2NDk1MDUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7522680acd95a0239fec79b22db57a92e01584e58bb381a3c8a57376c12d9579 |
| hovercard-subject-tag | issue:475078142 |
| 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/7276/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5cc7df10ff8adf261fc0b03410e6cf5a307cf39053b9a4689e1a296a2b40969b/python/mypy/issues/7276 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5cc7df10ff8adf261fc0b03410e6cf5a307cf39053b9a4689e1a296a2b40969b/python/mypy/issues/7276 |
| og:image:alt | Hi, Sorry for the title. I try to explain myself better. I have found a strange behaviour in mypy related to an import error in a imported module. That is, an error in a module 'b' importing a modu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Quibi |
| 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