Skip to content

Commit bf0b688

Browse files
committed
chore: apply review suggestions
1 parent 1803208 commit bf0b688

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎gitlab/utils.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def response_content(
5050

5151

5252
def _transform_types(
53-
data: Dict[str, Any], custom_types: dict, transform_files: Optional[bool] = True
53+
data: Dict[str, Any], custom_types: dict, *, transform_files: Optional[bool] = True
5454
) -> Tuple[dict, dict]:
5555
"""Copy the data dict with attributes that have custom types and transform them
5656
before being sent to the server.
@@ -67,7 +67,7 @@ def _transform_types(
6767
files = {}
6868

6969
for attr_name, type_cls in custom_types.items():
70-
if attr_name not in data.keys():
70+
if attr_name not in data:
7171
continue
7272

7373
type_obj = type_cls(data[attr_name])

‎tests/unit/test_utils.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,16 @@ def test_warn(self):
9797
assert warn_source == warning.source
9898

9999

100-
def test_transform_types_copies_data():
100+
def test_transform_types_copies_data_with_empty_files():
101101
data = {"attr": "spam"}
102-
new_data, _ = utils._transform_types(data, {})
102+
new_data, files = utils._transform_types(data, {})
103103

104104
assert new_data is not data
105+
assert new_data == data
106+
assert files == {}
105107

106108

107-
def test_transform_types_with_transform_files():
109+
def test_transform_types_with_transform_files_populates_files():
108110
custom_types = {"attr": types.FileAttribute}
109111
data = {"attr": "spam"}
110112
new_data, files = utils._transform_types(data, custom_types)
@@ -113,7 +115,7 @@ def test_transform_types_with_transform_files():
113115
assert files["attr"] == ("attr", "spam")
114116

115117

116-
def test_transform_types_without_transform_files():
118+
def test_transform_types_without_transform_files_populates_data_with_empty_files():
117119
custom_types = {"attr": types.FileAttribute}
118120
data = {"attr": "spam"}
119121
new_data, files = utils._transform_types(data, custom_types, transform_files=False)

0 commit comments

Comments
 (0)