Title: Example in PEP 544 seems to be wrong · Issue #1231 · python/peps · GitHub
Open Graph Title: Example in PEP 544 seems to be wrong · Issue #1231 · python/peps
X Title: Example in PEP 544 seems to be wrong · Issue #1231 · python/peps
Description: I am on Python 3.8 and use MyPy 0.740 I consider the following example from PEP 544: from typing import Any, Protocol class ProtoA(Protocol): def meth(self, x: int) -> int: ... class ProtoB(Protocol): def meth(self, obj: Any, x: int) -> ...
Open Graph Description: I am on Python 3.8 and use MyPy 0.740 I consider the following example from PEP 544: from typing import Any, Protocol class ProtoA(Protocol): def meth(self, x: int) -> int: ... class ProtoB(Protoco...
X Description: I am on Python 3.8 and use MyPy 0.740 I consider the following example from PEP 544: from typing import Any, Protocol class ProtoA(Protocol): def meth(self, x: int) -> int: ... class ProtoB(Prot...
Opengraph URL: https://github.com/python/peps/issues/1231
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Example in PEP 544 seems to be wrong","articleBody":"I am on Python 3.8 and use MyPy 0.740\r\n\r\nI consider the following example from PEP 544:\r\n\r\n```python\r\nfrom typing import Any, Protocol\r\n\r\nclass ProtoA(Protocol):\r\n def meth(self, x: int) -\u003e int: ...\r\nclass ProtoB(Protocol):\r\n def meth(self, obj: Any, x: int) -\u003e int: ...\r\n\r\nclass C:\r\n def meth(self, x: int) -\u003e int: ...\r\n\r\na: ProtoA = C # Type check error, signatures don't match!\r\nb: ProtoB = C # OK\r\n```\r\n\r\nIn the final two lines a class is assigned to a instance. MyPy thus reports\r\n\r\n /tmp/protocol-test.py:19: error: Incompatible types in assignment (expression has type \"Type[C]\", variable has type \"ProtoA\")\r\n /tmp/protocol-test.py:20: error: Incompatible types in assignment (expression has type \"Type[C]\", variable has type \"ProtoB\")\r\n Found 2 errors in 1 file (checked 1 source file)\r\n\r\nIf I fix that (i.e. adding the missing '()'), than it seems as if the assignment to `b` should cause a type error, not the assignment to `a`. Mypy`s report is consistent to my presumption.\r\n\r\nI hope it is ok to ask this, since I am here anyways: What is the difference between `...` and `pass`? RTFM with link would be fine.","author":{"url":"https://github.com/MaxG87","@type":"Person","name":"MaxG87"},"datePublished":"2019-11-11T10:13:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1231/peps/issues/1231"}
| 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:667e65eb-df66-73b6-a2de-2ceb83bfd614 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC84:3E5651:BC7902:103448F:6A61267C |
| html-safe-nonce | 1bb1cbbf1b7c9bb14cf1ef85431787f21371b43d24a501c5f6a3d0358325abb5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzg0OjNFNTY1MTpCQzc5MDI6MTAzNDQ4Rjo2QTYxMjY3QyIsInZpc2l0b3JfaWQiOiIzODUyNzQzNzM3MTU2MDEwMjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 58ab98bb41e1a337f561cd5d09939a4ed39cafac9d62e6e613021dcb9a8c600c |
| hovercard-subject-tag | issue:520860928 |
| 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/peps/1231/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e8bdc7c1cbd4f12bf65d4e2baa83b8b5530b6716c404aaa027614529dbf4d09f/python/peps/issues/1231 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e8bdc7c1cbd4f12bf65d4e2baa83b8b5530b6716c404aaa027614529dbf4d09f/python/peps/issues/1231 |
| og:image:alt | I am on Python 3.8 and use MyPy 0.740 I consider the following example from PEP 544: from typing import Any, Protocol class ProtoA(Protocol): def meth(self, x: int) -> int: ... class ProtoB(Protoco... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MaxG87 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6896275b704df9b9258326d49c8695aecd98d736cd9eeda7bcbb1790ac97d3ad |
| turbo-cache-control | no-preview |
| go-import | github.com/python/peps git https://github.com/python/peps.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 13414105 |
| octolytics-dimension-repository_nwo | python/peps |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13414105 |
| octolytics-dimension-repository_network_root_nwo | python/peps |
| 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 | af89f6cd55841b57fa09b6b0ed9e3f8f2e94b05d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width