Title: Mucking with sys.path breaks checking imports · Issue #13701 · python/mypy · GitHub
Open Graph Title: Mucking with sys.path breaks checking imports · Issue #13701 · python/mypy
X Title: Mucking with sys.path breaks checking imports · Issue #13701 · python/mypy
Description: Bug Report If the first 2 entries of sys.path are pwd, mypy seems to miss type checks in imported modules. To Reproduce mypy==0.971 # sscce.py import sys import mypy.api sys.path.insert(0, sys.path[0]) print(mypy.api.run(["good.py"])[0])...
Open Graph Description: Bug Report If the first 2 entries of sys.path are pwd, mypy seems to miss type checks in imported modules. To Reproduce mypy==0.971 # sscce.py import sys import mypy.api sys.path.insert(0, sys.path...
X Description: Bug Report If the first 2 entries of sys.path are pwd, mypy seems to miss type checks in imported modules. To Reproduce mypy==0.971 # sscce.py import sys import mypy.api sys.path.insert(0, sys.path...
Opengraph URL: https://github.com/python/mypy/issues/13701
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mucking with sys.path breaks checking imports","articleBody":"**Bug Report**\r\n\r\nIf the first 2 entries of `sys.path` are pwd, `mypy` seems to miss type checks in imported modules.\r\n\r\n**To Reproduce**\r\n\r\n`mypy==0.971`\r\n\r\n``` python\r\n# sscce.py\r\nimport sys\r\nimport mypy.api\r\nsys.path.insert(0, sys.path[0])\r\nprint(mypy.api.run([\"good.py\"])[0])\r\n```\r\n``` python\r\n# good.py\r\nimport bad\r\n```\r\n``` python\r\n# bad.py \r\nfoo: str = 5\r\n```\r\n\r\n**Expected Behavior**\r\n\r\n```\r\nbad.py:1: error: Incompatible types in assignment (expression has type \"int\", variable has type \"str\")\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\n**Actual Behavior**\r\n\r\n```\r\nSuccess: no issues found in 1 source file\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 0.971\r\n\r\nThis issue broke `pytest-mypy` tests which use [`pytester.runpytest_subprocess`](https://docs.pytest.org/en/latest/reference/reference.html#pytest.Pytester.runpytest_subprocess) to run `pytest` in a subprocess (see https://github.com/dbader/pytest-mypy/issues/139).","author":{"url":"https://github.com/dmtucker","@type":"Person","name":"dmtucker"},"datePublished":"2022-09-21T07:54:14Z","url":"https://github.com/python/mypy/issues/13701"}
| 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:5e548e35-63cd-523f-efa5-a0e344249811 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C5AE:1FB2:133C013:1A759FF:6B00386A |
| html-safe-nonce | bbf36be023f1917690a9de24c205bfb8085d48c79a3717d120746003b58a0396 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNUFFOjFGQjI6MTMzQzAxMzoxQTc1OUZGOjZCMDAzODZBIiwidmlzaXRvcl9pZCI6Ijc4NTMzMDk1NTQ2MzE2NTM0ODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5be61097e6d07c5b1f01112365b573867201fdc634f8c1fd175eae004eb5ffbf |
| hovercard-subject-tag | issue:1380489939 |
| 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/13701/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1e13b0550866107c0ce18933225d7e8b2cd5bd348ba384e001c9d798b4e799d6/python/mypy/issues/13701 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1e13b0550866107c0ce18933225d7e8b2cd5bd348ba384e001c9d798b4e799d6/python/mypy/issues/13701 |
| og:image:alt | Bug Report If the first 2 entries of sys.path are pwd, mypy seems to miss type checks in imported modules. To Reproduce mypy==0.971 # sscce.py import sys import mypy.api sys.path.insert(0, sys.path... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dmtucker |
| 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