Title: Mypy issue validating package with directory and -p arg · Issue #11234 · python/mypy · GitHub
Open Graph Title: Mypy issue validating package with directory and -p arg · Issue #11234 · python/mypy
X Title: Mypy issue validating package with directory and -p arg · Issue #11234 · python/mypy
Description: Bug Report I'm having an issue running mypy on a package with the -p argument where the package directory has a subdirectory inside it. I'm receiving the following error with mypy 0.9.10: Traceback (most recent call last): File "/Users/o...
Open Graph Description: Bug Report I'm having an issue running mypy on a package with the -p argument where the package directory has a subdirectory inside it. I'm receiving the following error with mypy 0.9.10: Traceback...
X Description: Bug Report I'm having an issue running mypy on a package with the -p argument where the package directory has a subdirectory inside it. I'm receiving the following error with mypy 0.9.10: T...
Opengraph URL: https://github.com/python/mypy/issues/11234
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mypy issue validating package with directory and -p arg","articleBody":"**Bug Report**\r\nI'm having an issue running mypy on a package with the `-p` argument where the package directory has a subdirectory inside it. I'm receiving the following error with mypy 0.9.10:\r\n```\r\nTraceback (most recent call last):\r\n File \"/Users/oleksiyk/.pyenv/versions/3.8.9/lib/python3.8/runpy.py\", line 194, in _run_module_as_main\r\n return _run_code(code, main_globals, None,\r\n File \"/Users/oleksiyk/.pyenv/versions/3.8.9/lib/python3.8/runpy.py\", line 87, in _run_code\r\n exec(code, run_globals)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/__main__.py\", line 23, in \u003cmodule>\r\n console_entry()\r\n File \"mypy/build.py\", line 1955, in wrap_context\r\n File \"mypy/build.py\", line 2205, in finish_passes\r\n File \"mypy/build.py\", line 818, in report_file\r\n File \"mypy/report.py\", line 83, in file\r\n File \"mypy/report.py\", line 482, in on_file\r\n File \"mypy/report.py\", line 131, in iterate_python_lines\r\n File \"/Users/oleksiyk/.pyenv/versions/3.8.9/lib/python3.8/tokenize.py\", line 392, in open\r\n buffer = _builtin_open(filename, 'rb')\r\nIsADirectoryError: [Errno 21] Is a directory: 'python_tools/resources'\r\n```\r\n\r\nI tested with the master branch, and the error is the same, but the traceback is different:\r\n```\r\nTraceback (most recent call last):\r\n File \"/Users/oleksiyk/.pyenv/versions/3.8.9/lib/python3.8/runpy.py\", line 194, in _run_module_as_main\r\n return _run_code(code, main_globals, None,\r\n File \"/Users/oleksiyk/.pyenv/versions/3.8.9/lib/python3.8/runpy.py\", line 87, in _run_code\r\n exec(code, run_globals)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/__main__.py\", line 23, in \u003cmodule>\r\n console_entry()\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/__main__.py\", line 11, in console_entry\r\n main(None, sys.stdout, sys.stderr)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/main.py\", line 87, in main\r\n res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/main.py\", line 165, in run_build\r\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 179, in build\r\n result = _build(\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 254, in _build\r\n graph = dispatch(sources, manager, stdout)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 2707, in dispatch\r\n process_graph(graph, manager)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 3031, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 3132, in process_stale_scc\r\n graph[id].finish_passes()\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 2220, in finish_passes\r\n free_tree(self.tree)\r\n File \"/Users/oleksiyk/.pyenv/versions/3.8.9/lib/python3.8/contextlib.py\", line 131, in __exit__\r\n self.gen.throw(type, value, traceback)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 1962, in wrap_context\r\n yield\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 2215, in finish_passes\r\n manager.report_file(self.tree, self.type_map(), self.options)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/build.py\", line 821, in report_file\r\n self.reports.file(file, self.modules, type_map, options)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/report.py\", line 85, in file\r\n reporter.on_file(tree, modules, type_map, options)\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/report.py\", line 483, in on_file\r\n for lineno, line_text in iterate_python_lines(path):\r\n File \"/Users/oleksiyk/virtualenv_python38/lib/python3.8/site-packages/mypy/report.py\", line 133, in iterate_python_lines\r\n with tokenize.open(path) as input_file:\r\n File \"/Users/oleksiyk/.pyenv/versions/3.8.9/lib/python3.8/tokenize.py\", line 392, in open\r\n buffer = _builtin_open(filename, 'rb')\r\nIsADirectoryError: [Errno 21] Is a directory: 'python_tools/resources'\r\n```\r\n\r\nWithout the -p argument, the command passes with no issue.\r\n\r\n**Expected Behavior**\r\n\r\nI'm not too familiar with mypy, but I would expect the code to ignore such directories I think. I'm also not sure why the -p argument would cause this issue, when the code otherwise works normally. When I dug through the traceback a bit, I found this function https://github.com/python/mypy/blob/f98f78216ba9d6ab68c8e69c19e9f3c7926c5efe/mypy/report.py#L121-L128 that seems to handle skipping different paths for mypy validation. For the sake of testing, I changed the directory name above from `resources` to `stubs`, and that fixed the error. Perhaps all directories should be ignored by this skip function (or maybe they shouldn't be passed into it in the first place, not sure)?\r\n\r\n**My Environment**\r\n\r\n- Mypy version used: 0.9.10 and 0.920+dev.209a7193feb4bbfa38d09232b0a5a916e9d2e605\r\n- Full command run: `python3.8 -m mypy --txt-report ~/tmp/mypyr_report --install-types --non-interactive --namespace-packages --ignore-missing-imports -p yahoo.contrib.mx3_python_tools --show-traceback`\r\n- Mypy configuration options from `mypy.ini` (and other config files): none\r\n- Python version used: 3.8.9 (although in a separate env, 3.9 showed the same issue)\r\n- Operating system and version: MacOS Big Sur version 11.6","author":{"url":"https://github.com/oleksiykamenyev","@type":"Person","name":"oleksiykamenyev"},"datePublished":"2021-09-30T16:23:50Z","url":"https://github.com/python/mypy/issues/11234"}
| 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:0a95b26b-cf3e-da14-a81b-3f79aa6ff6d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C80E:B5253:21FB211:2D22099:6B005136 |
| html-safe-nonce | 803ee99cc97a15e12dbdd7f3818f9feb46b8e013e591825adbb043fe77792804 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDODBFOkI1MjUzOjIxRkIyMTE6MkQyMjA5OTo2QjAwNTEzNiIsInZpc2l0b3JfaWQiOiIyMDM4NTMxOTYwMjY3MTAwNDcwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8bf6f34ada10bf2a837a2092a46608456ec5cff73c0349f0baf47e604ceff43b |
| hovercard-subject-tag | issue:1012379545 |
| 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/11234/issue_layout |
| twitter:image | https://opengraph.githubassets.com/364628d70b94ba2a936d8cbb952ba2c6672300c859249daece73eb5433a6a4b5/python/mypy/issues/11234 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/364628d70b94ba2a936d8cbb952ba2c6672300c859249daece73eb5433a6a4b5/python/mypy/issues/11234 |
| og:image:alt | Bug Report I'm having an issue running mypy on a package with the -p argument where the package directory has a subdirectory inside it. I'm receiving the following error with mypy 0.9.10: Traceback... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | oleksiykamenyev |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width