Skip to content

Commit 0acc09c

Browse files
CaliLukeclaude
andcommitted
Fix CI lint/format and type check failures
- Sort imports in conftest.py, test_social_network_queries.py - Remove unused import TypeDBException in test_crud_edge_cases.py - Fix E721: use `is not` instead of `== Profile` for type comparison - Fix W293: remove whitespace from blank line in typedb_lifecycle.py - Fix pyright error: use len(manager.all()) instead of manager.count() - Format all test files with ruff Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d1c63a8 commit 0acc09c

13 files changed

Lines changed: 74 additions & 43 deletions

File tree

tests/integration/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import pytest
44
from typedb.driver import DriverOptions
55

6-
from type_bridge import Credentials, Database, TypeDB
76
from tests.utils.typedb_lifecycle import (
8-
suppress_stderr,
7+
TEST_DB_ADDRESS,
8+
TEST_DB_NAME,
99
start_typedb_container,
1010
stop_typedb_container,
11-
TEST_DB_NAME,
12-
TEST_DB_ADDRESS,
11+
suppress_stderr,
1312
)
13+
from type_bridge import Credentials, Database, TypeDB
1414

1515

1616
@pytest.fixture(scope="session")

tests/integration/crud/test_complex_relations.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,13 @@ def test_multiple_three_role_relations(self, schema_with_three_roles):
188188
Location.manager(db).insert(store)
189189

190190
# Multiple purchases at same store
191-
Purchase.manager(db).insert(Purchase(buyer=alice, item=laptop, store=store, amount=Amount(1)))
191+
Purchase.manager(db).insert(
192+
Purchase(buyer=alice, item=laptop, store=store, amount=Amount(1))
193+
)
192194
Purchase.manager(db).insert(Purchase(buyer=bob, item=phone, store=store, amount=Amount(2)))
193-
Purchase.manager(db).insert(Purchase(buyer=alice, item=phone, store=store, amount=Amount(1)))
195+
Purchase.manager(db).insert(
196+
Purchase(buyer=alice, item=phone, store=store, amount=Amount(1))
197+
)
194198

195199
purchases = Purchase.manager(db).all()
196200
assert len(purchases) == 3

tests/integration/crud/test_crud_edge_cases.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66

77
import pytest
8-
from typedb.driver import TypeDBException
98

