Skip to content

Commit 483404f

Browse files
committed
fix formatting
1 parent 604de8f commit 483404f

File tree

8 files changed

+265
-222
lines changed

8 files changed

+265
-222
lines changed

README.md

Lines changed: 41 additions & 43 deletions
Large diffs are not rendered by default.

imagekitio/file.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def upload(
9595
raise ValueError("Invalid upload options")
9696
if isinstance(file, str) or isinstance(file, bytes):
9797
files.update({"file": (None, file)})
98-
if 'overwriteAiTags' in options:
99-
options['overwriteAITags'] = options['overwriteAiTags']
100-
del options['overwriteAiTags']
98+
if "overwriteAiTags" in options:
99+
options["overwriteAITags"] = options["overwriteAiTags"]
100+
del options["overwriteAiTags"]
101101
all_fields = {**files, **options}
102102
multipart_data = MultipartEncoder(
103103
fields=all_fields, boundary="--randomBoundary---------------------"
@@ -118,7 +118,7 @@ def list(self, options: ListAndSearchFileRequestOptions = None) -> ListFileResul
118118
:return: ListFileResult
119119
"""
120120
if options is not None:
121-
if 'tags' in options.__dict__ and isinstance(options.tags, list):
121+
if "tags" in options.__dict__ and isinstance(options.tags, list):
122122
val = ", ".join(options.tags)
123123
if val:
124124
options.tags = val
@@ -223,17 +223,13 @@ def update_file_details(
223223
headers = {"Content-Type": "application/json"}
224224
headers.update(self.request.get_auth_headers())
225225
formatted_options = request_formatter(options.__dict__)
226-
if 'removeAiTags' in formatted_options:
227-
remove_ai_tags_dict = {'removeAITags': formatted_options['removeAiTags']}
228-
del formatted_options['removeAiTags']
226+
if "removeAiTags" in formatted_options:
227+
remove_ai_tags_dict = {"removeAITags": formatted_options["removeAiTags"]}
228+
del formatted_options["removeAiTags"]
229229
request_data = {**remove_ai_tags_dict, **formatted_options}
230230
else:
231231
request_data = formatted_options
232-
data = (
233-
dumps(request_data)
234-
if options is not None
235-
else dict()
236-
)
232+
data = dumps(request_data) if options is not None else dict()
237233
resp = self.request.request(method="Patch", url=url, headers=headers, data=data)
238234
if resp.status_code == 200:
239235
response = convert_to_response_object(resp, FileResultWithResponseMetadata)

imagekitio/models/results/FileResult.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ def __init__(
3838
self.ai_tags: List[AITags] = []
3939
if ai_tags is not None:
4040
for i in ai_tags:
41-
self.ai_tags.append(AITags(i["name"] if "name" in i else None,
42-
i["confidence"] if "confidence" in i else None,
43-
i["source"] if 'source' in i else None))
41+
self.ai_tags.append(
42+
AITags(
43+
i["name"] if "name" in i else None,
44+
i["confidence"] if "confidence" in i else None,
45+
i["source"] if "source" in i else None,
46+
)
47+
)
4448
self.version_info = VersionInfo(version_info["id"], version_info["name"])
4549
self.embedded_metadata = embedded_metadata
4650
self.custom_coordinates = custom_coordinates

imagekitio/utils/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def general_api_throw_exception(response: Response):
3939
response_meta_data = populate_response_metadata(response)
4040
if type(resp) == str:
4141
resp = ast.literal_eval(resp)
42-
error_message = resp['message'] if type(resp) == dict else ""
43-
response_help = resp['help'] if type(resp) == dict and 'help' in resp else ""
42+
error_message = resp["message"] if type(resp) == dict else ""
43+
response_help = resp["help"] if type(resp) == dict and "help" in resp else ""
4444
if response.status_code == 400:
4545
raise BadRequestException(error_message, response_help, response_meta_data)
4646
elif response.status_code == 401:
@@ -65,8 +65,8 @@ def throw_other_exception(response: Response):
6565
response_meta_data = populate_response_metadata(response)
6666
if type(resp) == str:
6767
resp = ast.literal_eval(resp)
68-
error_message = resp['message'] if type(resp) == dict else ""
69-
response_help = resp['help'] if type(resp) == dict else ""
68+
error_message = resp["message"] if type(resp) == dict else ""
69+
response_help = resp["help"] if type(resp) == dict else ""
7070
if response.status_code == 207:
7171
raise PartialSuccessException(error_message, response_help, response_meta_data)
7272
elif response.status_code == 404:

tests/test_custom_metadata_fields_ops.py

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,9 @@ def test_create_custom_metadata_fields_succeeds_with_type_number(self):
346346
},
347347
}
348348

349-
request_body = json.dumps(json.loads(
350-
"""{
349+
request_body = json.dumps(
350+
json.loads(
351+
"""{
351352
"name": "test",
352353
"label": "test",
353354
"schema": {
@@ -356,7 +357,8 @@ def test_create_custom_metadata_fields_succeeds_with_type_number(self):
356357
"maxValue": 200
357358
}
358359
}"""
359-
))
360+
)
361+
)
360362
self.assertEqual(
361363
camel_dict_to_snake_dict(mock_response_metadata),
362364
resp.response_metadata.__dict__,
@@ -428,8 +430,9 @@ def test_create_custom_metadata_fields_succeeds_with_type_textarea(self):
428430
},
429431
}
430432

