Skip to content

Commit

Permalink
chore: require kwargs for utils.copy_dict()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JohnVillalovos committed Feb 3, 2022
1 parent 64d01ef commit 7cf35b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions gitlab/client.py
Expand Up @@ -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
Expand All @@ -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()

Expand Down
6 changes: 5 additions & 1 deletion gitlab/utils.py
Expand Up @@ -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:
Expand Down

0 comments on commit 7cf35b2

Please sign in to comment.