109
from type_bridge import (
1110
Card,

tests/integration/generator/test_generate_and_import.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -439,26 +439,25 @@ def test_bounded_cardinality_role(self, generated_package: dict[str, ModuleType]
439439
assert reviewer_role.cardinality.min == 1
440440
assert reviewer_role.cardinality.max == 3
441441

442-
def test_create_relation_with_list_players(self, generated_package: dict[str, ModuleType]) -> None:
442+
def test_create_relation_with_list_players(
443+
self, generated_package: dict[str, ModuleType]
444+
) -> None:
443445
"""Create relation instance with list of role players."""
444446
entities = generated_package["entities"]
445447
relations = generated_package["relations"]
446448
attributes = generated_package["attributes"]
447449

448450
# Create two memory instances
449451
memory1 = entities.Memory(
450-
name=attributes.Name("Memory 1"),
451-
content=attributes.Content("First memory content")
452+
name=attributes.Name("Memory 1"), content=attributes.Content("First memory content")
452453
)
453454
memory2 = entities.Memory(
454-
name=attributes.Name("Memory 2"),
455-
content=attributes.Content("Second memory content")
455+
name=attributes.Name("Memory 2"), content=attributes.Content("Second memory content")
456456
)
457457

458458
# Create similarity relation with list of players
459459
similarity = relations.Is_similar_to(
460-
similar_memory=[memory1, memory2],
461-
score=attributes.Score(0.95)
460+
similar_memory=[memory1, memory2], score=attributes.Score(0.95)
462461
)
463462

464463
assert similarity.similar_memory == [memory1, memory2]
@@ -480,7 +479,9 @@ def test_symmetric_friendship_with_list(self, generated_package: dict[str, Modul
480479
assert alice in friendship.friend
481480
assert bob in friendship.friend
482481

483-
def test_unbounded_role_with_multiple_players(self, generated_package: dict[str, ModuleType]) -> None:
482+
def test_unbounded_role_with_multiple_players(
483+
self, generated_package: dict[str, ModuleType]
484+
) -> None:
484485
"""Group membership with 3+ members."""
485486
entities = generated_package["entities"]
486487
relations = generated_package["relations"]
@@ -491,10 +492,7 @@ def test_unbounded_role_with_multiple_players(self, generated_package: dict[str,
491492
member2 = entities.Person(name=attributes.Name("Member 2"))
492493
member3 = entities.Person(name=attributes.Name("Member 3"))
493494

494-
membership = relations.Group_membership(
495-
group=group,
496-
member=[member1, member2, member3]
497-
)
495+
membership = relations.Group_membership(group=group, member=[member1, member2, member3])
498496

499497
assert membership.group == group
500498
assert len(membership.member) == 3

tests/integration/generator/test_generator_use_pipeline.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def generated_package(self, tmp_path: Path) -> dict[str, ModuleType]:
8686
return _import_generated_package(output)
8787

8888
@pytest.fixture
89-
def db_with_generated_schema(self, clean_db: Database, generated_package: dict[str, ModuleType]):
89+
def db_with_generated_schema(
90+
self, clean_db: Database, generated_package: dict[str, ModuleType]
91+
):
9092
"""Set up database with generated schema."""
9193
entities = generated_package["entities"]
9294
relations = generated_package["relations"]
@@ -297,7 +299,9 @@ def test_unbounded_cardinality_group_membership(
297299

298300

299301
@pytest.mark.integration
300-
@pytest.mark.skip(reason="Bookstore schema has @card constraints that need SchemaManager investigation")
302+
@pytest.mark.skip(
303+
reason="Bookstore schema has @card constraints that need SchemaManager investigation"
304+
)
301305
class TestGeneratorBookstoreE2E:
302306
"""Test bookstore schema end-to-end with various attribute types."""
303307

@@ -311,7 +315,9 @@ def generated_package(self, tmp_path: Path) -> dict[str, ModuleType]:
311315
return _import_generated_package(output)
312316

313317
@pytest.fixture
314-
def db_with_bookstore_schema(self, clean_db: Database, generated_package: dict[str, ModuleType]):
318+
def db_with_bookstore_schema(
319+
self, clean_db: Database, generated_package: dict[str, ModuleType]
320+
):
315321
"""Set up database with bookstore schema."""
316322
entities = generated_package["entities"]
317323
relations = generated_package["relations"]

tests/integration/queries/test_complex_graph.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,17 @@ def test_count_with_filter(self, schema_for_aggregation):
274274
manager = Employee.manager(db)
275275

276276
# Insert employees in different departments
277-
manager.insert(Employee(name=Name("Alice"), salary=Salary(100000), department=Department("Engineering")))
278-
manager.insert(Employee(name=Name("Bob"), salary=Salary(90000), department=Department("Engineering")))
279-
manager.insert(Employee(name=Name("Carol"), salary=Salary(80000), department=Department("Marketing")))
277+
manager.insert(
278+
Employee(
279+
name=Name("Alice"), salary=Salary(100000), department=Department("Engineering")
280+
)
281+
)
282+
manager.insert(
283+
Employee(name=Name("Bob"), salary=Salary(90000), department=Department("Engineering"))
284+
)
285+
manager.insert(
286+
Employee(name=Name("Carol"), salary=Salary(80000), department=Department("Marketing"))
287+
)
280288

281289
# Count engineering employees
282290
eng_count = manager.filter(department="Engineering").count()
@@ -292,9 +300,17 @@ def test_multiple_filters_combined(self, schema_for_aggregation):
292300

293301
manager = Employee.manager(db)
294302

295-
manager.insert(Employee(name=Name("Alice"), salary=Salary(100000), department=Department("Engineering")))
296-
manager.insert(Employee(name=Name("Bob"), salary=Salary(60000), department=Department("Engineering")))
297-
manager.insert(Employee(name=Name("Carol"), salary=Salary(90000), department=Department("Marketing")))
303+
manager.insert(
304+
Employee(
305+
name=Name("Alice"), salary=Salary(100000), department=Department("Engineering")
306+
)
307+
)
308+
manager.insert(
309+
Employee(name=Name("Bob"), salary=Salary(60000), department=Department("Engineering"))
310+
)
311+
manager.insert(
312+
Employee(name=Name("Carol"), salary=Salary(90000), department=Department("Marketing"))
313+
)
298314

299315
# All employees - use filter() to get a Query that has count()
300316
all_count = manager.filter().count()

tests/integration/queries/test_social_network_queries.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
Unique,
3030
)
3131

32-
3332
# =============================================================================
3433
# Shared Attribute Types
3534
# =============================================================================
@@ -575,7 +574,7 @@ def test_insert_relation_with_person_author(self, schema_with_polymorphic_roles)
575574
# not the abstract declared type (Profile)
576575
author = authorings[0].author
577576
assert isinstance(author, Person), f"Expected Person, got {type(author).__name__}"
578-
assert not type(author) == Profile # Should NOT be the abstract type
577+
assert type(author) is not Profile # Should NOT be the abstract type
579578

580579
# Inherited attributes from Profile are accessible
581580
assert str(author.profile_id) == "alice"
@@ -616,7 +615,7 @@ def test_insert_relation_with_org_author(self, schema_with_polymorphic_roles):
616615
assert isinstance(author, Organization), (
617616
f"Expected Organization, got {type(author).__name__}"
618617
)
619-
assert not type(author) == Profile
618+
assert type(author) is not Profile
620619

621620
# Inherited attributes from Profile
622621
assert str(author.profile_id) == "techcorp"

tests/unit/generator/test_generator.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ def test_role_cardinality_exact(self) -> None:
545545
source = render_relations(schema, attr_names, entity_names, relation_names)
546546

547547
# Role with @card(2..2) should include cardinality=Card(2, 2)
548-
assert 'similar_memory: Role[entities.Memory] = Role("similar_memory", entities.Memory, cardinality=Card(2, 2))' in source
548+
assert (
549+
'similar_memory: Role[entities.Memory] = Role("similar_memory", entities.Memory, cardinality=Card(2, 2))'
550+
in source
551+
)
549552
assert "Card" in source
550553

551554
def test_role_cardinality_unbounded(self) -> None:
@@ -565,7 +568,10 @@ def test_role_cardinality_unbounded(self) -> None:
565568
source = render_relations(schema, attr_names, entity_names, relation_names)
566569

567570
# Role with @card(2..) should include cardinality=Card(2) (unbounded)
568-
assert 'member: Role[entities.Person] = Role("member", entities.Person, cardinality=Card(2))' in source
571+
assert (
572+
'member: Role[entities.Person] = Role("member", entities.Person, cardinality=Card(2))'
573+
in source
574+
)
569575

570576
def test_role_cardinality_bounded(self) -> None:
571577
"""Render relation with bounded role cardinality (@card(1..3))."""
@@ -587,7 +593,10 @@ def test_role_cardinality_bounded(self) -> None:
587593
source = render_relations(schema, attr_names, entity_names, relation_names)
588594

589595
# Role with @card(1..3) should include cardinality=Card(1, 3)
590-
assert 'reviewer: Role[entities.Reviewer] = Role("reviewer", entities.Reviewer, cardinality=Card(1, 3))' in source
596+
assert (
597+
'reviewer: Role[entities.Reviewer] = Role("reviewer", entities.Reviewer, cardinality=Card(1, 3))'
598+
in source
599+
)
591600
# Role with @card(1) is default, should not include Card
592601
assert 'document: Role[entities.Document] = Role("document", entities.Document)' in source
593602

tests/utils/assertions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def assert_entity_exists(db: Database, entity_type: type[Entity], **attrs) -> En
1212
def assert_entity_count(db: Database, entity_type: type[Entity], expected: int) -> None:
1313
"""Assert the count of entities matches expected."""
1414
manager = entity_type.manager(db)
15-
actual = manager.count()
15+
actual = len(manager.all())
1616
assert actual == expected, f"Expected {expected} {entity_type.__name__}, got {actual}"
1717

1818

@@ -27,5 +27,5 @@ def assert_relation_exists(db: Database, relation_type: type[Relation], **role_p
2727
def assert_relation_count(db: Database, relation_type: type[Relation], expected: int) -> None:
2828
"""Assert the count of relations matches expected."""
2929
manager = relation_type.manager(db)
30-
actual = manager.count()
30+
actual = len(manager.all())
3131
assert actual == expected, f"Expected {expected} {relation_type.__name__}, got {actual}"

tests/utils/data_builders.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def make_email(name: str | None = None) -> str:
2626
def make_isbn() -> str:
2727
"""Generate a fake ISBN-13."""
2828
import random
29+
2930
# Generate 12 random digits
3031
digits = [random.randint(0, 9) for _ in range(12)]
3132
# Calculate check digit (simplified)

0 commit comments

Comments
 (0)