{"action":"created","comment":{"url":"https://api.github.com/repos/Suor/flaws/pulls/comments/84418940","pull_request_review_id":5199043,"id":84418940,"diff_hunk":"@@ -129,22 +129,30 @@ def _parse_urlrec(node):\n \n def _mark_refs(files, used, refs):\n     for ref in refs:\n-        module, func = ref.rsplit('.', 1)\n-        if module in files:\n-            pyfile = files[module]\n-            if func in pyfile.scope.names:\n-                used[module].add(func)\n-            else:\n-                # Try to find func in imports\n-                for imp in pyfile.scope.imports:\n-                    imported_module = get_import_module(imp, pyfile, files)\n-                    ref = \"%s.%s\" % (imported_module, func)\n-                    names = [node.asname or node.name for node in imp.names]\n-                    if func in names:\n-                        used[module].add(func)\n-                        _mark_refs(files, used, [ref])\n-                    elif '*' in names:\n-                        _mark_refs(files, used, [ref])\n+        if not _mark_ref(files, used, ref):\n+            print \"Can't resolve name '%s'\" % ref\n+\n+\n+def _mark_ref(files, used, ref):\n+    module, func = ref.rsplit('.', 1)\n+    if module in files:\n+        pyfile = files[module]\n+        if func in pyfile.scope.names:\n+            used[module].add(func)\n+            return True\n+        else:\n+            # Try to find func in imports\n+            for imp in (imp for imp in pyfile.scope.imports\n+                        if isinstance(imp, ast.ImportFrom)):\n+                imported_module = get_import_module(imp, pyfile, files)\n+                ref = \"%s.%s\" % (imported_module, func)\n+                for node in imp.names:\n+                    if func == node.asname:","path":"flaws/ext/django.py","position":40,"original_position":38,"commit_id":"add1b6d59cfc0ae5eaba515b90d790eaff4b815b","original_commit_id":"add1b6d59cfc0ae5eaba515b90d790eaff4b815b","user":{"login":"Suor","id":284103,"avatar_url":"https://avatars.githubusercontent.com/u/284103?v=3","gravatar_id":"","url":"https://api.github.com/users/Suor","html_url":"https://github.com/Suor","followers_url":"https://api.github.com/users/Suor/followers","following_url":"https://api.github.com/users/Suor/following{/other_user}","gists_url":"https://api.github.com/users/Suor/gists{/gist_id}","starred_url":"https://api.github.com/users/Suor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suor/subscriptions","organizations_url":"https://api.github.com/users/Suor/orgs","repos_url":"https://api.github.com/users/Suor/repos","events_url":"https://api.github.com/users/Suor/events{/privacy}","received_events_url":"https://api.github.com/users/Suor/received_events","type":"User","site_admin":false},"body":"Это почти всегда None","created_at":"2016-10-21T04:54:35Z","updated_at":"2016-10-21T04:54:35Z","html_url":"https://github.com/Suor/flaws/pull/8#discussion_r84418940","pull_request_url":"https://api.github.com/repos/Suor/flaws/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/Suor/flaws/pulls/comments/84418940"},"html":{"href":"https://github.com/Suor/flaws/pull/8#discussion_r84418940"},"pull_request":{"href":"https://api.github.com/repos/Suor/flaws/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/Suor/flaws/pulls/8","id":90241595,"html_url":"https://github.com/Suor/flaws/pull/8","diff_url":"https://github.com/Suor/flaws/pull/8.diff","patch_url":"https://github.com/Suor/flaws/pull/8.patch","issue_url":"https://api.github.com/repos/Suor/flaws/issues/8","number":8,"state":"open","locked":false,"title":"Search usage recursive throw imports","user":{"login":"ir4y","id":1488983,"avatar_url":"https://avatars.githubusercontent.com/u/1488983?v=3","gravatar_id":"","url":"https://api.github.com/users/ir4y","html_url":"https://github.com/ir4y","followers_url":"https://api.github.com/users/ir4y/followers","following_url":"https://api.github.com/users/ir4y/following{/other_user}","gists_url":"https://api.github.com/users/ir4y/gists{/gist_id}","starred_url":"https://api.github.com/users/ir4y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ir4y/subscriptions","organizations_url":"https://api.github.com/users/ir4y/orgs","repos_url":"https://api.github.com/users/ir4y/repos","events_url":"https://api.github.com/users/ir4y/events{/privacy}","received_events_url":"https://api.github.com/users/ir4y/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-20T17:04:15Z","updated_at":"2016-10-21T04:54:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26d514b0fbf7a4a4f1b4e2c146afb9086f9b775c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Suor/flaws/pulls/8/commits","review_comments_url":"https://api.github.com/repos/Suor/flaws/pulls/8/comments","review_comment_url":"https://api.github.com/repos/Suor/flaws/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Suor/flaws/issues/8/comments","statuses_url":"https://api.github.com/repos/Suor/flaws/statuses/add1b6d59cfc0ae5eaba515b90d790eaff4b815b","head":{"label":"ir4y:master","ref":"master","sha":"add1b6d59cfc0ae5eaba515b90d790eaff4b815b","user":{"login":"ir4y","id":1488983,"avatar_url":"https://avatars.githubusercontent.com/u/1488983?v=3","gravatar_id":"","url":"https://api.github.com/users/ir4y","html_url":"https://github.com/ir4y","followers_url":"https://api.github.com/users/ir4y/followers","following_url":"https://api.github.com/users/ir4y/following{/other_user}","gists_url":"https://api.github.com/users/ir4y/gists{/gist_id}","starred_url":"https://api.github.com/users/ir4y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ir4y/subscriptions","organizations_url":"https://api.github.com/users/ir4y/orgs","repos_url":"https://api.github.com/users/ir4y/repos","events_url":"https://api.github.com/users/ir4y/events{/privacy}","received_events_url":"https://api.github.com/users/ir4y/received_events","type":"User","site_admin":false},"repo":{"id":71485242,"name":"flaws","full_name":"ir4y/flaws","owner":{"login":"ir4y","id":1488983,"avatar_url":"https://avatars.githubusercontent.com/u/1488983?v=3","gravatar_id":"","url":"https://api.github.com/users/ir4y","html_url":"https://github.com/ir4y","followers_url":"https://api.github.com/users/ir4y/followers","following_url":"https://api.github.com/users/ir4y/following{/other_user}","gists_url":"https://api.github.com/users/ir4y/gists{/gist_id}","starred_url":"https://api.github.com/users/ir4y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ir4y/subscriptions","organizations_url":"https://api.github.com/users/ir4y/orgs","repos_url":"https://api.github.com/users/ir4y/repos","events_url":"https://api.github.com/users/ir4y/events{/privacy}","received_events_url":"https://api.github.com/users/ir4y/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ir4y/flaws","description":"Finds flaws in your python code","fork":true,"url":"https://api.github.com/repos/ir4y/flaws","forks_url":"https://api.github.com/repos/ir4y/flaws/forks","keys_url":"https://api.github.com/repos/ir4y/flaws/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ir4y/flaws/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ir4y/flaws/teams","hooks_url":"https://api.github.com/repos/ir4y/flaws/hooks","issue_events_url":"https://api.github.com/repos/ir4y/flaws/issues/events{/number}","events_url":"https://api.github.com/repos/ir4y/flaws/events","assignees_url":"https://api.github.com/repos/ir4y/flaws/assignees{/user}","branches_url":"https://api.github.com/repos/ir4y/flaws/branches{/branch}","tags_url":"https://api.github.com/repos/ir4y/flaws/tags","blobs_url":"https://api.github.com/repos/ir4y/flaws/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ir4y/flaws/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ir4y/flaws/git/refs{/sha}","trees_url":"https://api.github.com/repos/ir4y/flaws/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ir4y/flaws/statuses/{sha}","languages_url":"https://api.github.com/repos/ir4y/flaws/languages","stargazers_url":"https://api.github.com/repos/ir4y/flaws/stargazers","contributors_url":"https://api.github.com/repos/ir4y/flaws/contributors","subscribers_url":"https://api.github.com/repos/ir4y/flaws/subscribers","subscription_url":"https://api.github.com/repos/ir4y/flaws/subscription","commits_url":"https://api.github.com/repos/ir4y/flaws/commits{/sha}","git_commits_url":"https://api.github.com/repos/ir4y/flaws/git/commits{/sha}","comments_url":"https://api.github.com/repos/ir4y/flaws/comments{/number}","issue_comment_url":"https://api.github.com/repos/ir4y/flaws/issues/comments{/number}","contents_url":"https://api.github.com/repos/ir4y/flaws/contents/{+path}","compare_url":"https://api.github.com/repos/ir4y/flaws/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ir4y/flaws/merges","archive_url":"https://api.github.com/repos/ir4y/flaws/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ir4y/flaws/downloads","issues_url":"https://api.github.com/repos/ir4y/flaws/issues{/number}","pulls_url":"https://api.github.com/repos/ir4y/flaws/pulls{/number}","milestones_url":"https://api.github.com/repos/ir4y/flaws/milestones{/number}","notifications_url":"https://api.github.com/repos/ir4y/flaws/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ir4y/flaws/labels{/name}","releases_url":"https://api.github.com/repos/ir4y/flaws/releases{/id}","deployments_url":"https://api.github.com/repos/ir4y/flaws/deployments","created_at":"2016-10-20T17:02:28Z","updated_at":"2016-10-20T17:02:29Z","pushed_at":"2016-10-21T04:21:42Z","git_url":"git://github.com/ir4y/flaws.git","ssh_url":"git@github.com:ir4y/flaws.git","clone_url":"https://github.com/ir4y/flaws.git","svn_url":"https://github.com/ir4y/flaws","homepage":"","size":93,"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":"Suor:master","ref":"master","sha":"a203d0976c347a0501429d43bb39d25d1bc922b4","user":{"login":"Suor","id":284103,"avatar_url":"https://avatars.githubusercontent.com/u/284103?v=3","gravatar_id":"","url":"https://api.github.com/users/Suor","html_url":"https://github.com/Suor","followers_url":"https://api.github.com/users/Suor/followers","following_url":"https://api.github.com/users/Suor/following{/other_user}","gists_url":"https://api.github.com/users/Suor/gists{/gist_id}","starred_url":"https://api.github.com/users/Suor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suor/subscriptions","organizations_url":"https://api.github.com/users/Suor/orgs","repos_url":"https://api.github.com/users/Suor/repos","events_url":"https://api.github.com/users/Suor/events{/privacy}","received_events_url":"https://api.github.com/users/Suor/received_events","type":"User","site_admin":false},"repo":{"id":22261292,"name":"flaws","full_name":"Suor/flaws","owner":{"login":"Suor","id":284103,"avatar_url":"https://avatars.githubusercontent.com/u/284103?v=3","gravatar_id":"","url":"https://api.github.com/users/Suor","html_url":"https://github.com/Suor","followers_url":"https://api.github.com/users/Suor/followers","following_url":"https://api.github.com/users/Suor/following{/other_user}","gists_url":"https://api.github.com/users/Suor/gists{/gist_id}","starred_url":"https://api.github.com/users/Suor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suor/subscriptions","organizations_url":"https://api.github.com/users/Suor/orgs","repos_url":"https://api.github.com/users/Suor/repos","events_url":"https://api.github.com/users/Suor/events{/privacy}","received_events_url":"https://api.github.com/users/Suor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Suor/flaws","description":"Finds flaws in your python code","fork":false,"url":"https://api.github.com/repos/Suor/flaws","forks_url":"https://api.github.com/repos/Suor/flaws/forks","keys_url":"https://api.github.com/repos/Suor/flaws/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Suor/flaws/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Suor/flaws/teams","hooks_url":"https://api.github.com/repos/Suor/flaws/hooks","issue_events_url":"https://api.github.com/repos/Suor/flaws/issues/events{/number}","events_url":"https://api.github.com/repos/Suor/flaws/events","assignees_url":"https://api.github.com/repos/Suor/flaws/assignees{/user}","branches_url":"https://api.github.com/repos/Suor/flaws/branches{/branch}","tags_url":"https://api.github.com/repos/Suor/flaws/tags","blobs_url":"https://api.github.com/repos/Suor/flaws/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Suor/flaws/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Suor/flaws/git/refs{/sha}","trees_url":"https://api.github.com/repos/Suor/flaws/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Suor/flaws/statuses/{sha}","languages_url":"https://api.github.com/repos/Suor/flaws/languages","stargazers_url":"https://api.github.com/repos/Suor/flaws/stargazers","contributors_url":"https://api.github.com/repos/Suor/flaws/contributors","subscribers_url":"https://api.github.com/repos/Suor/flaws/subscribers","subscription_url":"https://api.github.com/repos/Suor/flaws/subscription","commits_url":"https://api.github.com/repos/Suor/flaws/commits{/sha}","git_commits_url":"https://api.github.com/repos/Suor/flaws/git/commits{/sha}","comments_url":"https://api.github.com/repos/Suor/flaws/comments{/number}","issue_comment_url":"https://api.github.com/repos/Suor/flaws/issues/comments{/number}","contents_url":"https://api.github.com/repos/Suor/flaws/contents/{+path}","compare_url":"https://api.github.com/repos/Suor/flaws/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Suor/flaws/merges","archive_url":"https://api.github.com/repos/Suor/flaws/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Suor/flaws/downloads","issues_url":"https://api.github.com/repos/Suor/flaws/issues{/number}","pulls_url":"https://api.github.com/repos/Suor/flaws/pulls{/number}","milestones_url":"https://api.github.com/repos/Suor/flaws/milestones{/number}","notifications_url":"https://api.github.com/repos/Suor/flaws/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Suor/flaws/labels{/name}","releases_url":"https://api.github.com/repos/Suor/flaws/releases{/id}","deployments_url":"https://api.github.com/repos/Suor/flaws/deployments","created_at":"2014-07-25T15:19:33Z","updated_at":"2016-06-24T23:46:24Z","pushed_at":"2016-10-21T04:21:43Z","git_url":"git://github.com/Suor/flaws.git","ssh_url":"git@github.com:Suor/flaws.git","clone_url":"https://github.com/Suor/flaws.git","svn_url":"https://github.com/Suor/flaws","homepage":"","size":92,"stargazers_count":33,"watchers_count":33,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":8,"forks":2,"open_issues":8,"watchers":33,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Suor/flaws/pulls/8"},"html":{"href":"https://github.com/Suor/flaws/pull/8"},"issue":{"href":"https://api.github.com/repos/Suor/flaws/issues/8"},"comments":{"href":"https://api.github.com/repos/Suor/flaws/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/Suor/flaws/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/Suor/flaws/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Suor/flaws/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/Suor/flaws/statuses/add1b6d59cfc0ae5eaba515b90d790eaff4b815b"}}}}
{"actor":{"display_login":"Suor"}}