Skip to content

Commit

Permalink
Merge pull request #4 from ncotie/io_mod_v1
Browse files Browse the repository at this point in the history
After lint testing with automatic change
  • Loading branch information
ncotie authored Oct 19, 2023
2 parents 2b99561 + 3dd168b commit 972d0e9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions osmnx/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,12 @@ def _convert_node_attr_types(G, dtypes=None):
# edge attributes might have a single value, or a list if simplified
for attr, value in data.items():
# check for stringified lists
if ((value.startswith("[") and value.endswith("]"))
or (value.startswith("{") and value.endswith("}"))):
if (value.startswith("[") and value.endswith("]")) or (
value.startswith("{") and value.endswith("}")
):
with contextlib.suppress(SyntaxError, ValueError):
data[attr] = ast.literal_eval(value)

for attr in data.keys() & dtypes.keys():
data[attr] = dtypes[attr](data[attr])
return G
Expand Down Expand Up @@ -458,8 +459,9 @@ def _convert_edge_attr_types(G, dtypes=None):
# first, eval stringified lists, dicts or sets to convert them to objects
# edge attributes might have a single value, or a list if simplified
for attr, value in data.items():
if ((value.startswith("[") and value.endswith("]"))
or (value.startswith("{") and value.endswith("}"))):
if (value.startswith("[") and value.endswith("]")) or (
value.startswith("{") and value.endswith("}")
):
with contextlib.suppress(SyntaxError, ValueError):
data[attr] = ast.literal_eval(value)

Expand Down

0 comments on commit 972d0e9

Please sign in to comment.