Skip to content

Commit fb5ff72

Browse files
fixing typing issues (#316)
1 parent 40e1e18 commit fb5ff72

30 files changed

Lines changed: 1115 additions & 929 deletions

.cursorignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838
!*.md
3939
!.pre-commit-config.yaml
4040
!run-tests.sh
41-
41+
!precommit.log
4242

4343

graflo/architecture/graph_types/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class ExtractionContext(ConfigBaseModel):
103103
edge_intents: Explicit edge intents for assembly phase
104104
"""
105105

106-
model_config = ConfigDict(kw_only=True) # type: ignore[assignment]
106+
model_config = ConfigDict(kw_only=True) # ty: ignore[invalid-key]
107107

108108
# Pydantic cannot schema nested defaultdict with custom key types (e.g. LocationIndex),
109109
# so we use Any; runtime type is as documented in Attributes
@@ -185,7 +185,7 @@ def record_transform_failure(
185185
class AssemblyContext(ConfigBaseModel):
186186
"""Assembly-phase context built from extraction outputs."""
187187

188-
model_config = ConfigDict(kw_only=True) # type: ignore[assignment]
188+
model_config = ConfigDict(kw_only=True) # ty: ignore[invalid-key]
189189

190190
extraction: ExtractionContext
191191
acc_global: Any = Field(default_factory=dd_factory)

graflo/architecture/graph_types/transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class VertexRep(ConfigBaseModel):
1616
vertex: doc representing a vertex
1717
"""
1818

19-
model_config = ConfigDict(kw_only=True) # type: ignore[assignment]
19+
model_config = ConfigDict(kw_only=True) # ty: ignore[invalid-key]
2020

2121
vertex: dict[str, Any]
2222

graflo/architecture/pipeline/runtime/actor/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _filter_items(self, items: dict[str, object]) -> dict[str, object]:
7979
def _stringify_items(self, items: dict[str, object]) -> dict[str, str]:
8080
"""Convert items to string representation."""
8181
return {
82-
k: ", ".join(list(v)) if isinstance(v, (tuple, list)) else str(v)
82+
k: ", ".join(str(x) for x in v) if isinstance(v, (tuple, list)) else str(v)
8383
for k, v in items.items()
8484
}
8585

graflo/architecture/pipeline/runtime/actor/vertex_router.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,14 @@ def _get_or_create_wrapper(self, vertex_type: str) -> "ActorWrapper | None":
9292
per_type_from = self.vertex_from_map[vertex_type]
9393
else:
9494
per_type_from = self.from_doc
95-
config = VertexActorConfig(
96-
vertex=vertex_type,
97-
from_doc=per_type_from,
98-
keep_fields=list(self.keep_fields) if self.keep_fields else None,
99-
extraction_scope=self.extraction_scope,
95+
config = VertexActorConfig.model_validate(
96+
{
97+
"type": "vertex",
98+
"vertex": vertex_type,
99+
"from": per_type_from,
100+
"keep_fields": list(self.keep_fields) if self.keep_fields else None,
101+
"extraction_scope": self.extraction_scope,
102+
}
100103
)
101104
wrapper = ActorWrapper.from_config(config)
102105
wrapper.finish_init(self._init_ctx)

graflo/data_source/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class APIConfig(ConfigBaseModel):
4444
method: str = "GET"
4545
headers: dict[str, str] = Field(default_factory=dict)
4646
auth: ApiAuth | None = None
47-
params: dict[str, object] = Field(default_factory=dict)
47+
params: dict[str, Any] = Field(default_factory=dict)
4848
timeout: float | None = None
4949
retries: int = 0
5050
retry_backoff_factor: float = 0.1

graflo/db/falkordb/conn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,15 +832,15 @@ def fetch_edges(
832832
target_match = "(target)"
833833

834834
# Build WHERE clauses
835-
where_clauses = []
835+
where_clauses: list[str] = []
836836
if to_id:
837837
where_clauses.append(f"target.id = '{to_id}'")
838838

839839
# Add additional filters if provided
840840
if filters is not None:
841841
ff = FilterExpression.from_dict(filters)
842842
filter_clause = ff(doc_name="r", kind=self.expression_flavor())
843-
where_clauses.append(filter_clause)
843+
where_clauses.append(str(filter_clause))
844844

845845
where_clause = f"WHERE {' AND '.join(where_clauses)}" if where_clauses else ""
846846

graflo/db/memgraph/conn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
from typing import Any
8282
from urllib.parse import urlparse
8383

84-
import mgclient # type: ignore[import-untyped]
84+
import mgclient # ty: ignore[unresolved-import]
8585

8686
from graflo.architecture.schema.edge import Edge
8787
from graflo.architecture.graph_types import Index
@@ -1026,15 +1026,15 @@ def fetch_edges(
10261026
q += f" {rel_pattern} {target_match}"
10271027

10281028
# Build WHERE clauses
1029-
where_clauses = []
1029+
where_clauses: list[str] = []
10301030
if to_id:
10311031
where_clauses.append("t.id = $to_id")
10321032

10331033
# Add relationship property filters
10341034
if filters is not None:
10351035
ff = FilterExpression.from_dict(filters)
10361036
filter_str = ff(doc_name="r", kind=self.expression_flavor())
1037-
where_clauses.append(filter_str)
1037+
where_clauses.append(str(filter_str))
10381038

10391039
if where_clauses:
10401040
q += f" WHERE {' AND '.join(where_clauses)}"

graflo/db/neo4j/conn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,15 +721,15 @@ def fetch_edges(
721721
target_match = "(target)"
722722

723723
# Add target ID filter if provided
724-
where_clauses = []
724+
where_clauses: list[str] = []
725725
if to_id:
726726
where_clauses.append(f"target.id = '{to_id}'")
727727

728728
# Add additional filters if provided
729729
if filters is not None:
730730
ff = FilterExpression.from_dict(filters)
731731
filter_clause = ff(doc_name="r", kind=self.expression_flavor())
732-
where_clauses.append(filter_clause)
732+
where_clauses.append(str(filter_clause))
733733

734734
where_clause = f"WHERE {' AND '.join(where_clauses)}" if where_clauses else ""
735735

graflo/db/tigergraph/auth.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,22 @@ def _get_token_from_secret(
227227
raise ValueError(f"No token in response: {result}")
228228

229229
except requests.exceptions.HTTPError as e:
230+
response = e.response
231+
status_code = response.status_code if response is not None else None
230232
# Track if this was a 404 error
231-
if e.response.status_code != 404:
233+
if status_code != 404:
232234
all_404_errors = False
233235

234236
# If 404 and we have more endpoints to try, continue
235-
if e.response.status_code == 404 and len(endpoints_to_try) > 1:
237+
if status_code == 404 and len(endpoints_to_try) > 1:
236238
logger.debug(
237239
f"Endpoint {url} returned 404, trying next endpoint..."
238240
)
239241
last_error = e
240242
continue
241243
# For other HTTP errors, log and try next endpoint if available
242-
logger.debug(
243-
f"HTTP error {e.response.status_code} on {url}: {e.response.text}"
244-
)
244+
response_text = response.text if response is not None else ""
245+
logger.debug(f"HTTP error {status_code} on {url}: {response_text}")
245246
last_error = e
246247
continue
247248
except Exception as e:

0 commit comments

Comments
 (0)