From 40ce81e9b9cea0dd75c712ccac887afd37416996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20M=C3=A4enp=C3=A4=C3=A4?= Date: Thu, 9 Oct 2014 10:17:21 +0300 Subject: [PATCH] No reason to add kwargs to object in Gitlab.list()-method because GitlabObject constructor can handle them. --- gitlab.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gitlab.py b/gitlab.py index 50f429e8e..5a3b034ef 100644 --- a/gitlab.py +++ b/gitlab.py @@ -204,14 +204,14 @@ def list(self, obj_class, **kwargs): cls = obj_class if obj_class._returnClass: cls = obj_class._returnClass - l = [cls(self, item) for item in r.json() if item is not None] - if kwargs: - for k, v in kwargs.items(): - if k in ('page', 'per_page'): - continue - for obj in l: - obj.__dict__[k] = str(v) - return l + + # Remove parameters from kwargs before passing it to constructor + cls_kwargs = kwargs.copy() + for key in ['page', 'per_page']: + if key in cls_kwargs: + del cls_kwargs[key] + + return [cls(self, item, **cls_kwargs) for item in r.json() if item is not None] elif r.status_code == 401: raise GitlabAuthenticationError(r.json()['message']) else: