{"action":"created","comment":{"url":"https://api.github.com/repos/python/mypy/pulls/comments/60244370","id":60244370,"diff_hunk":"@@ -1593,3 +1593,106 @@ tmp/m.py: note: In function \"g\":\n tmp/m.py:2: error: \"int\" not callable\n main: note: In function \"f\":\n main:3: error: \"int\" not callable\n+\n+\n+-- Tests for special cases of unification\n+-- --------------------------------------\n+\n+[case testUnificationRedundantUnion]\n+from typing import Union\n+a = None  # type: Union[int, str]\n+b = None  # type: Union[str, tuple]\n+def f(): pass\n+def g(x: Union[int, str]): pass\n+c = a if f() else b\n+g(c) # E: Argument 1 to \"g\" has incompatible type \"Union[int, str, tuple]\"; expected \"Union[int, str]\"\n+\n+[case testUnificationMultipleInheritance]\n+class A: pass\n+class B:\n+    def foo(self): pass\n+class C(A, B): pass\n+def f(): pass\n+a1 = B() if f() else C()\n+a1.foo()\n+a2 = C() if f() else B()\n+a2.foo()\n+\n+[case testUnificationMultipleInheritanceAmbiguous]\n+# Show that join_instances_via_supertype() breakes ties using the first base class.\n+class A1: pass\n+class B1:\n+    def foo1(self): pass\n+class C1(A1, B1): pass\n+\n+class A2: pass\n+class B2:\n+    def foo2(self): pass\n+class C2(A2, B2): pass\n+\n+class D1(C1, C2): pass\n+class D2(C2, C1): pass\n+\n+def f(): pass\n+\n+a1 = D1() if f() else D2()\n+a1.foo1()\n+a2 = D2() if f() else D1()\n+a2.foo2()\n+\n+[case testUnificationEmptyListLeft]\n+def f(): pass\n+a = [] if f() else [0]\n+a.append(0)\n+[builtins fixtures/list.py]\n+\n+[case testUnificationEmptyListRight]\n+def f(): pass\n+a = [0] if f() else []\n+a.append(0)","path":"mypy/test/data/check-inference.test","position":84,"original_position":84,"commit_id":"1d2a30ded2ff7af80deee523847b3d4fdb9a5f79","original_commit_id":"1d2a30ded2ff7af80deee523847b3d4fdb9a5f79","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":"Similar to above -- verify type of `a`.","created_at":"2016-04-19T14:45:46Z","updated_at":"2016-04-19T14:45:46Z","html_url":"https://github.com/python/mypy/pull/1403#discussion_r60244370","pull_request_url":"https://api.github.com/repos/python/mypy/pulls/1403","_links":{"self":{"href":"https://api.github.com/repos/python/mypy/pulls/comments/60244370"},"html":{"href":"https://github.com/python/mypy/pull/1403#discussion_r60244370"},"pull_request":{"href":"https://api.github.com/repos/python/mypy/pulls/1403"}}},"pull_request":{"url":"https://api.github.com/repos/python/mypy/pulls/1403","id":66926274,"html_url":"https://github.com/python/mypy/pull/1403","diff_url":"https://github.com/python/mypy/pull/1403.diff","patch_url":"https://github.com/python/mypy/pull/1403.patch","issue_url":"https://api.github.com/repos/python/mypy/issues/1403","number":1403,"state":"open","locked":false,"title":"Empty list unification","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},"body":"There are three TODOs left:\r\n- Suppress errors of first attempt if we analyze the left branch a second time (needs a reproducing example)\r\n- Pick a better name for has_unfinished_types()\r\n- Find an example where the overall context is required for `([x] if ... else [])` (and that works with the limited test fixtures)","created_at":"2016-04-18T21:36:31Z","updated_at":"2016-04-19T14:45:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e45abdb631de8593a5449cda67e6f4547c3a4cea","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/python/mypy/pulls/1403/commits","review_comments_url":"https://api.github.com/repos/python/mypy/pulls/1403/comments","review_comment_url":"https://api.github.com/repos/python/mypy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python/mypy/issues/1403/comments","statuses_url":"https://api.github.com/repos/python/mypy/statuses/1d2a30ded2ff7af80deee523847b3d4fdb9a5f79","head":{"label":"python:empty-list-unification","ref":"empty-list-unification","sha":"1d2a30ded2ff7af80deee523847b3d4fdb9a5f79","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-04-19T05:53:08Z","pushed_at":"2016-04-19T14:31:15Z","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":14237,"stargazers_count":1224,"watchers_count":1224,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":143,"mirror_url":null,"open_issues_count":382,"forks":143,"open_issues":382,"watchers":1224,"default_branch":"master"}},"base":{"label":"python:master","ref":"master","sha":"4ae9c35a8a6fa884706462a54a9a1c5aad50a200","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-04-19T05:53:08Z","pushed_at":"2016-04-19T14:31:15Z","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":14237,"stargazers_count":1224,"watchers_count":1224,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":143,"mirror_url":null,"open_issues_count":382,"forks":143,"open_issues":382,"watchers":1224,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python/mypy/pulls/1403"},"html":{"href":"https://github.com/python/mypy/pull/1403"},"issue":{"href":"https://api.github.com/repos/python/mypy/issues/1403"},"comments":{"href":"https://api.github.com/repos/python/mypy/issues/1403/comments"},"review_comments":{"href":"https://api.github.com/repos/python/mypy/pulls/1403/comments"},"review_comment":{"href":"https://api.github.com/repos/python/mypy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python/mypy/pulls/1403/commits"},"statuses":{"href":"https://api.github.com/repos/python/mypy/statuses/1d2a30ded2ff7af80deee523847b3d4fdb9a5f79"}}}}