{"action":"created","issue":{"url":"https://api.github.com/repos/python/mypy/issues/5144","repository_url":"https://api.github.com/repos/python/mypy","labels_url":"https://api.github.com/repos/python/mypy/issues/5144/labels{/name}","comments_url":"https://api.github.com/repos/python/mypy/issues/5144/comments","events_url":"https://api.github.com/repos/python/mypy/issues/5144/events","html_url":"https://github.com/python/mypy/issues/5144","id":329211743,"node_id":"MDU6SXNzdWUzMjkyMTE3NDM=","number":5144,"title":"Generic ClassVar Type failing","user":{"login":"alanhdu","id":1914111,"node_id":"MDQ6VXNlcjE5MTQxMTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1914111?v=4","gravatar_id":"","url":"https://api.github.com/users/alanhdu","html_url":"https://github.com/alanhdu","followers_url":"https://api.github.com/users/alanhdu/followers","following_url":"https://api.github.com/users/alanhdu/following{/other_user}","gists_url":"https://api.github.com/users/alanhdu/gists{/gist_id}","starred_url":"https://api.github.com/users/alanhdu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alanhdu/subscriptions","organizations_url":"https://api.github.com/users/alanhdu/orgs","repos_url":"https://api.github.com/users/alanhdu/repos","events_url":"https://api.github.com/users/alanhdu/events{/privacy}","received_events_url":"https://api.github.com/users/alanhdu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-04T20:50:09Z","updated_at":"2018-11-16T20:55:51Z","closed_at":null,"author_association":"NONE","body":"With mypy `0.600` (and the latest master `eb1bb064d707ce05735ff6795df82126e75ea6ea`), running mypy on\r\n\r\n```python\r\nfrom typing import ClassVar, Type, Generic, TypeVar\r\n\r\n_T = TypeVar('_T')\r\n\r\nclass Array(Generic[_T]):\r\n    _length_: ClassVar[int]\r\n    _type_: ClassVar[Type[_T]]\r\n\r\ndef generate() -> Type[Array[float]]:\r\n    pass\r\n\r\ngenerate()._type_(3)\r\n```\r\n\r\nfails with\r\n\r\n```python\r\ntest.py:12: error: Too many arguments for \"object\"\r\n```\r\n\r\ninstead of allowing this to construct a `float`.\r\n\r\nThe original use-case here is in the `ctypes` stubs, where mypy fails to derive the type of `(ctypes.c_float * 5)._type_` -- see:\r\n\r\nhttps://github.com/python/typeshed/blob/9ec6d476c44729ea84e9cafde9c5a77610451b0c/stdlib/2and3/ctypes/__init__.pyi#L248-L250"},"comment":{"url":"https://api.github.com/repos/python/mypy/issues/comments/439524567","html_url":"https://github.com/python/mypy/issues/5144#issuecomment-439524567","issue_url":"https://api.github.com/repos/python/mypy/issues/5144","id":439524567,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTUyNDU2Nw==","user":{"login":"ilevkivskyi","id":12005495,"node_id":"MDQ6VXNlcjEyMDA1NDk1","avatar_url":"https://avatars1.githubusercontent.com/u/12005495?v=4","gravatar_id":"","url":"https://api.github.com/users/ilevkivskyi","html_url":"https://github.com/ilevkivskyi","followers_url":"https://api.github.com/users/ilevkivskyi/followers","following_url":"https://api.github.com/users/ilevkivskyi/following{/other_user}","gists_url":"https://api.github.com/users/ilevkivskyi/gists{/gist_id}","starred_url":"https://api.github.com/users/ilevkivskyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilevkivskyi/subscriptions","organizations_url":"https://api.github.com/users/ilevkivskyi/orgs","repos_url":"https://api.github.com/users/ilevkivskyi/repos","events_url":"https://api.github.com/users/ilevkivskyi/events{/privacy}","received_events_url":"https://api.github.com/users/ilevkivskyi/received_events","type":"User","site_admin":false},"created_at":"2018-11-16T20:55:51Z","updated_at":"2018-11-16T20:55:51Z","author_association":"COLLABORATOR","body":"One comment is now have good stubs and a plugin for `ctypes`, another comment is maybe this restriction in the PEP is to limiting, _accessing_ generic class variables when they are still generic should indeed be prohibited, but declaring it and accessing only on subclasses that has that variable bound should be OK (technically not 100% safe but but I think should be fine)."}}
{"actor":{"display_login":"ilevkivskyi"}}