Title: cast gives cryptic error: Invalid type "self" · Issue #6862 · python/mypy · GitHub
Open Graph Title: cast gives cryptic error: Invalid type "self" · Issue #6862 · python/mypy
X Title: cast gives cryptic error: Invalid type "self" · Issue #6862 · python/mypy
Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to simplify your case to a minimal repro. fro...
Open Graph Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si...
X Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si...
Opengraph URL: https://github.com/python/mypy/issues/6862
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"cast gives cryptic error: Invalid type \"self\"","articleBody":"* Are you reporting a bug, or opening a feature request?\r\n**Bug**\r\n\r\n* Please insert below the code you are checking with mypy,\r\n or a mock-up repro if the source is private. We would appreciate\r\n if you try to simplify your case to a minimal repro.\r\n```python\r\nfrom typing import *\r\n\r\nInteger = NewType(\"Integer\", int)\r\n\r\nclass Foo:\r\n\r\n _bar: Integer\r\n\r\n def __init__(self, val: int) -> None:\r\n self._val = val\r\n self._bar = cast(self._val, self._bar)\r\n```\r\n* What is the actual behavior/output?\r\n`type.py:11: error: Invalid type \"self\"`\r\n* What is the behavior/output you expect?\r\n**An error message that explains that you cannot cast to an instance of a type.**\r\n* What are the versions of mypy and Python you are using?\r\n Do you see the same issue after installing mypy from Git master?\r\n**`mypy 0.701`**\r\n**`python 3.7.3`**\r\n* What are the mypy flags you are using? (For example --strict-optional)\r\n**`mypy.ini` is as follows.**\r\n```\r\n[mypy]\r\nmypy_path = stubs\r\n\r\nwarn_unused_ignores = True\r\nwarn_return_any = True\r\n\r\nstrict_optional = True\r\nno_implicit_optional = True\r\n\r\ndisallow_any_unimported = True\r\n#disallow_any_expr = True\r\n#disallow_any_decorated = True\r\ndisallow_any_explicit = True\r\ndisallow_subclassing_any = True\r\ndisallow_any_generics = True\r\n\r\ndisallow_untyped_calls = True\r\ndisallow_untyped_defs = True\r\ndisallow_incomplete_defs = True\r\ndisallow_untyped_decorators = True\r\n\r\ncheck_untyped_defs = True\r\n```","author":{"url":"https://github.com/trickeydan","@type":"Person","name":"trickeydan"},"datePublished":"2019-05-18T17:24:16Z","url":"https://github.com/python/mypy/issues/6862"}
| 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:9b0819b4-ca95-026b-e905-fca089fa411e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D0A6:3A13A0:2039817:2BA69C1:6B001C44 |
| html-safe-nonce | cd77533b9927d12710e4c3881dc94e581f5b5ac611230d44547c05badaf3e2ee |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEE2OjNBMTNBMDoyMDM5ODE3OjJCQTY5QzE6NkIwMDFDNDQiLCJ2aXNpdG9yX2lkIjoiMTczNTgyODk4NzQzNjg2NjYyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 435cc72e13cb66b467c94aef76d0e31e3353e6c4966b38e6d5d302128e6add20 |
| hovercard-subject-tag | issue:445736428 |
| 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/6862/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e3f80d14ef45f6296100b3644aba4f3fc808dfaf833693318f6f06000128f797/python/mypy/issues/6862 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e3f80d14ef45f6296100b3644aba4f3fc808dfaf833693318f6f06000128f797/python/mypy/issues/6862 |
| og:image:alt | Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trickeydan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width