Title: `typing.Protocol` is explicitly treated as not a `type` · Issue #21940 · python/mypy · GitHub
Open Graph Title: `typing.Protocol` is explicitly treated as not a `type` · Issue #21940 · python/mypy
X Title: `typing.Protocol` is explicitly treated as not a `type` · Issue #21940 · python/mypy
Description: Bug Report At runtime, isinstance(typing.Protocol, type) is True. When type checking, mypy appears to special-case Protocol: mypy:
Open Graph Description: Bug Report At runtime, isinstance(typing.Protocol, type) is True. When type checking, mypy appears to special-case Protocol: mypy:
X Description: Bug Report At runtime, isinstance(typing.Protocol, type) is True. When type checking, mypy appears to special-case Protocol: mypy: <typing special form> Pylance/Pyright: (class) Protocol To R...
Opengraph URL: https://github.com/python/mypy/issues/21940
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`typing.Protocol` is explicitly treated as not a `type`","articleBody":"**Bug Report**\n\nAt runtime, `isinstance(typing.Protocol, type)` is `True`. When type checking, mypy appears to special-case Protocol:\n- mypy: `\u003ctyping special form>`\n- Pylance/Pyright: `(class) Protocol`\n\n**To Reproduce**\n\n```python\nfrom typing import Protocol\n\nclass A(Protocol): pass\n \nassert Protocol in A.__bases__\nbases: tuple[type, ...] = (Protocol, *A.__bases__)\n```\n\n[playground](https://mypy-play.net/?mypy=latest&python=3.14&flags=strict&gist=94a51ba0195276872717f697d4ca0db9) ([gist](https://gist.github.com/mypy-play/94a51ba0195276872717f697d4ca0db9))\n\n**Expected Behavior**\n\nSame as Pyright, Protocol is a class (type), no errors.\n\n**Actual Behavior**\n\n```log\nmain.py:5: error: Non-overlapping container check (element type: \"\u003ctyping special form>\", container item type: \"type\") [comparison-overlap]\nmain.py:6: error: Argument 1 to \u003ctuple> has incompatible type \"\u003ctyping special form>\"; expected \"type\" [arg-type]\n```\n\n**Your Environment**\n\n- Mypy version used: 1.0.0, 1.10.1, 1.20.2, 2.3.1\n- Mypy command-line flags: `--strict`\n- Python version used: 3.6 - 3.14\n","author":{"url":"https://github.com/chet-manley","@type":"Person","name":"chet-manley"},"datePublished":"2026-09-04T22:02:07Z","url":"https://github.com/python/mypy/issues/21940"}
| 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:bbd802e6-e71d-7632-2eb9-ad0e0d9358a7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8208:3AC034:4E07D0:696C0D:6B002FF4 |
| html-safe-nonce | d1f6bbe967e63469b5b40cf10f2d7ca295657c290e342209b904594fd1a9b815 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjA4OjNBQzAzNDo0RTA3RDA6Njk2QzBEOjZCMDAyRkY0IiwidmlzaXRvcl9pZCI6Ijc1MjY1MzA5MDY0MDA1MDE3NDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 39917fcf809b9a0e749c494af1f137c608d0f48f179bedcbdcbb9266f02b5ac1 |
| hovercard-subject-tag | issue:5353510476 |
| 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/21940/issue_layout |
| twitter:image | https://opengraph.githubassets.com/124c28d003c22fab04ec9896000626e9063df2ca0d3ed62d86debe28e8791491/python/mypy/issues/21940 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/124c28d003c22fab04ec9896000626e9063df2ca0d3ed62d86debe28e8791491/python/mypy/issues/21940 |
| og:image:alt | Bug Report At runtime, isinstance(typing.Protocol, type) is True. When type checking, mypy appears to special-case Protocol: mypy: |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chet-manley |
| 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