Title: False positive when using os.PathLike in an isinstance check. · Issue #4681 · python/typeshed · GitHub
Open Graph Title: False positive when using os.PathLike in an isinstance check. · Issue #4681 · python/typeshed
X Title: False positive when using os.PathLike in an isinstance check. · Issue #4681 · python/typeshed
Description: Bug Report Take, for example. the following code: import os, pathlib print(isinstance(pathlib.Path(), os.PathLike)) Since version 0.790 mypy fails with the following error: domdf@ryzen:~/Python$ mypy mypy_os_pathlike.py mypy_os_pathlike....
Open Graph Description: Bug Report Take, for example. the following code: import os, pathlib print(isinstance(pathlib.Path(), os.PathLike)) Since version 0.790 mypy fails with the following error: domdf@ryzen:~/Python$ my...
X Description: Bug Report Take, for example. the following code: import os, pathlib print(isinstance(pathlib.Path(), os.PathLike)) Since version 0.790 mypy fails with the following error: domdf@ryzen:~/Python$ my...
Opengraph URL: https://github.com/python/typeshed/issues/4681
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False positive when using os.PathLike in an isinstance check.","articleBody":"\u003c!--\r\n If you're new to mypy and you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form\r\n instead.\r\n-->\r\n\r\n**Bug Report**\r\n\r\n\u003c!--\r\nNote: If the problem you are reporting is about a specific library function, then the typeshed tracker is better suited\r\nfor this report: https://github.com/python/typeshed/issues\r\n-->\r\n\r\nTake, for example. the following code:\r\n\r\n```python\r\nimport os, pathlib\r\nprint(isinstance(pathlib.Path(), os.PathLike))\r\n```\r\n\r\nSince version 0.790 mypy fails with the following error:\r\n\r\n```\r\ndomdf@ryzen:~/Python$ mypy mypy_os_pathlike.py \r\nmypy_os_pathlike.py:2: error: Only @runtime_checkable protocols can be used with instance and class checks\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\n\r\n**To Reproduce**\r\n\r\n\r\n1. Analyse the above source with mypy 0.790\r\n\r\n**Expected Behavior**\r\n\r\n\r\nWith mypy 0.782 everything was OK:\r\n\r\n```\r\ndomdf@ryzen:~/Python$ mypy mypy_os_pathlike.py \r\nSuccess: no issues found in 1 source file\r\n```\r\n\r\nFrom what I can tell, os.PathLike is not a Protocol but an abc.ABC, so I'm not sure why mypy thinks it is.\r\n\r\n\r\n**Actual Behavior**\r\n\r\n\u003c!--\r\n Did something go wrong?\r\n Is something broken, or not behaving as you expected?\r\n-->\r\n\r\nmypy thinks os.PathLike is a Protocol that cannot be used in isinstance checks.\r\n\r\n**Your Environment**\r\n\r\n\r\n- Mypy version used: 0.790\r\n- Mypy command-line flags: None\r\n- Mypy configuration options from `mypy.ini` (and other config files): None\r\n- Python version used: Python 3.8\r\n- Operating system and version: Ubuntu 20.04\r\n","author":{"url":"https://github.com/domdfcoding","@type":"Person","name":"domdfcoding"},"datePublished":"2020-10-17T11:33:59Z","url":"https://github.com/python/typeshed/issues/4681"}
| 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:8ef9f544-04ae-7d84-baa1-89fe285ed109 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CBA6:1A3D7F:3105E5C:40D7377:6B002934 |
| html-safe-nonce | 30bbb559f5b68a5a7ac74dbd9e3160b9d00396655b31cee06c8b42bef5eaed55 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkE2OjFBM0Q3RjozMTA1RTVDOjQwRDczNzc6NkIwMDI5MzQiLCJ2aXNpdG9yX2lkIjoiNDY0Mzc5NzAwODIwMzY1NTQ3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 884cb8e7ab65ecb37764f9572a7abea65a8a36233012a6b2828fd0b69f01d2c9 |
| hovercard-subject-tag | issue:723812454 |
| 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/typeshed/4681/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0a81b2ecf508e7888ed5707becbecefe2728139f4c82565aae3597dc6a9db480/python/typeshed/issues/4681 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0a81b2ecf508e7888ed5707becbecefe2728139f4c82565aae3597dc6a9db480/python/typeshed/issues/4681 |
| og:image:alt | Bug Report Take, for example. the following code: import os, pathlib print(isinstance(pathlib.Path(), os.PathLike)) Since version 0.790 mypy fails with the following error: domdf@ryzen:~/Python$ my... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | domdfcoding |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width