Skip to content

Commit

Permalink
lint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aMahanna committed Nov 13, 2023
1 parent dc9bf44 commit 2c3d636
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
18 changes: 8 additions & 10 deletions adbpyg_adapter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ def arangodb_graph_to_pyg(
:raise adbpyg_adapter.exceptions.ADBMetagraphError: If invalid metagraph.
"""
graph = self.__db.graph(name)
v_cols: Set[str] = graph.vertex_collections() # type: ignore
edge_definitions: List[Json] = graph.edge_definitions() # type: ignore
v_cols: Set[str] = graph.vertex_collections()
edge_definitions: List[Json] = graph.edge_definitions()
e_cols: Set[str] = {c["edge_collection"] for c in edge_definitions}

return self.arangodb_collections_to_pyg(
Expand Down Expand Up @@ -731,12 +731,12 @@ def get_aql_return_value(
)
"""

col_size: int = self.__db.collection(col).count() # type: ignore
col_size: int = self.__db.collection(col).count()

with get_export_spinner_progress(f"ADB Export: '{col}' ({col_size})") as p:
p.add_task(col)

cursor: Cursor = self.__db.aql.execute( # type: ignore
cursor: Cursor = self.__db.aql.execute(
f"FOR doc IN @@col RETURN {get_aql_return_value(meta)}",
bind_vars={"@col": col},
**{**adb_export_kwargs, **{"stream": True}},
Expand Down Expand Up @@ -785,7 +785,7 @@ def __process_adb_cursor(
with Live(Group(progress)):
i = 0
while not cursor.empty():
cursor_batch = len(cursor.batch()) # type: ignore
cursor_batch = len(cursor.batch())
df = DataFrame([cursor.pop() for _ in range(cursor_batch)])

i = process_adb_df(i, df, col, adb_map, meta, preserve_key, **kwargs)
Expand Down Expand Up @@ -1180,7 +1180,7 @@ def __create_adb_graph(
edge_definitions = self.__etypes_to_edefinitions(edge_types)
orphan_collections = self.__ntypes_to_ocollections(node_types, edge_types)

return self.__db.create_graph( # type: ignore[return-value]
return self.__db.create_graph(
name,
edge_definitions,
orphan_collections,
Expand Down Expand Up @@ -1239,8 +1239,7 @@ def __process_pyg_node_batch(

# 3. Apply the ArangoDB Node Controller (if provided)
if is_custom_controller:
f = lambda n: self.__cntrl._prepare_pyg_node(n, n_type)
df = df.apply(f, axis=1)
df = df.apply(lambda n: self.__cntrl._prepare_pyg_node(n, n_type), axis=1)

return df

Expand Down Expand Up @@ -1313,8 +1312,7 @@ def __process_pyg_edge_batch(

# 5. Apply the ArangoDB Edge Controller (if provided)
if is_custom_controller:
f = lambda e: self.__cntrl._prepare_pyg_edge(e, e_type)
df = df.apply(f, axis=1)
df = df.apply(lambda e: self.__cntrl._prepare_pyg_edge(e, e_type), axis=1)

return df

Expand Down
26 changes: 13 additions & 13 deletions tests/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class Bad_ADBPyG_Controller:
pass

with pytest.raises(TypeError):
ADBPyG_Adapter(bad_db) # type: ignore
ADBPyG_Adapter(bad_db)

with pytest.raises(TypeError):
ADBPyG_Adapter(db, Bad_ADBPyG_Controller()) # type: ignore
ADBPyG_Adapter(db, Bad_ADBPyG_Controller()) # type:ignore[arg-type]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -395,11 +395,11 @@ def test_pyg_to_arangodb_with_controller() -> None:

ADBPyG_Adapter(db, Custom_ADBPyG_Controller()).pyg_to_arangodb(name, data)

for doc in db.collection(f"{name}_N"): # type: ignore
for doc in db.collection(f"{name}_N"):
assert "foo" in doc
assert doc["foo"] == "bar"

for edge in db.collection(f"{name}_E"): # type: ignore
for edge in db.collection(f"{name}_E"):
assert "bar" in edge
assert edge["bar"] == "foo"

Expand Down Expand Up @@ -649,8 +649,8 @@ def test_adb_graph_to_pyg(
pyg_g_new = adapter.arangodb_graph_to_pyg(name)

graph = db.graph(name)
v_cols: Set[str] = graph.vertex_collections() # type: ignore
edge_definitions: List[Json] = graph.edge_definitions() # type: ignore
v_cols: Set[str] = graph.vertex_collections()
edge_definitions: List[Json] = graph.edge_definitions()
e_cols: Set[str] = {c["edge_collection"] for c in edge_definitions}

# Manually set the number of nodes (since nodes are feature-less)
Expand Down Expand Up @@ -683,8 +683,8 @@ def test_adb_graph_to_pyg_to_arangodb_with_missing_document_and_strict(
ADBPyG_Adapter(db).pyg_to_arangodb(name, data)

graph = db.graph(name)
v_cols: Set[str] = graph.vertex_collections() # type: ignore
edge_definitions: List[Json] = graph.edge_definitions() # type: ignore
v_cols: Set[str] = graph.vertex_collections()
edge_definitions: List[Json] = graph.edge_definitions()
e_cols: Set[str] = {c["edge_collection"] for c in edge_definitions}

for v_col in v_cols:
Expand Down Expand Up @@ -713,8 +713,8 @@ def test_adb_graph_to_pyg_to_arangodb_with_missing_document_and_permissive(
ADBPyG_Adapter(db).pyg_to_arangodb(name, data)

graph = db.graph(name)
v_cols: Set[str] = graph.vertex_collections() # type: ignore
edge_definitions: List[Json] = graph.edge_definitions() # type: ignore
v_cols: Set[str] = graph.vertex_collections()
edge_definitions: List[Json] = graph.edge_definitions()
e_cols: Set[str] = {c["edge_collection"] for c in edge_definitions}

for v_col in v_cols:
Expand All @@ -728,7 +728,7 @@ def test_adb_graph_to_pyg_to_arangodb_with_missing_document_and_permissive(

data = adapter.arangodb_to_pyg(name, metagraph=metagraph, strict=False)

collection_count: int = db.collection(list(e_cols)[0]).count() # type: ignore
collection_count: int = db.collection(list(e_cols)[0]).count()
assert len(data.edge_index[0]) < collection_count

db.delete_graph(name, drop_collections=True)
Expand Down Expand Up @@ -799,8 +799,8 @@ def test_full_cycle_homogeneous_with_preserve_adb_keys() -> None:
pyg_g = adbpyg_adapter.arangodb_graph_to_pyg(name, preserve_adb_keys=True)

graph = db.graph(name)
v_cols: Set[str] = graph.vertex_collections() # type: ignore
edge_definitions: List[Json] = graph.edge_definitions() # type: ignore
v_cols: Set[str] = graph.vertex_collections()
edge_definitions: List[Json] = graph.edge_definitions()
e_cols: Set[str] = {c["edge_collection"] for c in edge_definitions}

metagraph: ADBMetagraph = {
Expand Down

0 comments on commit 2c3d636

Please sign in to comment.