arkindex-base-worker 0.4.0rc6__py3-none-any.whl → 0.5.0a2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -113,9 +113,9 @@ class DatasetMixin:
113
113
  :param dataset_set: Set to find elements in.
114
114
  :returns: An iterator of Element built from the ``ListDatasetElements`` API endpoint.
115
115
  """
116
- assert dataset_set and isinstance(
117
- dataset_set, Set
118
- ), "dataset_set shouldn't be null and should be a Set"
116
+ assert dataset_set and isinstance(dataset_set, Set), (
117
+ "dataset_set shouldn't be null and should be a Set"
118
+ )
119
119
 
120
120
  results = self.api_client.paginate(
121
121
  "ListDatasetElements", id=dataset_set.dataset.id, set=dataset_set.name
@@ -152,12 +152,12 @@ class DatasetMixin:
152
152
  :param state: State of the dataset.
153
153
  :returns: The updated ``Dataset`` object from the ``PartialUpdateDataset`` API endpoint.
154
154
  """
155
- assert dataset and isinstance(
156
- dataset, Dataset
157
- ), "dataset shouldn't be null and should be a Dataset"
158
- assert state and isinstance(
159
- state, DatasetState
160
- ), "state shouldn't be null and should be a str from DatasetState"
155
+ assert dataset and isinstance(dataset, Dataset), (
156
+ "dataset shouldn't be null and should be a Dataset"
157
+ )
158
+ assert state and isinstance(state, DatasetState), (
159
+ "state shouldn't be null and should be a str from DatasetState"
160
+ )
161
161
 
162
162
  if self.is_read_only:
163
163
  logger.warning("Cannot update dataset as this worker is in read-only mode")
@@ -67,7 +67,7 @@ class ElementMixin:
67
67
  }
68
68
  count = len(self.corpus_types)
69
69
  logger.info(
70
- f'Loaded {count} element {pluralize("type", count)} in corpus ({self.corpus_id}).'
70
+ f"Loaded {count} element {pluralize('type', count)} in corpus ({self.corpus_id})."
71
71
  )
72
72
 
73
73
  @unsupported_cache
@@ -101,9 +101,9 @@ class ElementMixin:
101
101
  :raises MissingTypeError: If any of the specified type slugs were not found.
102
102
  """
103
103
  assert len(type_slugs), "At least one element type slug is required."
104
- assert all(
105
- isinstance(slug, str) for slug in type_slugs
106
- ), "Element type slugs must be strings."
104
+ assert all(isinstance(slug, str) for slug in type_slugs), (
105
+ "Element type slugs must be strings."
106
+ )
107
107
 
108
108
  if not self.corpus_types:
109
109
  self.list_corpus_types()
@@ -118,7 +118,7 @@ class ElementMixin:
118
118
  )
119
119
  else:
120
120
  raise MissingTypeError(
121
- f'Element {pluralize("type", len(missing_slugs))} {", ".join(sorted(missing_slugs))} were not found in corpus ({self.corpus_id}).'
121
+ f"Element {pluralize('type', len(missing_slugs))} {', '.join(sorted(missing_slugs))} were not found in corpus ({self.corpus_id})."
122
122
  )
123
123
 
124
124
  return True
@@ -146,18 +146,18 @@ class ElementMixin:
146
146
  :param slim_output: Whether to return the child ID or the full child.
147
147
  :returns: UUID of the created element.
148
148
  """
149
- assert element and isinstance(
150
- element, Element
151
- ), "element shouldn't be null and should be of type Element"
152
- assert type and isinstance(
153
- type, str
154
- ), "type shouldn't be null and should be of type str"
155
- assert name and isinstance(
156
- name, str
157
- ), "name shouldn't be null and should be of type str"
158
- assert polygon is None or isinstance(
159
- polygon, list
160
- ), "polygon should be None or a list"
149
+ assert element and isinstance(element, Element), (
150
+ "element shouldn't be null and should be of type Element"
151
+ )
152
+ assert type and isinstance(type, str), (
153
+ "type shouldn't be null and should be of type str"
154
+ )
155
+ assert name and isinstance(name, str), (
156
+ "name shouldn't be null and should be of type str"
157
+ )
158
+ assert polygon is None or isinstance(polygon, list), (
159
+ "polygon should be None or a list"
160
+ )
161
161
  if polygon is not None:
