Skip to content

Commit b261357

Browse files
committed
rye fmt
1 parent 6a9aa4f commit b261357

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

libs/labelbox/src/labelbox/data/annotation_types/relationship.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ def check_readonly(self):
3131
@model_validator(mode="after")
3232
def validate_source_fields(self):
3333
if self.source is None and self.source_ontology_name is None:
34-
raise ValueError("Either source or source_ontology_name must be provided")
34+
raise ValueError(
35+
"Either source or source_ontology_name must be provided"
36+
)
3537
return self
3638

3739
@model_validator(mode="after")
3840
def validate_source_consistency(self):
3941
if self.source is not None and self.source_ontology_name is not None:
40-
raise ValueError("Only one of 'source' or 'source_ontology_name' may be provided")
42+
raise ValueError(
43+
"Only one of 'source' or 'source_ontology_name' may be provided"
44+
)
4145
return self
4246

4347

libs/labelbox/src/labelbox/data/serialization/ndjson/label.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ def _create_relationship_annotations(
230230
f"Unable to create relationship with invalid source. For PDF targets, "
231231
f"source must be ObjectAnnotation or ClassificationAnnotation. Got: {type(source)}"
232232
)
233-
if source is None and annotation.value.source_ontology_name is None:
233+
if (
234+
source is None
235+
and annotation.value.source_ontology_name is None
236+
):
234237
raise ValueError(
235238
"Unable to create relationship - either source or source_ontology_name must be provided"
236239
)

libs/labelbox/src/labelbox/data/serialization/ndjson/relationship.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def from_common(
5353
name=annotation.name,
5454
dataRow=DataRow(id=data.uid, global_key=data.global_key),
5555
relationship=_Relationship(
56-
source=str(relationship.source._uuid) if relationship.source else None,
56+
source=str(relationship.source._uuid)
57+
if relationship.source
58+
else None,
5759
target=str(relationship.target._uuid),
5860
sourceOntologyName=relationship.source_ontology_name,
5961
type=relationship.type.value,

libs/labelbox/tests/data/annotation_import/test_relationships.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,10 @@ def test_relationship_missing_source_validation():
437437
value=TextEntity(start=30, end=35),
438438
)
439439

440-
with pytest.raises(ValueError, match="Either source or source_ontology_name must be provided"):
440+
with pytest.raises(
441+
ValueError,
442+
match="Either source or source_ontology_name must be provided",
443+
):
441444
RelationshipAnnotation(
442445
name="rel",
443446
value=Relationship(
@@ -458,7 +461,10 @@ def test_relationship_both_sources_validation():
458461
value=TextEntity(start=30, end=35),
459462
)
460463

461-
with pytest.raises(ValueError, match="Only one of 'source' or 'source_ontology_name' may be provided"):
464+
with pytest.raises(
465+
ValueError,
466+
match="Only one of 'source' or 'source_ontology_name' may be provided",
467+
):
462468
RelationshipAnnotation(
463469
name="rel",
464470
value=Relationship(

libs/labelbox/tests/data/serialization/ndjson/test_relationship.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ def test_source_ontology_name_relationship():
383383

384384
# Verify relationship with source_ontology_name
385385
assert (
386-
ontology_rel_serialized["relationship"]["sourceOntologyName"] == "Person"
386+
ontology_rel_serialized["relationship"]["sourceOntologyName"]
387+
== "Person"
387388
)
388389
assert (
389390
ontology_rel_serialized["relationship"]["target"]
@@ -404,7 +405,10 @@ def test_source_ontology_name_relationship():
404405
)
405406
assert False, "Expected ValueError for providing both source and source_ontology_name"
406407
except Exception as e:
407-
assert "Value error, Only one of 'source' or 'source_ontology_name' may be provided" in str(e)
408+
assert (
409+
"Value error, Only one of 'source' or 'source_ontology_name' may be provided"
410+
in str(e)
411+
)
408412

409413
# Test that providing neither source nor source_ontology_name raises an error
410414
try:
@@ -417,4 +421,7 @@ def test_source_ontology_name_relationship():
417421
)
418422
assert False, "Expected ValueError for providing neither source nor source_ontology_name"
419423
except Exception as e:
420-
assert "Value error, Either source or source_ontology_name must be provided" in str(e)
424+
assert (
425+
"Value error, Either source or source_ontology_name must be provided"
426+
in str(e)
427+
)

0 commit comments

Comments
 (0)