Title: cannot inherit from a parameters · Issue #14185 · python/mypy · GitHub
Open Graph Title: cannot inherit from a parameters · Issue #14185 · python/mypy
X Title: cannot inherit from a parameters · Issue #14185 · python/mypy
Description: Bug Report It seems that mypy does not allow to inherit from a parameter when creating a function on the fly. To Reproduce from typing import Type def f(cls: Type) -> Type: class A(cls): ... return A >>>file.py:6: error: Variable "cls" i...
Open Graph Description: Bug Report It seems that mypy does not allow to inherit from a parameter when creating a function on the fly. To Reproduce from typing import Type def f(cls: Type) -> Type: class A(cls): ... return...
X Description: Bug Report It seems that mypy does not allow to inherit from a parameter when creating a function on the fly. To Reproduce from typing import Type def f(cls: Type) -> Type: class A(cls): ... ret...
Opengraph URL: https://github.com/python/mypy/issues/14185
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"cannot inherit from a parameters ","articleBody":"**Bug Report**\r\n\r\nIt seems that mypy does not allow to inherit from a parameter when creating a function on the fly.\r\n\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import Type\r\n\r\n\r\ndef f(cls: Type) -> Type:\r\n\r\n\r\n class A(cls):\r\n ...\r\n \r\n return A\r\n\r\n>>>file.py:6: error: Variable \"cls\" is not valid as a type [valid-type]\r\n>>>file.py:6: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases\r\n>>>file.py:6: error: Invalid base class \"cls\" [misc]\r\n\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nMypy should not complain\r\n\r\n**Actual Behavior**\r\n\r\nMypy complain and say\r\n\r\n```\r\n>>>file.py:6: error: Variable \"cls\" is not valid as a type [valid-type]\r\n>>>file.py:6: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases\r\n>>>file.py:6: error: Invalid base class \"cls\" [misc]\r\n```\r\n\r\n**Your Environment**\r\n\r\n\r\n\r\n- Mypy version used:`0.990\r\n- Python version used: 3.9.10\r\n\r\n\r\n","author":{"url":"https://github.com/samsja","@type":"Person","name":"samsja"},"datePublished":"2022-11-25T14:52:17Z","url":"https://github.com/python/mypy/issues/14185"}
| 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:925063a2-427a-ec56-f689-5299bcb147d4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA90:DD1C:105AD5B:15E8A0F:6AFFC422 |
| html-safe-nonce | f36f90c4e5eaa651fc91f2f7e4903c38834a1739114ad07738e5c17fcf251ca5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTkwOkREMUM6MTA1QUQ1QjoxNUU4QTBGOjZBRkZDNDIyIiwidmlzaXRvcl9pZCI6IjU4Mjg0MTk3OTUyNzEyNzE0NTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c005b537360ba31205b2e9477ee2007d6b1daf88ae5e945a4e4d20a02fc384da |
| hovercard-subject-tag | issue:1464650205 |
| 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/14185/issue_layout |
| twitter:image | https://opengraph.githubassets.com/227dde86691a6ec3a2f46a6dc19b2ed5c6860497fa26e825c50f83c17c2f61d7/python/mypy/issues/14185 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/227dde86691a6ec3a2f46a6dc19b2ed5c6860497fa26e825c50f83c17c2f61d7/python/mypy/issues/14185 |
| og:image:alt | Bug Report It seems that mypy does not allow to inherit from a parameter when creating a function on the fly. To Reproduce from typing import Type def f(cls: Type) -> Type: class A(cls): ... return... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | samsja |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1e805b832df235bb21305db712c3b6432920019dfc12cb25b9cb8d3b0c9403cf |
| 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 | 8fa4a54e6871c7908eda1c246ad5972982c0b59d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width