Skip to content

Commit d868e9c

Browse files
committed
refactor for mypy
1 parent a6360b0 commit d868e9c

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

infrahub_sdk/client.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -566,17 +566,20 @@ async def count(
566566
**kwargs: Any,
567567
) -> int:
568568
"""Return the number of nodes of a given kind."""
569-
filters = kwargs
570-
schema = await self.schema.get(kind=kind, branch=branch)
569+
filters: dict[str, Any] = dict(kwargs)
570+
571+
if partial_match:
572+
filters["partial_match"] = True
571573

574+
schema = await self.schema.get(kind=kind, branch=branch)
572575
branch = branch or self.default_branch
573576
if at:
574577
at = Timestamp(at)
575578

576-
data = {"count": None, "@filters": filters}
577-
578-
if partial_match:
579-
data["@filters"]["partial_match"] = True
579+
data: dict[str, Any] = {
580+
"count": None,
581+
"@filters": filters,
582+
}
580583

581584
response = await self.execute_graphql(
582585
query=Query(query={schema.kind: data}).render(),
@@ -1693,16 +1696,20 @@ def count(
16931696
**kwargs: Any,
16941697
) -> int:
16951698
"""Return the number of nodes of a given kind."""
1696-
filters = kwargs
1697-
schema = self.schema.get(kind=kind, branch=branch)
1699+
filters: dict[str, Any] = dict(kwargs)
1700+
1701+
if partial_match:
1702+
filters["partial_match"] = True
16981703

1704+
schema = self.schema.get(kind=kind, branch=branch)
16991705
branch = branch or self.default_branch
17001706
if at:
17011707
at = Timestamp(at)
17021708

1703-
data = {"count": None, "@filters": filters}
1704-
if partial_match:
1705-
data["@filters"]["partial_match"] = True
1709+
data: dict[str, Any] = {
1710+
"count": None,
1711+
"@filters": filters,
1712+
}
17061713

17071714
response = self.execute_graphql(
17081715
query=Query(query={schema.kind: data}).render(),
@@ -1712,6 +1719,7 @@ def count(
17121719
)
17131720
return int(response.get(schema.kind, {}).get("count", 0))
17141721

1722+
17151723
@overload
17161724
def all(
17171725
self,

0 commit comments

Comments
 (0)