162
162
  assert len(polygon) >= 3, "polygon should have at least three points"
163
163
  assert all(
@@ -177,7 +177,9 @@ class ElementMixin:
177
177
  except ValueError as e:
178
178
  raise ValueError("image is not a valid uuid.") from e
179
179
  if polygon and image is None:
180
- assert element.zone, "An image or a parent with an image is required to create an element with a polygon."
180
+ assert element.zone, (
181
+ "An image or a parent with an image is required to create an element with a polygon."
182
+ )
181
183
  assert isinstance(slim_output, bool), "slim_output should be of type bool"
182
184
 
183
185
  if self.is_read_only:
@@ -231,56 +233,61 @@ class ElementMixin:
231
233
  :return: List of dicts, with each dict having a single key, ``id``, holding the UUID of each created element.
232
234
  """
233
235
  if isinstance(parent, Element):
234
- assert parent.get(
235
- "zone"
236
- ), "create_elements cannot be used on parents without zones"
236
+ assert parent.get("zone"), (
237
+ "create_elements cannot be used on parents without zones"
238
+ )
237
239
  elif isinstance(parent, CachedElement):
238
- assert (
239
- parent.image_id
240
- ), "create_elements cannot be used on parents without images"
240
+ assert parent.image_id, (
241
+ "create_elements cannot be used on parents without images"
242
+ )
241
243
  else:
242
244
  raise TypeError(
243
245
  "Parent element should be an Element or CachedElement instance"
244
246
  )
245
247
 
246
- assert elements and isinstance(
247
- elements, list
248
- ), "elements shouldn't be null and should be of type list"
248
+ assert elements and isinstance(elements, list), (
249
+ "elements shouldn't be null and should be of type list"
250
+ )
249
251
 
250
252
  for index, element in enumerate(elements):
251
- assert isinstance(
252
- element, dict
253
- ), f"Element at index {index} in elements: Should be of type dict"
253
+ assert isinstance(element, dict), (
254
+ f"Element at index {index} in elements: Should be of type dict"
255
+ )
254
256
 
255
257
  name = element.get("name")
256
- assert (
257
- name and isinstance(name, str)
258
- ), f"Element at index {index} in elements: name shouldn't be null and should be of type str"
258
+ assert name and isinstance(name, str), (
259
+ f"Element at index {index} in elements: name shouldn't be null and should be of type str"
260
+ )
259
261
 
260
262
  type = element.get("type")
261
- assert (
262
- type and isinstance(type, str)
263
- ), f"Element at index {index} in elements: type shouldn't be null and should be of type str"
263
+ assert type and isinstance(type, str), (
264
+ f"Element at index {index} in elements: type shouldn't be null and should be of type str"
265
+ )
264
266
 
265
267
  polygon = element.get("polygon")
266
- assert (
267
- polygon and isinstance(polygon, list)
268
- ), f"Element at index {index} in elements: polygon shouldn't be null and should be of type list"
269
- assert (
270
- len(polygon) >= 3
271
- ), f"Element at index {index} in elements: polygon should have at least three points"
268
+ assert polygon and isinstance(polygon, list), (
269
+ f"Element at index {index} in elements: polygon shouldn't be null and should be of type list"
270
+ )
271
+ assert len(polygon) >= 3, (
272
+ f"Element at index {index} in elements: polygon should have at least three points"
273
+ )
272
274
  assert all(
273
275
  isinstance(point, list) and len(point) == 2 for point in polygon
274
- ), f"Element at index {index} in elements: polygon points should be lists of two items"
276
+ ), (
277
+ f"Element at index {index} in elements: polygon points should be lists of two items"
278
+ )
275
279
  assert all(
276
280
  isinstance(coord, int | float) for point in polygon for coord in point
277
- ), f"Element at index {index} in elements: polygon points should be lists of two numbers"
281
+ ), (
282
+ f"Element at index {index} in elements: polygon points should be lists of two numbers"
283
+ )
278
284
 
279
285
  confidence = element.get("confidence")
280
- assert (
281
- confidence is None
282
- or (isinstance(confidence, float) and 0 <= confidence <= 1)
283
- ), f"Element at index {index} in elements: confidence should be None or a float in [0..1] range"
286
+ assert confidence is None or (
287
+ isinstance(confidence, float) and 0 <= confidence <= 1
288
+ ), (
289
+ f"Element at index {index} in elements: confidence should be None or a float in [0..1] range"
290
+ )
284
291
 
285
292
  if self.is_read_only:
286
293
  logger.warning("Cannot create elements as this worker is in read-only mode")
@@ -347,12 +354,12 @@ class ElementMixin:
347
354
  :param child: Child element.
348
355
  :returns: A dict from the ``CreateElementParent`` API endpoint.
349
356
  """
350
- assert parent and isinstance(
351
- parent, Element
352
- ), "parent shouldn't be null and should be of type Element"
353
- assert child and isinstance(
354
- child, Element
355
- ), "child shouldn't be null and should be of type Element"
357
+ assert parent and isinstance(parent, Element), (
358
+ "parent shouldn't be null and should be of type Element"
359
+ )
360
+ assert child and isinstance(child, Element), (
361
+ "child shouldn't be null and should be of type Element"
362
+ )
356
363
 
357
364
  if self.is_read_only:
358
365
  logger.warning("Cannot link elements as this worker is in read-only mode")
@@ -381,18 +388,18 @@ class ElementMixin:
381
388
 
382
389
  :returns: A list containing the string UUID of each child linked to the parent.
383
390
  """
384
- assert parent and isinstance(
385
- parent, Element
386
- ), "parent shouldn't be null and should be of type Element"
391
+ assert parent and isinstance(parent, Element), (
392
+ "parent shouldn't be null and should be of type Element"
393
+ )
387
394
 
388
- assert children and isinstance(
389
- children, list
390
- ), "children shouldn't be null and should be of type list"
395
+ assert children and isinstance(children, list), (
396
+ "children shouldn't be null and should be of type list"
397
+ )
391
398
 
392
399
  for index, child in enumerate(children):
393
- assert isinstance(
394
- child, Element
395
- ), f"Child at index {index} in children: Should be of type Element"
400
+ assert isinstance(child, Element), (
401
+ f"Child at index {index} in children: Should be of type Element"
402
+ )
396
403
 
397
404
  if self.is_read_only:
398
405
  logger.warning("Cannot link elements as this worker is in read-only mode")
@@ -430,9 +437,9 @@ class ElementMixin:
430
437
 
431
438
  :returns: A dict from the ``PartialUpdateElement`` API endpoint.
432
439
  """
433
- assert element and isinstance(
434
- element, Element | CachedElement
435
- ), "element shouldn't be null and should be an Element or CachedElement"
440
+ assert element and isinstance(element, Element | CachedElement), (
441
+ "element shouldn't be null and should be an Element or CachedElement"
442
+ )
436
443
 
437
444
  if "type" in kwargs:
438
445
  assert isinstance(kwargs["type"], str), "type should be a str"
@@ -459,9 +466,9 @@ class ElementMixin:
459
466
 
460
467
  if "rotation_angle" in kwargs:
461
468
  rotation_angle = kwargs["rotation_angle"]
462
- assert (
463
- isinstance(rotation_angle, int) and rotation_angle >= 0
464
- ), "rotation_angle should be a positive integer"
469
+ assert isinstance(rotation_angle, int) and rotation_angle >= 0, (
470
+ "rotation_angle should be a positive integer"
471
+ )
465
472
 
466
473
  if "mirrored" in kwargs:
467
474
  assert isinstance(kwargs["mirrored"], bool), "mirrored should be a boolean"
@@ -571,22 +578,22 @@ class ElementMixin:
571
578
  DeprecationWarning,
572
579
  stacklevel=1,
573
580
  )
