Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring batch_format_link_properties to Utilize Optional Return Type for in-place Mutation #96

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions iyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
from datetime import datetime, time, timezone
from shutil import rmtree
from typing import Optional

from neo4j import GraphDatabase

Expand Down Expand Up @@ -38,7 +39,7 @@ def format_properties(prop):
return prop


def batch_format_link_properties(links: list, inplace=True) -> list:
def batch_format_link_properties(links: list, inplace=True) -> Optional[list]:
"""Helper function that applies format_properties to the relationship properties.

Warning: Formats properties in-place to save memory by default.
Expand All @@ -50,7 +51,6 @@ def batch_format_link_properties(links: list, inplace=True) -> list:
for link in links:
for idx, prop_dict in enumerate(link['props']):
link['props'][idx] = format_properties(prop_dict)
return links
mohamedawnallah marked this conversation as resolved.
Show resolved Hide resolved
return [{'src_id': link['src_id'],
'dst_id': link['dst_id'],
'props': [format_properties(d) for d in link['props']]}
Expand Down