431-
request_body = json.dumps(json.loads(
432-
"""{
433+
request_body = json.dumps(
434+
json.loads(
435+
"""{
433436
"name": "test",
434437
"label": "test",
435438
"schema": {
@@ -440,7 +443,8 @@ def test_create_custom_metadata_fields_succeeds_with_type_textarea(self):
440443
"maxLength": 200
441444
}
442445
}"""
443-
))
446+
)
447+
)
444448
self.assertEqual(
445449
camel_dict_to_snake_dict(mock_response_metadata),
446450
resp.response_metadata.__dict__,
@@ -506,8 +510,9 @@ def test_create_custom_metadata_fields_succeeds_with_type_date(self):
506510
},
507511
}
508512

509-
request_body = json.dumps(json.loads(
510-
"""{
513+
request_body = json.dumps(
514+
json.loads(
515+
"""{
511516
"name": "test-date",
512517
"label": "test-date",
513518
"schema": {
@@ -516,7 +521,8 @@ def test_create_custom_metadata_fields_succeeds_with_type_date(self):
516521
"maxValue": "2022-11-30T10:11:10+00:00"
517522
}
518523
}"""
519-
))
524+
)
525+
)
520526
self.assertEqual(
521527
camel_dict_to_snake_dict(mock_response_metadata),
522528
resp.response_metadata.__dict__,
@@ -582,8 +588,9 @@ def test_create_custom_metadata_fields_succeeds_with_type_boolean(self):
582588
},
583589
}
584590

585-
request_body = json.dumps(json.loads(
586-
"""{
591+
request_body = json.dumps(
592+
json.loads(
593+
"""{
587594
"name": "test-boolean",
588595
"label": "test-boolean",
589596
"schema": {
@@ -592,7 +599,8 @@ def test_create_custom_metadata_fields_succeeds_with_type_boolean(self):
592599
"isValueRequired": true
593600
}
594601
}"""
595-
))
602+
)
603+
)
596604
self.assertEqual(
597605
camel_dict_to_snake_dict(mock_response_metadata),
598606
resp.response_metadata.__dict__,
@@ -655,8 +663,9 @@ def test_create_custom_metadata_fields_succeeds_with_type_single_select(self):
655663
},
656664
}
657665

658-
request_body = json.dumps(json.loads(
659-
"""{
666+
request_body = json.dumps(
667+
json.loads(
668+
"""{
660669
"name": "test",
661670
"label": "test",
662671
"schema":
@@ -666,7 +675,8 @@ def test_create_custom_metadata_fields_succeeds_with_type_single_select(self):
666675
true]
667676
}
668677
}"""
669-
))
678+
)
679+
)
670680
self.assertEqual(
671681
camel_dict_to_snake_dict(mock_response_metadata),
672682
resp.response_metadata.__dict__,
@@ -735,8 +745,9 @@ def test_create_custom_metadata_fields_succeeds_with_type_multi_select(self):
735745
},
736746
}
737747

738-
request_body = json.dumps(json.loads(
739-
"""{
748+
request_body = json.dumps(
749+
json.loads(
750+
"""{
740751
"name": "test",
741752
"label": "test",
742753
"schema": {
@@ -746,7 +757,8 @@ def test_create_custom_metadata_fields_succeeds_with_type_multi_select(self):
746757
"isValueRequired": true
747758
}
748759
}"""
749-
))
760+
)
761+
)
750762
self.assertEqual(
751763
camel_dict_to_snake_dict(mock_response_metadata),
752764
resp.response_metadata.__dict__,
@@ -804,15 +816,17 @@ def test_update_custom_metadata_fields_succeeds(self):
804816
},
805817
}
806818

807-
request_body = json.dumps(json.loads(
808-
"""{
819+
request_body = json.dumps(
820+
json.loads(
821+
"""{
809822
"label": "test-update",
810823
"schema": {
811824
"minValue": 100,
812825
"maxValue": 200
813826
}
814827
}"""
815-
))
828+
)
829+
)
816830

817831
self.assertEqual(
818832
camel_dict_to_snake_dict(mock_response_metadata),

0 commit comments

Comments
 (0)