574
- assert isinstance(
575
- transcription_worker_version, str | bool
576
- ), "transcription_worker_version should be of type str or bool"
581
+ assert isinstance(transcription_worker_version, str | bool), (
582
+ "transcription_worker_version should be of type str or bool"
583
+ )
577
584
  if isinstance(transcription_worker_version, bool):
578
- assert (
579
- transcription_worker_version is False
580
- ), "if of type bool, transcription_worker_version can only be set to False"
585
+ assert transcription_worker_version is False, (
586
+ "if of type bool, transcription_worker_version can only be set to False"
587
+ )
581
588
  query_params["transcription_worker_version"] = transcription_worker_version
582
589
  if transcription_worker_run is not None:
583
- assert isinstance(
584
- transcription_worker_run, str | bool
585
- ), "transcription_worker_run should be of type str or bool"
590
+ assert isinstance(transcription_worker_run, str | bool), (
591
+ "transcription_worker_run should be of type str or bool"
592
+ )
586
593
  if isinstance(transcription_worker_run, bool):
587
- assert (
588
- transcription_worker_run is False
589
- ), "if of type bool, transcription_worker_run can only be set to False"
594
+ assert transcription_worker_run is False, (
595
+ "if of type bool, transcription_worker_run can only be set to False"
596
+ )
590
597
  query_params["transcription_worker_run"] = transcription_worker_run
