{"action":"created","comment":{"url":"https://api.github.com/repos/python/mypy/pulls/comments/65584274","id":65584274,"diff_hunk":"@@ -0,0 +1,98 @@\n+Mypy syntax cheat sheet\n+=======================\n+\n+This document is a quick cheat sheet showing how the PEP-484 type\n+language represents various common types in Python 2.\n+\n+# document the cool print type feature of mypy here.\n+\n+.. code-block:: python\n+\n+   from typing import List, Dict, Set, Tuple, Union, Optional, Callable, Match\n+   from six import text_type\n+\n+   # For builtin types, just use the name of the type\n+   x = 1 # type: int\n+   x = 1.0 # type: float\n+   x = \"test\" # type: str\n+   x = u\"test\" # type: unicode\n+\n+   # For collections, the name of the type is capitalized, and the\n+   # name of the type in the collection is in brackets.\n+   x = [1] # type: List[int]\n+   x = set([6, 7]) # type: Set[int]\n+   # For mappings, we need the types of both keys and values\n+   x = dict(field=2.0) # type: Dict[str, float]\n+   # For tuples, we specify the types of all the elements\n+   x = (3, \"yes\", 7.5) # type: Tuple[int, str, float]\n+\n+   # six.text_type is str/unicode in Python 2 and string but not bytes in Python 3\n+   x = [\"string\", u\"unicode\"] # type: List[text_type]\n+   # If something could be one of a few types, use Union\n+   x = [3, 5, \"test\", \"fun\"] # type: Union[int, str]\n+   x = re.match(r'[0-9]+', \"15\") # type: Match","path":"docs/source/cheat_sheet.rst","position":33,"original_position":33,"commit_id":"f3d1f72d0f4b751b2d31a5c2f89bd2a41d6838a0","original_commit_id":"f3d1f72d0f4b751b2d31a5c2f89bd2a41d6838a0","user":{"login":"JukkaL","id":1107911,"avatar_url":"https://avatars.githubusercontent.com/u/1107911?v=3","gravatar_id":"","url":"https://api.github.com/users/JukkaL","html_url":"https://github.com/JukkaL","followers_url":"https://api.github.com/users/JukkaL/followers","following_url":"https://api.github.com/users/JukkaL/following{/other_user}","gists_url":"https://api.github.com/users/JukkaL/gists{/gist_id}","starred_url":"https://api.github.com/users/JukkaL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JukkaL/subscriptions","organizations_url":"https://api.github.com/users/JukkaL/orgs","repos_url":"https://api.github.com/users/JukkaL/repos","events_url":"https://api.github.com/users/JukkaL/events{/privacy}","received_events_url":"https://api.github.com/users/JukkaL/received_events","type":"User","site_admin":false},"body":"A more precise type would be `Match[str]`.","created_at":"2016-06-02T17:36:55Z","updated_at":"2016-06-02T17:36:55Z","html_url":"https://github.com/python/mypy/pull/1602#discussion_r65584274","pull_request_url":"https://api.github.com/repos/python/mypy/pulls/1602","_links":{"self":{"href":"https://api.github.com/repos/python/mypy/pulls/comments/65584274"},"html":{"href":"https://github.com/python/mypy/pull/1602#discussion_r65584274"},"pull_request":{"href":"https://api.github.com/repos/python/mypy/pulls/1602"}}},"pull_request":{"url":"https://api.github.com/repos/python/mypy/pulls/1602","id":72379435,"html_url":"https://github.com/python/mypy/pull/1602","diff_url":"https://github.com/python/mypy/pull/1602.diff","patch_url":"https://github.com/python/mypy/pull/1602.patch","issue_url":"https://api.github.com/repos/python/mypy/issues/1602","number":1602,"state":"open","locked":false,"title":"[WIP] Add mypy syntax cheat sheet.","user":{"login":"timabbott","id":2746074,"avatar_url":"https://avatars.githubusercontent.com/u/2746074?v=3","gravatar_id":"","url":"https://api.github.com/users/timabbott","html_url":"https://github.com/timabbott","followers_url":"https://api.github.com/users/timabbott/followers","following_url":"https://api.github.com/users/timabbott/following{/other_user}","gists_url":"https://api.github.com/users/timabbott/gists{/gist_id}","starred_url":"https://api.github.com/users/timabbott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timabbott/subscriptions","organizations_url":"https://api.github.com/users/timabbott/orgs","repos_url":"https://api.github.com/users/timabbott/repos","events_url":"https://api.github.com/users/timabbott/events{/privacy}","received_events_url":"https://api.github.com/users/timabbott/received_events","type":"User","site_admin":false},"body":"Here's a first version of a mypy syntax cheat sheet, intended to be linked to from the CI of project using mypy ; feedback (or picking this up and improving it directly during the Pycon sprints) is welcome!  \r\n\r\n","created_at":"2016-06-02T16:44:12Z","updated_at":"2016-06-02T17:36:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b80b9d0bd4b304e1eaa0cf4a96b34c62bb1637fd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/python/mypy/pulls/1602/commits","review_comments_url":"https://api.github.com/repos/python/mypy/pulls/1602/comments","review_comment_url":"https://api.github.com/repos/python/mypy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python/mypy/issues/1602/comments","statuses_url":"https://api.github.com/repos/python/mypy/statuses/f3d1f72d0f4b751b2d31a5c2f89bd2a41d6838a0","head":{"label":"timabbott:cheat-sheet","ref":"cheat-sheet","sha":"f3d1f72d0f4b751b2d31a5c2f89bd2a41d6838a0","user":{"login":"timabbott","id":2746074,"avatar_url":"https://avatars.githubusercontent.com/u/2746074?v=3","gravatar_id":"","url":"https://api.github.com/users/timabbott","html_url":"https://github.com/timabbott","followers_url":"https://api.github.com/users/timabbott/followers","following_url":"https://api.github.com/users/timabbott/following{/other_user}","gists_url":"https://api.github.com/users/timabbott/gists{/gist_id}","starred_url":"https://api.github.com/users/timabbott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timabbott/subscriptions","organizations_url":"https://api.github.com/users/timabbott/orgs","repos_url":"https://api.github.com/users/timabbott/repos","events_url":"https://api.github.com/users/timabbott/events{/privacy}","received_events_url":"https://api.github.com/users/timabbott/received_events","type":"User","site_admin":false},"repo":{"id":60280513,"name":"mypy","full_name":"timabbott/mypy","owner":{"login":"timabbott","id":2746074,"avatar_url":"https://avatars.githubusercontent.com/u/2746074?v=3","gravatar_id":"","url":"https://api.github.com/users/timabbott","html_url":"https://github.com/timabbott","followers_url":"https://api.github.com/users/timabbott/followers","following_url":"https://api.github.com/users/timabbott/following{/other_user}","gists_url":"https://api.github.com/users/timabbott/gists{/gist_id}","starred_url":"https://api.github.com/users/timabbott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timabbott/subscriptions","organizations_url":"https://api.github.com/users/timabbott/orgs","repos_url":"https://api.github.com/users/timabbott/repos","events_url":"https://api.github.com/users/timabbott/events{/privacy}","received_events_url":"https://api.github.com/users/timabbott/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/timabbott/mypy","description":"Optional static typing for Python","fork":true,"url":"https://api.github.com/repos/timabbott/mypy","forks_url":"https://api.github.com/repos/timabbott/mypy/forks","keys_url":"https://api.github.com/repos/timabbott/mypy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/timabbott/mypy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/timabbott/mypy/teams","hooks_url":"https://api.github.com/repos/timabbott/mypy/hooks","issue_events_url":"https://api.github.com/repos/timabbott/mypy/issues/events{/number}","events_url":"https://api.github.com/repos/timabbott/mypy/events","assignees_url":"https://api.github.com/repos/timabbott/mypy/assignees{/user}","branches_url":"https://api.github.com/repos/timabbott/mypy/branches{/branch}","tags_url":"https://api.github.com/repos/timabbott/mypy/tags","blobs_url":"https://api.github.com/repos/timabbott/mypy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/timabbott/mypy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/timabbott/mypy/git/refs{/sha}","trees_url":"https://api.github.com/repos/timabbott/mypy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/timabbott/mypy/statuses/{sha}","languages_url":"https://api.github.com/repos/timabbott/mypy/languages","stargazers_url":"https://api.github.com/repos/timabbott/mypy/stargazers","contributors_url":"https://api.github.com/repos/timabbott/mypy/contributors","subscribers_url":"https://api.github.com/repos/timabbott/mypy/subscribers","subscription_url":"https://api.github.com/repos/timabbott/mypy/subscription","commits_url":"https://api.github.com/repos/timabbott/mypy/commits{/sha}","git_commits_url":"https://api.github.com/repos/timabbott/mypy/git/commits{/sha}","comments_url":"https://api.github.com/repos/timabbott/mypy/comments{/number}","issue_comment_url":"https://api.github.com/repos/timabbott/mypy/issues/comments{/number}","contents_url":"https://api.github.com/repos/timabbott/mypy/contents/{+path}","compare_url":"https://api.github.com/repos/timabbott/mypy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/timabbott/mypy/merges","archive_url":"https://api.github.com/repos/timabbott/mypy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/timabbott/mypy/downloads","issues_url":"https://api.github.com/repos/timabbott/mypy/issues{/number}","pulls_url":"https://api.github.com/repos/timabbott/mypy/pulls{/number}","milestones_url":"https://api.github.com/repos/timabbott/mypy/milestones{/number}","notifications_url":"https://api.github.com/repos/timabbott/mypy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/timabbott/mypy/labels{/name}","releases_url":"https://api.github.com/repos/timabbott/mypy/releases{/id}","deployments_url":"https://api.github.com/repos/timabbott/mypy/deployments","created_at":"2016-06-02T16:37:52Z","updated_at":"2016-06-02T16:37:54Z","pushed_at":"2016-06-02T16:39:31Z","git_url":"git://github.com/timabbott/mypy.git","ssh_url":"git@github.com:timabbott/mypy.git","clone_url":"https://github.com/timabbott/mypy.git","svn_url":"https://github.com/timabbott/mypy","homepage":"http://www.mypy-lang.org/","size":13336,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"python:master","ref":"master","sha":"ccc7f5389e29814379fd352eb2440c34e09091b8","user":{"login":"python","id":1525981,"avatar_url":"https://avatars.githubusercontent.com/u/1525981?v=3","gravatar_id":"","url":"https://api.github.com/users/python","html_url":"https://github.com/python","followers_url":"https://api.github.com/users/python/followers","following_url":"https://api.github.com/users/python/following{/other_user}","gists_url":"https://api.github.com/users/python/gists{/gist_id}","starred_url":"https://api.github.com/users/python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python/subscriptions","organizations_url":"https://api.github.com/users/python/orgs","repos_url":"https://api.github.com/users/python/repos","events_url":"https://api.github.com/users/python/events{/privacy}","received_events_url":"https://api.github.com/users/python/received_events","type":"Organization","site_admin":false},"repo":{"id":7053637,"name":"mypy","full_name":"python/mypy","owner":{"login":"python","id":1525981,"avatar_url":"https://avatars.githubusercontent.com/u/1525981?v=3","gravatar_id":"","url":"https://api.github.com/users/python","html_url":"https://github.com/python","followers_url":"https://api.github.com/users/python/followers","following_url":"https://api.github.com/users/python/following{/other_user}","gists_url":"https://api.github.com/users/python/gists{/gist_id}","starred_url":"https://api.github.com/users/python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python/subscriptions","organizations_url":"https://api.github.com/users/python/orgs","repos_url":"https://api.github.com/users/python/repos","events_url":"https://api.github.com/users/python/events{/privacy}","received_events_url":"https://api.github.com/users/python/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python/mypy","description":"Optional static typing for Python","fork":false,"url":"https://api.github.com/repos/python/mypy","forks_url":"https://api.github.com/repos/python/mypy/forks","keys_url":"https://api.github.com/repos/python/mypy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python/mypy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python/mypy/teams","hooks_url":"https://api.github.com/repos/python/mypy/hooks","issue_events_url":"https://api.github.com/repos/python/mypy/issues/events{/number}","events_url":"https://api.github.com/repos/python/mypy/events","assignees_url":"https://api.github.com/repos/python/mypy/assignees{/user}","branches_url":"https://api.github.com/repos/python/mypy/branches{/branch}","tags_url":"https://api.github.com/repos/python/mypy/tags","blobs_url":"https://api.github.com/repos/python/mypy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python/mypy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python/mypy/git/refs{/sha}","trees_url":"https://api.github.com/repos/python/mypy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python/mypy/statuses/{sha}","languages_url":"https://api.github.com/repos/python/mypy/languages","stargazers_url":"https://api.github.com/repos/python/mypy/stargazers","contributors_url":"https://api.github.com/repos/python/mypy/contributors","subscribers_url":"https://api.github.com/repos/python/mypy/subscribers","subscription_url":"https://api.github.com/repos/python/mypy/subscription","commits_url":"https://api.github.com/repos/python/mypy/commits{/sha}","git_commits_url":"https://api.github.com/repos/python/mypy/git/commits{/sha}","comments_url":"https://api.github.com/repos/python/mypy/comments{/number}","issue_comment_url":"https://api.github.com/repos/python/mypy/issues/comments{/number}","contents_url":"https://api.github.com/repos/python/mypy/contents/{+path}","compare_url":"https://api.github.com/repos/python/mypy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python/mypy/merges","archive_url":"https://api.github.com/repos/python/mypy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python/mypy/downloads","issues_url":"https://api.github.com/repos/python/mypy/issues{/number}","pulls_url":"https://api.github.com/repos/python/mypy/pulls{/number}","milestones_url":"https://api.github.com/repos/python/mypy/milestones{/number}","notifications_url":"https://api.github.com/repos/python/mypy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python/mypy/labels{/name}","releases_url":"https://api.github.com/repos/python/mypy/releases{/id}","deployments_url":"https://api.github.com/repos/python/mypy/deployments","created_at":"2012-12-07T13:30:23Z","updated_at":"2016-06-02T13:20:04Z","pushed_at":"2016-06-02T17:22:27Z","git_url":"git://github.com/python/mypy.git","ssh_url":"git@github.com:python/mypy.git","clone_url":"https://github.com/python/mypy.git","svn_url":"https://github.com/python/mypy","homepage":"http://www.mypy-lang.org/","size":15174,"stargazers_count":1469,"watchers_count":1469,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":170,"mirror_url":null,"open_issues_count":382,"forks":170,"open_issues":382,"watchers":1469,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python/mypy/pulls/1602"},"html":{"href":"https://github.com/python/mypy/pull/1602"},"issue":{"href":"https://api.github.com/repos/python/mypy/issues/1602"},"comments":{"href":"https://api.github.com/repos/python/mypy/issues/1602/comments"},"review_comments":{"href":"https://api.github.com/repos/python/mypy/pulls/1602/comments"},"review_comment":{"href":"https://api.github.com/repos/python/mypy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python/mypy/pulls/1602/commits"},"statuses":{"href":"https://api.github.com/repos/python/mypy/statuses/f3d1f72d0f4b751b2d31a5c2f89bd2a41d6838a0"}}}}
{"actor":{"display_login":"JukkaL"}}