{"action":"created","issue":{"url":"https://api.github.com/repos/ambv/typehinting/issues/107","labels_url":"https://api.github.com/repos/ambv/typehinting/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/ambv/typehinting/issues/107/comments","events_url":"https://api.github.com/repos/ambv/typehinting/issues/107/events","html_url":"https://github.com/ambv/typehinting/issues/107","id":74505744,"number":107,"title":"Can we have a generic Type[T]?","user":{"login":"NYKevin","id":1929766,"avatar_url":"https://avatars.githubusercontent.com/u/1929766?v=3","gravatar_id":"","url":"https://api.github.com/users/NYKevin","html_url":"https://github.com/NYKevin","followers_url":"https://api.github.com/users/NYKevin/followers","following_url":"https://api.github.com/users/NYKevin/following{/other_user}","gists_url":"https://api.github.com/users/NYKevin/gists{/gist_id}","starred_url":"https://api.github.com/users/NYKevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NYKevin/subscriptions","organizations_url":"https://api.github.com/users/NYKevin/orgs","repos_url":"https://api.github.com/users/NYKevin/repos","events_url":"https://api.github.com/users/NYKevin/events{/privacy}","received_events_url":"https://api.github.com/users/NYKevin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ambv/typehinting/labels/postponed","name":"postponed","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-08T21:42:19Z","updated_at":"2015-05-18T23:34:24Z","closed_at":null,"body":"The `type` object occupies a rather strange place in the type hierarchy:\r\n\r\n    >>> type(type) is type\r\n    True\r\n\r\n(I'm pretty sure that's a flat lie, since you can't instantiate something from itself, but regardless...)\r\n\r\n    >>> isinstance(type, object)\r\n    True\r\n    >>> isinstance(object, type)\r\n    True\r\n    >>> isinstance(type, type)\r\n    True\r\n\r\nIn Java, the (very rough) equivalent is a class, specifically [`Class<T>`](http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html).  It's also generic; the type variable refers to the instance.  Java has it easy because they don't support metaclasses.  Classes are not first class in Java, so their type hierarchy doesn't have to deal with the strange loops shown above.\r\n\r\nI realize metaclasses in their full generality are out of scope (at least for now), but a generic `Type[T]` like Java's would be nice to have.  So far as I can tell from the Mypy documentation, it doesn't currently exist.\r\n\r\nHere's some example code which might like to have this feature:\r\n\r\n    def make_foo(class_: Type[T]) -> T:\r\n        # Instantiate and return a T"},"comment":{"url":"https://api.github.com/repos/ambv/typehinting/issues/comments/103265155","html_url":"https://github.com/ambv/typehinting/issues/107#issuecomment-103265155","issue_url":"https://api.github.com/repos/ambv/typehinting/issues/107","id":103265155,"user":{"login":"ilevkivskyi","id":12005495,"avatar_url":"https://avatars.githubusercontent.com/u/12005495?v=3","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":"2015-05-18T23:34:24Z","updated_at":"2015-05-18T23:34:24Z","body":"I understand the time pressure but without `Type[T]` typehinting system looks a bit incomplete. I hope it will be added soon. "}}