591
598
  if type:
592
599
  assert isinstance(type, str), "type should be of type str"
@@ -598,14 +605,14 @@ class ElementMixin:
598
605
  assert isinstance(with_corpus, bool), "with_corpus should be of type bool"
599
606
  query_params["with_corpus"] = with_corpus
600
607
  if with_has_children is not None:
601
- assert isinstance(
602
- with_has_children, bool
603
- ), "with_has_children should be of type bool"
608
+ assert isinstance(with_has_children, bool), (
609
+ "with_has_children should be of type bool"
610
+ )
604
611
  query_params["with_has_children"] = with_has_children
605
612
  if with_metadata is not None:
606
- assert isinstance(
607
- with_metadata, bool
608
- ), "with_metadata should be of type bool"
613
+ assert isinstance(with_metadata, bool), (
614
+ "with_metadata should be of type bool"
615
+ )
609
616
  query_params["with_metadata"] = with_metadata
610
617
  if with_zone is not None:
611
618
  assert isinstance(with_zone, bool), "with_zone should be of type bool"
@@ -616,22 +623,22 @@ class ElementMixin:
616
623
  DeprecationWarning,
617
624
  stacklevel=1,
618
625
  )
619
- assert isinstance(
620
- worker_version, str | bool
621
- ), "worker_version should be of type str or bool"
626
+ assert isinstance(worker_version, str | bool), (
627
+ "worker_version should be of type str or bool"
628
+ )
622
629
  if isinstance(worker_version, bool):
623
- assert (
624
- worker_version is False
625
- ), "if of type bool, worker_version can only be set to False"
630
+ assert worker_version is False, (
631
+ "if of type bool, worker_version can only be set to False"
632
+ )
626
633
  query_params["worker_version"] = worker_version
627
634
  if worker_run is not None:
628
- assert isinstance(
629
- worker_run, str | bool
630
- ), "worker_run should be of type str or bool"
635
+ assert isinstance(worker_run, str | bool), (
636
+ "worker_run should be of type str or bool"
637
+ )
631
638
  if isinstance(worker_run, bool):
632
- assert (
633
- worker_run is False
634
- ), "if of type bool, worker_run can only be set to False"
639
+ assert worker_run is False, (
640
+ "if of type bool, worker_run can only be set to False"
641
+ )
635
642
  query_params["worker_run"] = worker_run
636
643
 
637
644
  if not self.use_cache:
@@ -640,14 +647,13 @@ class ElementMixin:
640
647
  )
641
648
 
642
649
  # Checking that we only received query_params handled by the cache
643
- assert (
644
- set(query_params.keys())
645
- <= {
646
- "type",
647
- "worker_version",
648
- "worker_run",
649
- }
650
- ), "When using the local cache, you can only filter by 'type' and/or 'worker_version' and/or 'worker_run'"
650
+ assert set(query_params.keys()) <= {
651
+ "type",
652
+ "worker_version",
653
+ "worker_run",
654
+ }, (
655
+ "When using the local cache, you can only filter by 'type' and/or 'worker_version' and/or 'worker_run'"
656
+ )
651
657
 
652
658
  query = CachedElement.select()
653
659
  if type:
@@ -729,9 +735,9 @@ class ElementMixin:
729
735
  :return: An iterable of dicts from the ``ListElementChildren`` API endpoint,
730
736
  or an iterable of [CachedElement][arkindex_worker.cache.CachedElement] when caching is enabled.
731
737
  """
732
- assert element and isinstance(
733
- element, Element | CachedElement
734
- ), "element shouldn't be null and should be an Element or CachedElement"
738
+ assert element and isinstance(element, Element | CachedElement), (
739
+ "element shouldn't be null and should be an Element or CachedElement"
740
+ )
735
741
  query_params = {}
736
742
  if folder is not None:
737
743
  assert isinstance(folder, bool), "folder should be of type bool"
@@ -748,22 +754,22 @@ class ElementMixin:
748
754
  DeprecationWarning,
749
755
  stacklevel=1,
750
756
  )
751
- assert isinstance(
752
- transcription_worker_version, str | bool
753
- ), "transcription_worker_version should be of type str or bool"
757
+ assert isinstance(transcription_worker_version, str | bool), (
758
+ "transcription_worker_version should be of type str or bool"
759
+ )
754
760
  if isinstance(transcription_worker_version, bool):
755
- assert (
756
- transcription_worker_version is False
757
- ), "if of type bool, transcription_worker_version can only be set to False"
761
+ assert transcription_worker_version is False, (
762
+ "if of type bool, transcription_worker_version can only be set to False"
763
+ )
758
764
  query_params["transcription_worker_version"] = transcription_worker_version
759
765
  if transcription_worker_run is not None:
760
- assert isinstance(
761
- transcription_worker_run, str | bool
762
- ), "transcription_worker_run should be of type str or bool"
766
+ assert isinstance(transcription_worker_run, str | bool), (
767
+ "transcription_worker_run should be of type str or bool"
768
+ )
763
769
  if isinstance(transcription_worker_run, bool):
764
- assert (
765
- transcription_worker_run is False
766
- ), "if of type bool, transcription_worker_run can only be set to False"
770
+ assert transcription_worker_run is False, (
771
+ "if of type bool, transcription_worker_run can only be set to False"
772
+ )
767
773
  query_params["transcription_worker_run"] = transcription_worker_run
768
774
  if type:
769
775
  assert isinstance(type, str), "type should be of type str"
@@ -775,14 +781,14 @@ class ElementMixin:
775
781
  assert isinstance(with_corpus, bool), "with_corpus should be of type bool"
776
782
  query_params["with_corpus"] = with_corpus
777
783
  if with_has_children is not None:
778
- assert isinstance(
779
- with_has_children, bool
780
- ), "with_has_children should be of type bool"
784
+ assert isinstance(with_has_children, bool), (
785
+ "with_has_children should be of type bool"
786
+ )
781
787
  query_params["with_has_children"] = with_has_children
782
788
  if with_metadata is not None:
783
- assert isinstance(
784
- with_metadata, bool
785
- ), "with_metadata should be of type bool"
789
+ assert isinstance(with_metadata, bool), (
790
+ "with_metadata should be of type bool"
791
+ )
786
792
  query_params["with_metadata"] = with_metadata
787
793
  if with_zone is not None:
788
794
  assert isinstance(with_zone, bool), "with_zone should be of type bool"
@@ -793,22 +799,22 @@ class ElementMixin:
793
799
  DeprecationWarning,
794
800
  stacklevel=1,
795
801
  )
796
- assert isinstance(
797
- worker_version, str | bool
798
- ), "worker_version should be of type str or bool"
802
+ assert isinstance(worker_version, str | bool), (
803
+ "worker_version should be of type str or bool"
804
+ )
799
805
  if isinstance(worker_version, bool):
800
- assert (
801
- worker_version is False
802
- ), "if of type bool, worker_version can only be set to False"
806
+ assert worker_version is False, (
807
+ "if of type bool, worker_version can only be set to False"
808
+ )
803
809
  query_params["worker_version"] = worker_version
804
810
  if worker_run is not None:
805
- assert isinstance(
806
- worker_run, str | bool
807
- ), "worker_run should be of type str or bool"
811
+ assert isinstance(worker_run, str | bool), (
812
+ "worker_run should be of type str or bool"
813
+ )
808
814
  if isinstance(worker_run, bool):
809
- assert (
810
- worker_run is False
811
- ), "if of type bool, worker_run can only be set to False"
815
+ assert worker_run is False, (
816
+ "if of type bool, worker_run can only be set to False"
817
+ )
812
818
  query_params["worker_run"] = worker_run
813
819
 
814
820
  if not self.use_cache:
@@ -817,14 +823,13 @@ class ElementMixin:
817
823
  )
818
824
 
819
825
  # Checking that we only received query_params handled by the cache
820
- assert (
821
- set(query_params.keys())
822
- <= {
823
- "type",
824
- "worker_version",
825
- "worker_run",
826
- }
827
- ), "When using the local cache, you can only filter by 'type' and/or 'worker_version' and/or 'worker_run'"
826
+ assert set(query_params.keys()) <= {
827
+ "type",
828
+ "worker_version",
829
+ "worker_run",
830
+ }, (
831
+ "When using the local cache, you can only filter by 'type' and/or 'worker_version' and/or 'worker_run'"
832
+ )
828
833
 
829
834
  query = CachedElement.select().where(CachedElement.parent_id == element.id)
830
835
  if type:
@@ -906,9 +911,9 @@ class ElementMixin:
906
911
  :return: An iterable of dicts from the ``ListElementParents`` API endpoint,
907
912
  or an iterable of [CachedElement][arkindex_worker.cache.CachedElement] when caching is enabled.
908
913
  """
