Skip to content

Commit 72481ab

Browse files
committed
Fix linting violations after merge
1 parent 1e2a513 commit 72481ab

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

tests/unit/sdk/test_hierarchical_nodes.py

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88

99
from infrahub_sdk.node import InfrahubNode, InfrahubNodeSync
10-
from infrahub_sdk.schema import NodeSchema
10+
from infrahub_sdk.schema import NodeSchema, NodeSchemaAPI
1111

1212
if TYPE_CHECKING:
1313
from infrahub_sdk import InfrahubClient, InfrahubClientSync
@@ -16,7 +16,7 @@
1616

1717

1818
@pytest.fixture
19-
async def hierarchical_schema():
19+
async def hierarchical_schema() -> NodeSchemaAPI:
2020
"""Schema for a hierarchical location node with hierarchy support."""
2121
data = {
2222
"name": "Location",
@@ -43,7 +43,7 @@ async def hierarchical_schema():
4343
},
4444
],
4545
}
46-
schema_api = NodeSchema(**data).convert_api() # type: ignore
46+
schema_api = NodeSchema(**data).convert_api()
4747
# Set hierarchy field manually since it's not part of NodeSchema but only NodeSchemaAPI
4848
# This field would normally be set by the backend
4949
schema_api.hierarchy = "InfraLocation"
@@ -53,7 +53,7 @@ async def hierarchical_schema():
5353
@pytest.mark.parametrize("client_type", ["standard", "sync"])
5454
async def test_hierarchical_node_has_hierarchy_support(
5555
client: InfrahubClient, client_sync: InfrahubClientSync, hierarchical_schema, client_type
56-
):
56+
) -> None:
5757
"""Test that hierarchical nodes are properly detected and support parent/children/ancestors/descendants."""
5858
if client_type == "standard":
5959
node = InfrahubNode(client=client, schema=hierarchical_schema)
@@ -68,7 +68,7 @@ async def test_hierarchical_node_has_hierarchy_support(
6868
@pytest.mark.parametrize("client_type", ["standard", "sync"])
6969
async def test_hierarchical_node_has_all_hierarchical_fields(
7070
client: InfrahubClient, client_sync: InfrahubClientSync, hierarchical_schema, client_type
71-
):
71+
) -> None:
7272
"""Test that hierarchical nodes have parent, children, ancestors and descendants attributes."""
7373
if client_type == "standard":
7474
node = InfrahubNode(client=client, schema=hierarchical_schema)
@@ -111,7 +111,7 @@ async def test_hierarchical_node_has_all_hierarchical_fields(
111111
@pytest.mark.parametrize("client_type", ["standard", "sync"])
112112
async def test_hierarchical_node_with_parent_data(
113113
client: InfrahubClient, client_sync: InfrahubClientSync, hierarchical_schema, client_type
114-
):
114+
) -> None:
115115
"""Test that hierarchical nodes can be initialized with parent data."""
116116
data = {
117117
"id": "location-1",
@@ -134,7 +134,7 @@ async def test_hierarchical_node_with_parent_data(
134134
@pytest.mark.parametrize("client_type", ["standard", "sync"])
135135
async def test_hierarchical_node_with_children_data(
136136
client: InfrahubClient, client_sync: InfrahubClientSync, hierarchical_schema, client_type
137-
):
137+
) -> None:
138138
"""Test that hierarchical nodes can be initialized with children data."""
139139
data = {
140140
"id": "location-1",
@@ -165,7 +165,7 @@ async def test_hierarchical_node_with_children_data(
165165
@pytest.mark.parametrize("client_type", ["standard", "sync"])
166166
async def test_hierarchical_node_with_ancestors_data(
167167
client: InfrahubClient, client_sync: InfrahubClientSync, hierarchical_schema, client_type
168-
):
168+
) -> None:
169169
"""Test that hierarchical nodes can be initialized with ancestors data."""
170170
data = {
171171
"id": "location-1",
@@ -196,7 +196,7 @@ async def test_hierarchical_node_with_ancestors_data(
196196
@pytest.mark.parametrize("client_type", ["standard", "sync"])
197197
async def test_hierarchical_node_with_descendants_data(
198198
client: InfrahubClient, client_sync: InfrahubClientSync, hierarchical_schema, client_type
199-
):
199+
) -> None:
200200
"""Test that hierarchical nodes can be initialized with descendants data."""
201201
data = {
202202
"id": "location-1",
@@ -230,7 +230,7 @@ async def test_hierarchical_node_with_descendants_data(
230230
@pytest.mark.parametrize("client_type", ["standard", "sync"])
231231
async def test_non_hierarchical_node_no_hierarchical_fields(
232232
client: InfrahubClient, client_sync: InfrahubClientSync, location_schema, client_type
233-
):
233+
) -> None:
234234
"""Test that non-hierarchical nodes don't have parent/children/ancestors/descendants."""
235235
if client_type == "standard":
236236
node = InfrahubNode(client=client, schema=location_schema)
@@ -254,7 +254,7 @@ async def test_non_hierarchical_node_no_hierarchical_fields(
254254
_ = node.descendants
255255

256256

257-
async def test_hierarchical_node_query_generation_includes_parent(client: InfrahubClient, hierarchical_schema):
257+
async def test_hierarchical_node_query_generation_includes_parent(client: InfrahubClient, hierarchical_schema) -> None:
258258
"""Test that query generation includes parent when requested."""
259259
# Pre-populate schema cache to avoid fetching from server
260260
cache_data = {
@@ -276,7 +276,9 @@ async def test_hierarchical_node_query_generation_includes_parent(client: Infrah
276276
assert "...on InfraLocation" in query_data["parent"]["node"]
277277

278278

279-
async def test_hierarchical_node_query_generation_includes_children(client: InfrahubClient, hierarchical_schema):
279+
async def test_hierarchical_node_query_generation_includes_children(
280+
client: InfrahubClient, hierarchical_schema
281+
) -> None:
280282
"""Test that query generation includes children when requested."""
281283
# Pre-populate schema cache to avoid fetching from server
282284
cache_data = {
@@ -299,7 +301,9 @@ async def test_hierarchical_node_query_generation_includes_children(client: Infr
299301
assert "...on InfraLocation" in query_data["children"]["edges"]["node"]
300302

301303

302-
async def test_hierarchical_node_query_generation_includes_ancestors(client: InfrahubClient, hierarchical_schema):
304+
async def test_hierarchical_node_query_generation_includes_ancestors(
305+
client: InfrahubClient, hierarchical_schema
306+
) -> None:
303307
"""Test that query generation includes ancestors when requested."""
304308
# Pre-populate schema cache to avoid fetching from server
305309
cache_data = {
@@ -322,7 +326,9 @@ async def test_hierarchical_node_query_generation_includes_ancestors(client: Inf
322326
assert "...on InfraLocation" in query_data["ancestors"]["edges"]["node"]
323327

324328

325-
async def test_hierarchical_node_query_generation_includes_descendants(client: InfrahubClient, hierarchical_schema):
329+
async def test_hierarchical_node_query_generation_includes_descendants(
330+
client: InfrahubClient, hierarchical_schema
331+
) -> None:
326332
"""Test that query generation includes descendants when requested."""
327333
# Pre-populate schema cache to avoid fetching from server
328334
cache_data = {
@@ -345,7 +351,9 @@ async def test_hierarchical_node_query_generation_includes_descendants(client: I
345351
assert "...on InfraLocation" in query_data["descendants"]["edges"]["node"]
346352

347353

348-
async def test_hierarchical_node_query_generation_prefetch_relationships(client: InfrahubClient, hierarchical_schema):
354+
async def test_hierarchical_node_query_generation_prefetch_relationships(
355+
client: InfrahubClient, hierarchical_schema
356+
) -> None:
349357
"""Test that query generation includes all hierarchical fields with prefetch_relationships=True."""
350358
# Pre-populate schema cache to avoid fetching from server
351359
cache_data = {
@@ -366,7 +374,7 @@ async def test_hierarchical_node_query_generation_prefetch_relationships(client:
366374
assert "descendants" in query_data
367375

368376

369-
async def test_hierarchical_node_query_generation_exclude(client: InfrahubClient, hierarchical_schema):
377+
async def test_hierarchical_node_query_generation_exclude(client: InfrahubClient, hierarchical_schema) -> None:
370378
"""Test that query generation respects exclude for hierarchical fields."""
371379
# Pre-populate schema cache to avoid fetching from server
372380
cache_data = {
@@ -387,7 +395,9 @@ async def test_hierarchical_node_query_generation_exclude(client: InfrahubClient
387395
assert "descendants" in query_data
388396

389397

390-
def test_hierarchical_node_sync_query_generation_includes_parent(client_sync: InfrahubClientSync, hierarchical_schema):
398+
def test_hierarchical_node_sync_query_generation_includes_parent(
399+
client_sync: InfrahubClientSync, hierarchical_schema
400+
) -> None:
391401
"""Test that sync query generation includes parent when requested."""
392402
# Set schema in cache to avoid HTTP request
393403
cache_data = {
@@ -411,7 +421,7 @@ def test_hierarchical_node_sync_query_generation_includes_parent(client_sync: In
411421

412422
def test_hierarchical_node_sync_query_generation_includes_children(
413423
client_sync: InfrahubClientSync, hierarchical_schema
414-
):
424+
) -> None:
415425
"""Test that sync query generation includes children when requested."""
416426
# Set schema in cache to avoid HTTP request
417427
cache_data = {
@@ -436,7 +446,7 @@ def test_hierarchical_node_sync_query_generation_includes_children(
436446

437447
def test_hierarchical_node_sync_query_generation_includes_ancestors(
438448
client_sync: InfrahubClientSync, hierarchical_schema
439-
):
449+
) -> None:
440450
"""Test that sync query generation includes ancestors when requested."""
441451
# Set schema in cache to avoid HTTP request
442452
cache_data = {
@@ -461,7 +471,7 @@ def test_hierarchical_node_sync_query_generation_includes_ancestors(
461471

462472
def test_hierarchical_node_sync_query_generation_includes_descendants(
463473
client_sync: InfrahubClientSync, hierarchical_schema
464-
):
474+
) -> None:
465475
"""Test that sync query generation includes descendants when requested."""
466476
# Set schema in cache to avoid HTTP request
467477
cache_data = {
@@ -484,7 +494,9 @@ def test_hierarchical_node_sync_query_generation_includes_descendants(
484494
assert "...on InfraLocation" in query_data["descendants"]["edges"]["node"]
485495

486496

487-
async def test_hierarchical_node_no_infinite_recursion_with_children(client: InfrahubClient, hierarchical_schema):
497+
async def test_hierarchical_node_no_infinite_recursion_with_children(
498+
client: InfrahubClient, hierarchical_schema
499+
) -> None:
488500
"""Test that including children does not cause infinite recursion."""
489501
# Pre-populate schema cache to avoid fetching from server
490502
cache_data = {
@@ -510,7 +522,7 @@ async def test_hierarchical_node_no_infinite_recursion_with_children(client: Inf
510522

511523
def test_hierarchical_node_sync_no_infinite_recursion_with_children(
512524
client_sync: InfrahubClientSync, hierarchical_schema
513-
):
525+
) -> None:
514526
"""Test that including children does not cause infinite recursion in sync mode."""
515527
# Set schema in cache to avoid HTTP request
516528
cache_data = {

0 commit comments

Comments
 (0)