From 7cf35b2c0e44732ca02b74b45525cc7c789457fb Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Thu, 3 Feb 2022 13:18:40 -0800 Subject: [PATCH] chore: require kwargs for `utils.copy_dict()` The non-keyword arguments were a tiny bit confusing as the destination was first and the source was second. Change the order and require key-word only arguments to ensure we don't silently break anyone. --- gitlab/client.py | 6 +++--- gitlab/utils.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gitlab/client.py b/gitlab/client.py index 46ddd9db6..a4c58313a 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -647,7 +647,7 @@ def http_request( url = self._build_url(path) params: Dict[str, Any] = {} - utils.copy_dict(params, query_data) + utils.copy_dict(src=query_data, dest=params) # Deal with kwargs: by default a user uses kwargs to send data to the # gitlab server, but this generates problems (python keyword conflicts @@ -656,12 +656,12 @@ def http_request( # value as arguments for the gitlab server, and ignore the other # arguments, except pagination ones (per_page and page) if "query_parameters" in kwargs: - utils.copy_dict(params, kwargs["query_parameters"]) + utils.copy_dict(src=kwargs["query_parameters"], dest=params) for arg in ("per_page", "page"): if arg in kwargs: params[arg] = kwargs[arg] else: - utils.copy_dict(params, kwargs) + utils.copy_dict(src=kwargs, dest=params) opts = self._get_session_opts() diff --git a/gitlab/utils.py b/gitlab/utils.py index f54904206..7b01d178d 100644 --- a/gitlab/utils.py +++ b/gitlab/utils.py @@ -44,7 +44,11 @@ def response_content( return None -def copy_dict(dest: Dict[str, Any], src: Dict[str, Any]) -> None: +def copy_dict( + *, + src: Dict[str, Any], + dest: Dict[str, Any], +) -> None: for k, v in src.items(): if isinstance(v, dict): # Transform dict values to new attributes. For example: