{"action":"created","issue":{"url":"https://api.github.com/repos/python/mypy/issues/1843","repository_url":"https://api.github.com/repos/python/mypy","labels_url":"https://api.github.com/repos/python/mypy/issues/1843/labels{/name}","comments_url":"https://api.github.com/repos/python/mypy/issues/1843/comments","events_url":"https://api.github.com/repos/python/mypy/issues/1843/events","html_url":"https://github.com/python/mypy/issues/1843","id":164930773,"number":1843,"title":"class object typed with Type[SomeAbstractClass] should not complain about instantiation","user":{"login":"gvanrossum","id":2894642,"avatar_url":"https://avatars.githubusercontent.com/u/2894642?v=3","gravatar_id":"","url":"https://api.github.com/users/gvanrossum","html_url":"https://github.com/gvanrossum","followers_url":"https://api.github.com/users/gvanrossum/followers","following_url":"https://api.github.com/users/gvanrossum/following{/other_user}","gists_url":"https://api.github.com/users/gvanrossum/gists{/gist_id}","starred_url":"https://api.github.com/users/gvanrossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvanrossum/subscriptions","organizations_url":"https://api.github.com/users/gvanrossum/orgs","repos_url":"https://api.github.com/users/gvanrossum/repos","events_url":"https://api.github.com/users/gvanrossum/events{/privacy}","received_events_url":"https://api.github.com/users/gvanrossum/received_events","type":"User","site_admin":false},"labels":[{"id":21488358,"url":"https://api.github.com/repos/python/mypy/labels/feature","name":"feature","color":"84b6eb","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/python/mypy/milestones/5","html_url":"https://github.com/python/mypy/milestones/0.4.x","labels_url":"https://api.github.com/repos/python/mypy/milestones/5/labels","id":1616634,"number":5,"title":"0.4.x","description":"The next release, and the next, within 0.4.x.\r\n\r\n(This is not strictly a milestone, just issues we'd like to get to before 0.5.0. For now we're going to a 6-week release cadence. So since 0.4.3 went out on July 14 and 0.4.4 went out on August 25, 0.4.5 should go out on October 6, 2016.)","creator":{"login":"ddfisher","id":245905,"avatar_url":"https://avatars.githubusercontent.com/u/245905?v=3","gravatar_id":"","url":"https://api.github.com/users/ddfisher","html_url":"https://github.com/ddfisher","followers_url":"https://api.github.com/users/ddfisher/followers","following_url":"https://api.github.com/users/ddfisher/following{/other_user}","gists_url":"https://api.github.com/users/ddfisher/gists{/gist_id}","starred_url":"https://api.github.com/users/ddfisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddfisher/subscriptions","organizations_url":"https://api.github.com/users/ddfisher/orgs","repos_url":"https://api.github.com/users/ddfisher/repos","events_url":"https://api.github.com/users/ddfisher/events{/privacy}","received_events_url":"https://api.github.com/users/ddfisher/received_events","type":"User","site_admin":false},"open_issues":36,"closed_issues":83,"state":"open","created_at":"2016-03-01T23:19:26Z","updated_at":"2016-11-15T18:35:28Z","due_on":"2016-11-18T00:00:00Z","closed_at":null},"comments":7,"created_at":"2016-07-11T20:47:48Z","updated_at":"2016-11-15T21:02:43Z","closed_at":null,"body":"I wish this code would work:\n\n```\nfrom typing import Type\n\nfrom abc import ABC, abstractmethod\n\nclass A(ABC):\n  @abstractmethod\n  def m(self) -> None: pass\n\ndef f(a: Type[A]) -> A:\n    return a()  # E: Cannot instantiate abstract class 'A' with abstract attribute 'm'\n```\n\nThe obvious intention is to pass f() a concrete subclass of A.\n\n(**UPDATE:** My real-world use case is a bit more involved, in asyncio there are some classes that implement an elaborate ABC, and I'd like to just say `SelectorEventLoop = ... # type: Type[AbstractEventLoop]` rather than having to write out the class definition with all 38 concrete method definitions.)\n"},"comment":{"url":"https://api.github.com/repos/python/mypy/issues/comments/260766993","html_url":"https://github.com/python/mypy/issues/1843#issuecomment-260766993","issue_url":"https://api.github.com/repos/python/mypy/issues/1843","id":260766993,"user":{"login":"gvanrossum","id":2894642,"avatar_url":"https://avatars.githubusercontent.com/u/2894642?v=3","gravatar_id":"","url":"https://api.github.com/users/gvanrossum","html_url":"https://github.com/gvanrossum","followers_url":"https://api.github.com/users/gvanrossum/followers","following_url":"https://api.github.com/users/gvanrossum/following{/other_user}","gists_url":"https://api.github.com/users/gvanrossum/gists{/gist_id}","starred_url":"https://api.github.com/users/gvanrossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvanrossum/subscriptions","organizations_url":"https://api.github.com/users/gvanrossum/orgs","repos_url":"https://api.github.com/users/gvanrossum/repos","events_url":"https://api.github.com/users/gvanrossum/events{/privacy}","received_events_url":"https://api.github.com/users/gvanrossum/received_events","type":"User","site_admin":false},"created_at":"2016-11-15T21:02:43Z","updated_at":"2016-11-15T21:02:43Z","body":"I don't really care what happens in that case. If it's considered an alias\nfor A, it should be an error; if it's seen as a variable whose type is\nType[A], then it should pass. Perhaps the implementation should just look\nwhether it's represented as a def with is_type_obj() true or as a TypeType\ninstance?\n"}}
{"actor":{"display_login":"gvanrossum"}}