909
- assert element and isinstance(
910
- element, Element | CachedElement
911
- ), "element shouldn't be null and should be an Element or CachedElement"
914
+ assert element and isinstance(element, Element | CachedElement), (
915
+ "element shouldn't be null and should be an Element or CachedElement"
916
+ )
912
917
  query_params = {}
913
918
  if folder is not None:
914
919
  assert isinstance(folder, bool), "folder should be of type bool"
@@ -925,22 +930,22 @@ class ElementMixin:
925
930
  DeprecationWarning,
926
931
  stacklevel=1,
927
932
  )
928
- assert isinstance(
929
- transcription_worker_version, str | bool
930
- ), "transcription_worker_version should be of type str or bool"
933
+ assert isinstance(transcription_worker_version, str | bool), (
934
+ "transcription_worker_version should be of type str or bool"
935
+ )
931
936
  if isinstance(transcription_worker_version, bool):
932
- assert (
933
- transcription_worker_version is False
934
- ), "if of type bool, transcription_worker_version can only be set to False"
937
+ assert transcription_worker_version is False, (
938
+ "if of type bool, transcription_worker_version can only be set to False"
939
+ )
935
940
  query_params["transcription_worker_version"] = transcription_worker_version
936
941
  if transcription_worker_run is not None:
937
- assert isinstance(
938
- transcription_worker_run, str | bool
939
- ), "transcription_worker_run should be of type str or bool"
942
+ assert isinstance(transcription_worker_run, str | bool), (
943
+ "transcription_worker_run should be of type str or bool"
944
+ )
940
945
  if isinstance(transcription_worker_run, bool):
