{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/zamboni/pulls/comments/31434020","id":31434020,"diff_hunk":"@@ -57,3 +56,23 @@ class AddonTag(ModelBase):\n \n     class Meta:\n         db_table = 'users_tags_addons'\n+\n+\n+def attach_tags(objs, m2m_name=None):\n+    \"\"\"\n+    Fetch tags from `objs` in one query and then attach them to a property on\n+    each instance. The name of the property will be `m2m_name` + '_list'.\n+\n+    Assumes every instance in `objs` uses the same model, and needs `m2m_name`\n+    to be set to the name of the m2m field between the model and Tag.\n+    \"\"\"\n+    if m2m_name is None:","path":"mkt/tags/models.py","position":31,"original_position":31,"commit_id":"bbc593f74495a7e1aeb9c9a5308e8880e2bfc47f","original_commit_id":"bf3237384e0625e419e3d97b475dddf11f5296e3","user":{"login":"mstriemer","id":211578,"avatar_url":"https://avatars.githubusercontent.com/u/211578?v=3","gravatar_id":"","url":"https://api.github.com/users/mstriemer","html_url":"https://github.com/mstriemer","followers_url":"https://api.github.com/users/mstriemer/followers","following_url":"https://api.github.com/users/mstriemer/following{/other_user}","gists_url":"https://api.github.com/users/mstriemer/gists{/gist_id}","starred_url":"https://api.github.com/users/mstriemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstriemer/subscriptions","organizations_url":"https://api.github.com/users/mstriemer/orgs","repos_url":"https://api.github.com/users/mstriemer/repos","events_url":"https://api.github.com/users/mstriemer/events{/privacy}","received_events_url":"https://api.github.com/users/mstriemer/received_events","type":"User","site_admin":false},"body":"This code won't catch the `attach_tags(webapps, 'tags')` call so I don't really see the point. It just makes me think `m2m_name` is going to default so something common like `'tags'` by looking at the signature. Is it worth adding an `arity` decorator?\r\n\r\n```python\r\ndef arity(n):\r\n    def wrapper(fn):\r\n        def inner(*args, **kwargs):\r\n            if len(args) != n:\r\n                raise ValueError(\r\n                    '{fn} takes exactly {n} positional arguments'.format(\r\n                        fn=fn.__name__, n=n))\r\n            else:\r\n                return fn(*args, **kwargs)\r\n        return inner\r\n    return wrapper\r\n\r\n@arity(2)\r\ndef foo(arg1, arg2, kwarg1, kwarg2):\r\n    return arg1, arg2, kwarg1, kwarg2\r\n```\r\n```bash\r\n>>> from arity import foo\r\n>>> print(foo(1, 2, kwarg1=3, kwarg2=4))\r\n(1, 2, 3, 4)\r\n>>> print(foo(1, 2, 3, 4))\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"arity.py\", line 7, in inner\r\n    fn=fn.__name__, n=n))\r\nValueError: foo takes exactly 2 positional arguments\r\n>>> foo(1, 2, kwarg1=3, kwarg2=4, kwarg3=5)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"arity.py\", line 9, in inner\r\n    return fn(*args, **kwargs)\r\nTypeError: foo() got an unexpected keyword argument 'kwarg3'\r\n```\r\n\r\nThis won't handle a `*args` case but if we just want to restrict to one position arg it does the trick.","created_at":"2015-06-01T15:04:52Z","updated_at":"2015-06-01T15:04:52Z","html_url":"https://github.com/mozilla/zamboni/pull/3109#discussion_r31434020","pull_request_url":"https://api.github.com/repos/mozilla/zamboni/pulls/3109","_links":{"self":{"href":"https://api.github.com/repos/mozilla/zamboni/pulls/comments/31434020"},"html":{"href":"https://github.com/mozilla/zamboni/pull/3109#discussion_r31434020"},"pull_request":{"href":"https://api.github.com/repos/mozilla/zamboni/pulls/3109"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/zamboni/pulls/3109","id":36408917,"html_url":"https://github.com/mozilla/zamboni/pull/3109","diff_url":"https://github.com/mozilla/zamboni/pull/3109.diff","patch_url":"https://github.com/mozilla/zamboni/pull/3109.patch","issue_url":"https://api.github.com/repos/mozilla/zamboni/issues/3109","number":3109,"state":"open","locked":false,"title":"Implement website keywords in ES and the API (bug 1168817)","user":{"login":"diox","id":187006,"avatar_url":"https://avatars.githubusercontent.com/u/187006?v=3","gravatar_id":"","url":"https://api.github.com/users/diox","html_url":"https://github.com/diox","followers_url":"https://api.github.com/users/diox/followers","following_url":"https://api.github.com/users/diox/following{/other_user}","gists_url":"https://api.github.com/users/diox/gists{/gist_id}","starred_url":"https://api.github.com/users/diox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diox/subscriptions","organizations_url":"https://api.github.com/users/diox/orgs","repos_url":"https://api.github.com/users/diox/repos","events_url":"https://api.github.com/users/diox/events{/privacy}","received_events_url":"https://api.github.com/users/diox/received_events","type":"User","site_admin":false},"body":"https://bugzilla.mozilla.org/show_bug.cgi?id=1168817\r\n\r\nRefactor some code along the way that we need to share between webapps and websites.","created_at":"2015-05-28T13:56:48Z","updated_at":"2015-06-01T15:04:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8b470b02694fb71b98c5011b4427e7a137fd9244","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/zamboni/pulls/3109/commits","review_comments_url":"https://api.github.com/repos/mozilla/zamboni/pulls/3109/comments","review_comment_url":"https://api.github.com/repos/mozilla/zamboni/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/zamboni/issues/3109/comments","statuses_url":"https://api.github.com/repos/mozilla/zamboni/statuses/bbc593f74495a7e1aeb9c9a5308e8880e2bfc47f","head":{"label":"diox:websites-keywords","ref":"websites-keywords","sha":"bbc593f74495a7e1aeb9c9a5308e8880e2bfc47f","user":{"login":"diox","id":187006,"avatar_url":"https://avatars.githubusercontent.com/u/187006?v=3","gravatar_id":"","url":"https://api.github.com/users/diox","html_url":"https://github.com/diox","followers_url":"https://api.github.com/users/diox/followers","following_url":"https://api.github.com/users/diox/following{/other_user}","gists_url":"https://api.github.com/users/diox/gists{/gist_id}","starred_url":"https://api.github.com/users/diox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diox/subscriptions","organizations_url":"https://api.github.com/users/diox/orgs","repos_url":"https://api.github.com/users/diox/repos","events_url":"https://api.github.com/users/diox/events{/privacy}","received_events_url":"https://api.github.com/users/diox/received_events","type":"User","site_admin":false},"repo":{"id":10216041,"name":"zamboni","full_name":"diox/zamboni","owner":{"login":"diox","id":187006,"avatar_url":"https://avatars.githubusercontent.com/u/187006?v=3","gravatar_id":"","url":"https://api.github.com/users/diox","html_url":"https://github.com/diox","followers_url":"https://api.github.com/users/diox/followers","following_url":"https://api.github.com/users/diox/following{/other_user}","gists_url":"https://api.github.com/users/diox/gists{/gist_id}","starred_url":"https://api.github.com/users/diox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diox/subscriptions","organizations_url":"https://api.github.com/users/diox/orgs","repos_url":"https://api.github.com/users/diox/repos","events_url":"https://api.github.com/users/diox/events{/privacy}","received_events_url":"https://api.github.com/users/diox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/diox/zamboni","description":"The backend of the Firefox Marketplace","fork":true,"url":"https://api.github.com/repos/diox/zamboni","forks_url":"https://api.github.com/repos/diox/zamboni/forks","keys_url":"https://api.github.com/repos/diox/zamboni/keys{/key_id}","collaborators_url":"https://api.github.com/repos/diox/zamboni/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/diox/zamboni/teams","hooks_url":"https://api.github.com/repos/diox/zamboni/hooks","issue_events_url":"https://api.github.com/repos/diox/zamboni/issues/events{/number}","events_url":"https://api.github.com/repos/diox/zamboni/events","assignees_url":"https://api.github.com/repos/diox/zamboni/assignees{/user}","branches_url":"https://api.github.com/repos/diox/zamboni/branches{/branch}","tags_url":"https://api.github.com/repos/diox/zamboni/tags","blobs_url":"https://api.github.com/repos/diox/zamboni/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/diox/zamboni/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/diox/zamboni/git/refs{/sha}","trees_url":"https://api.github.com/repos/diox/zamboni/git/trees{/sha}","statuses_url":"https://api.github.com/repos/diox/zamboni/statuses/{sha}","languages_url":"https://api.github.com/repos/diox/zamboni/languages","stargazers_url":"https://api.github.com/repos/diox/zamboni/stargazers","contributors_url":"https://api.github.com/repos/diox/zamboni/contributors","subscribers_url":"https://api.github.com/repos/diox/zamboni/subscribers","subscription_url":"https://api.github.com/repos/diox/zamboni/subscription","commits_url":"https://api.github.com/repos/diox/zamboni/commits{/sha}","git_commits_url":"https://api.github.com/repos/diox/zamboni/git/commits{/sha}","comments_url":"https://api.github.com/repos/diox/zamboni/comments{/number}","issue_comment_url":"https://api.github.com/repos/diox/zamboni/issues/comments{/number}","contents_url":"https://api.github.com/repos/diox/zamboni/contents/{+path}","compare_url":"https://api.github.com/repos/diox/zamboni/compare/{base}...{head}","merges_url":"https://api.github.com/repos/diox/zamboni/merges","archive_url":"https://api.github.com/repos/diox/zamboni/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/diox/zamboni/downloads","issues_url":"https://api.github.com/repos/diox/zamboni/issues{/number}","pulls_url":"https://api.github.com/repos/diox/zamboni/pulls{/number}","milestones_url":"https://api.github.com/repos/diox/zamboni/milestones{/number}","notifications_url":"https://api.github.com/repos/diox/zamboni/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/diox/zamboni/labels{/name}","releases_url":"https://api.github.com/repos/diox/zamboni/releases{/id}","created_at":"2013-05-22T09:07:50Z","updated_at":"2015-05-07T16:20:10Z","pushed_at":"2015-06-01T14:54:05Z","git_url":"git://github.com/diox/zamboni.git","ssh_url":"git@github.com:diox/zamboni.git","clone_url":"https://github.com/diox/zamboni.git","svn_url":"https://github.com/diox/zamboni","homepage":" http://zamboni.readthedocs.org","size":365829,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"2ba2ec9da1711e78e2c4fc96d6f233ce4a3fb65a","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":347655,"name":"zamboni","full_name":"mozilla/zamboni","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/zamboni","description":"Backend for the Firefox Marketplace","fork":false,"url":"https://api.github.com/repos/mozilla/zamboni","forks_url":"https://api.github.com/repos/mozilla/zamboni/forks","keys_url":"https://api.github.com/repos/mozilla/zamboni/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/zamboni/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/zamboni/teams","hooks_url":"https://api.github.com/repos/mozilla/zamboni/hooks","issue_events_url":"https://api.github.com/repos/mozilla/zamboni/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/zamboni/events","assignees_url":"https://api.github.com/repos/mozilla/zamboni/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/zamboni/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/zamboni/tags","blobs_url":"https://api.github.com/repos/mozilla/zamboni/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/zamboni/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/zamboni/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/zamboni/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/zamboni/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/zamboni/languages","stargazers_url":"https://api.github.com/repos/mozilla/zamboni/stargazers","contributors_url":"https://api.github.com/repos/mozilla/zamboni/contributors","subscribers_url":"https://api.github.com/repos/mozilla/zamboni/subscribers","subscription_url":"https://api.github.com/repos/mozilla/zamboni/subscription","commits_url":"https://api.github.com/repos/mozilla/zamboni/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/zamboni/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/zamboni/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/zamboni/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/zamboni/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/zamboni/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/zamboni/merges","archive_url":"https://api.github.com/repos/mozilla/zamboni/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/zamboni/downloads","issues_url":"https://api.github.com/repos/mozilla/zamboni/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/zamboni/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/zamboni/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/zamboni/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/zamboni/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/zamboni/releases{/id}","created_at":"2009-10-23T19:35:34Z","updated_at":"2015-05-25T10:47:03Z","pushed_at":"2015-06-01T15:01:15Z","git_url":"git://github.com/mozilla/zamboni.git","ssh_url":"git@github.com:mozilla/zamboni.git","clone_url":"https://github.com/mozilla/zamboni.git","svn_url":"https://github.com/mozilla/zamboni","homepage":"http://marketplace.readthedocs.org/en/latest/topics/backend.html","size":428528,"stargazers_count":460,"watchers_count":460,"language":"Python","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":244,"mirror_url":null,"open_issues_count":20,"forks":244,"open_issues":20,"watchers":460,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/zamboni/pulls/3109"},"html":{"href":"https://github.com/mozilla/zamboni/pull/3109"},"issue":{"href":"https://api.github.com/repos/mozilla/zamboni/issues/3109"},"comments":{"href":"https://api.github.com/repos/mozilla/zamboni/issues/3109/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/zamboni/pulls/3109/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/zamboni/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/zamboni/pulls/3109/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/zamboni/statuses/bbc593f74495a7e1aeb9c9a5308e8880e2bfc47f"}}}}