diff --git a/funlib/persistence/graphs/pgsql_graph_database.py b/funlib/persistence/graphs/pgsql_graph_database.py index 5a2f4b2..dfbd58f 100644 --- a/funlib/persistence/graphs/pgsql_graph_database.py +++ b/funlib/persistence/graphs/pgsql_graph_database.py @@ -69,8 +69,8 @@ def __init__( nodes_table=nodes_table, edges_table=edges_table, endpoint_names=endpoint_names, - node_attrs=node_attrs, - edge_attrs=edge_attrs, + node_attrs=node_attrs, # type: ignore + edge_attrs=edge_attrs, # type: ignore ) def _drop_tables(self) -> None: @@ -101,12 +101,12 @@ def _create_tables(self) -> None: f"{self.nodes_table_name}({self.position_attribute})" ) - columns = list(self.edge_attrs.keys()) + columns = list(self.edge_attrs.keys()) # type: ignore types = list([self.__sql_type(t) for t in self.edge_attrs.values()]) column_types = [f"{c} {t}" for c, t in zip(columns, types)] self.__exec( f"CREATE TABLE IF NOT EXISTS {self.edges_table_name}(" - f"{self.endpoint_names[0]} BIGINT not null, " + f"{self.endpoint_names[0]} BIGINT not null, " # type: ignore f"{self.endpoint_names[1]} BIGINT not null, " f"{' '.join([c + ',' for c in column_types])}" f"PRIMARY KEY ({self.endpoint_names[0]}, {self.endpoint_names[1]})" diff --git a/funlib/persistence/graphs/sql_graph_database.py b/funlib/persistence/graphs/sql_graph_database.py index 3a4853b..03c1bc2 100644 --- a/funlib/persistence/graphs/sql_graph_database.py +++ b/funlib/persistence/graphs/sql_graph_database.py @@ -231,7 +231,7 @@ def read_graph( edges = self.read_edges( roi, nodes=nodes, read_attrs=edge_attrs, attr_filter=edges_filter ) - u, v = self.endpoint_names + u, v = self.endpoint_names # type: ignore try: edge_list = [(e[u], e[v], self.__remove_keys(e, [u, v])) for e in edges] except KeyError as e: @@ -373,11 +373,11 @@ def read_edges( return [] node_ids = ", ".join([str(node["id"]) for node in nodes]) - node_condition = f"{self.endpoint_names[0]} IN ({node_ids})" + node_condition = f"{self.endpoint_names[0]} IN ({node_ids})" # type: ignore logger.debug("Reading nodes in roi %s" % roi) # TODO: AND vs OR here - desired_columns = ", ".join(self.endpoint_names + list(self.edge_attrs.keys())) + desired_columns = ", ".join(self.endpoint_names + list(self.edge_attrs.keys())) # type: ignore select_statement = ( f"SELECT {desired_columns} FROM {self.edges_table_name} WHERE " + node_condition @@ -388,7 +388,7 @@ def read_edges( ) ) - edge_attrs = self.endpoint_names + ( + edge_attrs = self.endpoint_names + ( # type: ignore list(self.edge_attrs.keys()) if read_attrs is None else read_attrs ) attr_filter = attr_filter if attr_filter is not None else {} @@ -399,7 +399,7 @@ def read_edges( { key: val for key, val in zip( - self.endpoint_names + list(self.edge_attrs.keys()), values + self.endpoint_names + list(self.edge_attrs.keys()), values # type: ignore ) if key in edge_attrs } @@ -484,8 +484,8 @@ def update_edges( if not roi.contains(pos_u): logger.debug( ( - f"Skipping edge with {self.endpoint_names[0]} {{}}, {self.endpoint_names[1]} {{}}," - + f"and data {{}} because {self.endpoint_names[0]} not in roi {{}}" + f"Skipping edge with {self.endpoint_names[0]} {{}}, {self.endpoint_names[1]} {{}}," # type: ignore + + f"and data {{}} because {self.endpoint_names[0]} not in roi {{}}" # type: ignore ).format(u, v, data, roi) ) continue @@ -495,7 +495,7 @@ def update_edges( update_statement = ( f"UPDATE {self.edges_table_name} SET " f"{', '.join(setters)} WHERE " - f"{self.endpoint_names[0]}={u} AND {self.endpoint_names[1]}={v}" + f"{self.endpoint_names[0]}={u} AND {self.endpoint_names[1]}={v}" # type: ignore ) self._update_query(update_statement, commit=False) @@ -653,7 +653,7 @@ def __remove_keys(self, dictionary, keys): def __get_node_pos(self, n: dict[str, Any]) -> Optional[Coordinate]: try: - return Coordinate(n[self.position_attribute]) + return Coordinate(n[self.position_attribute]) # type: ignore except KeyError: return None @@ -677,7 +677,7 @@ def __attr_query(self, attrs: dict[str, Any]) -> str: def __roi_query(self, roi: Roi) -> str: query = "WHERE " pos_attr = self.position_attribute - for dim in range(self.ndims): + for dim in range(self.ndims): # type: ignore if dim > 0: query += " AND " if roi.begin[dim] is not None and roi.end[dim] is not None: diff --git a/funlib/persistence/graphs/sqlite_graph_database.py b/funlib/persistence/graphs/sqlite_graph_database.py index abed133..7925fb1 100644 --- a/funlib/persistence/graphs/sqlite_graph_database.py +++ b/funlib/persistence/graphs/sqlite_graph_database.py @@ -96,7 +96,7 @@ def _create_tables(self) -> None: f"{', '.join(node_columns)}" ")" ) - if self.ndims > 1: + if self.ndims > 1: # type: ignore position_columns = self.node_array_columns[self.position_attribute] else: position_columns = self.position_attribute @@ -104,8 +104,8 @@ def _create_tables(self) -> None: f"CREATE INDEX IF NOT EXISTS pos_index ON {self.nodes_table_name}({','.join(position_columns)})" ) edge_columns = [ - f"{self.endpoint_names[0]} INTEGER not null", - f"{self.endpoint_names[1]} INTEGER not null", + f"{self.endpoint_names[0]} INTEGER not null", # type: ignore + f"{self.endpoint_names[1]} INTEGER not null", # type: ignore ] for attr in self.edge_attrs.keys(): if attr in self.edge_array_columns: @@ -115,7 +115,7 @@ def _create_tables(self) -> None: self.cur.execute( f"CREATE TABLE IF NOT EXISTS {self.edges_table_name}(" + f"{', '.join(edge_columns)}" - + f", PRIMARY KEY ({self.endpoint_names[0]}, {self.endpoint_names[1]})" + + f", PRIMARY KEY ({self.endpoint_names[0]}, {self.endpoint_names[1]})" # type: ignore + ")" ) diff --git a/mypy.ini b/mypy.ini index 065fdfe..a44ef10 100644 --- a/mypy.ini +++ b/mypy.ini @@ -11,4 +11,7 @@ ignore_missing_imports = True ignore_missing_imports = True [mypy-h5py.*] +ignore_missing_imports = True + +[mypy-psycopg2.*] ignore_missing_imports = True \ No newline at end of file