941
- assert (
942
- transcription_worker_run is False
943
- ), "if of type bool, transcription_worker_run can only be set to False"
946
+ assert transcription_worker_run is False, (
947
+ "if of type bool, transcription_worker_run can only be set to False"
948
+ )
944
949
  query_params["transcription_worker_run"] = transcription_worker_run
945
950
  if type:
946
951
  assert isinstance(type, str), "type should be of type str"
@@ -952,14 +957,14 @@ class ElementMixin:
952
957
  assert isinstance(with_corpus, bool), "with_corpus should be of type bool"
953
958
  query_params["with_corpus"] = with_corpus
954
959
  if with_has_children is not None:
955
- assert isinstance(
956
- with_has_children, bool
957
- ), "with_has_children should be of type bool"
960
+ assert isinstance(with_has_children, bool), (
961
+ "with_has_children should be of type bool"
962
+ )
958
963
  query_params["with_has_children"] = with_has_children
959
964
  if with_metadata is not None:
960
- assert isinstance(
961
- with_metadata, bool
962
- ), "with_metadata should be of type bool"
965
+ assert isinstance(with_metadata, bool), (
966
+ "with_metadata should be of type bool"
967
+ )
963
968
  query_params["with_metadata"] = with_metadata
964
969
  if with_zone is not None:
965
970
  assert isinstance(with_zone, bool), "with_zone should be of type bool"
@@ -970,22 +975,22 @@ class ElementMixin:
970
975
  DeprecationWarning,
971
976
  stacklevel=1,
972
977
  )
973
- assert isinstance(
974
- worker_version, str | bool
975
- ), "worker_version should be of type str or bool"
978
+ assert isinstance(worker_version, str | bool), (
979
+ "worker_version should be of type str or bool"
980
+ )
976
981
  if isinstance(worker_version, bool):
977
- assert (
978
- worker_version is False
979
- ), "if of type bool, worker_version can only be set to False"
982
+ assert worker_version is False, (
983
+ "if of type bool, worker_version can only be set to False"
984
+ )
980
985
  query_params["worker_version"] = worker_version
981
986
  if worker_run is not None:
982
- assert isinstance(
983
- worker_run, str | bool
984
- ), "worker_run should be of type str or bool"
987
+ assert isinstance(worker_run, str | bool), (
988
+ "worker_run should be of type str or bool"
989
+ )
985
990
  if isinstance(worker_run, bool):
986
- assert (
987
- worker_run is False
988
- ), "if of type bool, worker_run can only be set to False"
991
+ assert worker_run is False, (
992
+ "if of type bool, worker_run can only be set to False"
993
+ )
989
994
  query_params["worker_run"] = worker_run
990
995
 
991
996
  if not self.use_cache:
@@ -994,14 +999,13 @@ class ElementMixin:
994
999
  )
995
1000
 
996
1001
  # Checking that we only received query_params handled by the cache
997
- assert (
998
- set(query_params.keys())
999
- <= {
1000
- "type",
1001
- "worker_version",
1002
- "worker_run",
1003
- }
1004
- ), "When using the local cache, you can only filter by 'type' and/or 'worker_version' and/or 'worker_run'"
1002
+ assert set(query_params.keys()) <= {
1003
+ "type",
1004
+ "worker_version",
1005
+ "worker_run",
1006
+ }, (
1007
+ "When using the local cache, you can only filter by 'type' and/or 'worker_version' and/or 'worker_run'"
1008
+ )
1005
1009
 
1006
1010
  parent_ids = CachedElement.select(CachedElement.parent_id).where(
1007
1011
  CachedElement.id == element.id