Skip to content

Commit a398c32

Browse files
committed
Whitespace
1 parent b10604f commit a398c32

3 files changed

Lines changed: 24 additions & 8 deletions

File tree

terminusdb_client/schema/schema.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ def _check_cycling(class_obj: "TerminusClass"):
8686
mro_names = [obj.__name__ for obj in class_obj.__mro__]
8787
for prop_type in class_obj._annotations.values():
8888
# Handle both string annotations and type objects
89-
type_name = prop_type if isinstance(prop_type, str) else getattr(prop_type, '__name__', str(prop_type))
89+
type_name = (
90+
prop_type
91+
if isinstance(prop_type, str)
92+
else getattr(prop_type, "__name__", str(prop_type))
93+
)
9094
if type_name in mro_names:
9195
raise RecursionError(f"Embbding {prop_type} cause recursions.")
9296

terminusdb_client/scripts/scripts.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
from ..woqlschema.woql_schema import WOQLSchema
2020

2121

22-
def _df_to_schema(class_name, df, np, embedded=None, id_col=None, na_mode=None, keys=None):
22+
def _df_to_schema(
23+
class_name, df, np, embedded=None, id_col=None, na_mode=None, keys=None
24+
):
2325
"""Convert a pandas DataFrame to a TerminusDB schema class definition.
2426
2527
Args:
@@ -41,9 +43,7 @@ def _df_to_schema(class_name, df, np, embedded=None, id_col=None, na_mode=None,
4143

4244
class_dict = {"@type": "Class", "@id": class_name}
4345
np_to_builtin = {
44-
v: getattr(builtins, k)
45-
for k, v in np.sctypeDict.items()
46-
if k in vars(builtins)
46+
v: getattr(builtins, k) for k, v in np.sctypeDict.items() if k in vars(builtins)
4747
}
4848
np_to_builtin[np.datetime64] = dt.datetime
4949

@@ -512,7 +512,15 @@ def importcsv(
512512
converted_col = col.lower().replace(" ", "_").replace(".", "_")
513513
df.rename(columns={col: converted_col}, inplace=True)
514514
if not has_schema:
515-
class_dict = _df_to_schema(class_name, df, np, embedded=embedded, id_col=id_, na_mode=na, keys=keys)
515+
class_dict = _df_to_schema(
516+
class_name,
517+
df,
518+
np,
519+
embedded=embedded,
520+
id_col=id_,
521+
na_mode=na,
522+
keys=keys,
523+
)
516524
if message is None:
517525
schema_msg = f"Schema object insert/ update with {csv_file} by Python client."
518526
else:

terminusdb_client/woqldataframe/woqlDataframe.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def _embed_obj(df, maxdep, pd, keepid, all_existing_class, class_obj, client):
7575
):
7676
return finish_df
7777
else:
78-
return _embed_obj(finish_df, maxdep - 1, pd, keepid, all_existing_class, class_obj, client)
78+
return _embed_obj(
79+
finish_df, maxdep - 1, pd, keepid, all_existing_class, class_obj, client
80+
)
7981

8082

8183
def result_to_df(all_records, keepid=False, max_embed_dep=0, client=None):
@@ -111,5 +113,7 @@ def result_to_df(all_records, keepid=False, max_embed_dep=0, client=None):
111113
raise InterfaceError(
112114
f"{class_obj} not found in database ({client.db}) schema.'"
113115
)
114-
df = _embed_obj(df, max_embed_dep, pd, keepid, all_existing_class, class_obj, client)
116+
df = _embed_obj(
117+
df, max_embed_dep, pd, keepid, all_existing_class, class_obj, client
118+
)
115119
return df

0 commit comments

Comments
 (0)