Skip to content

Commit e042ee7

Browse files
committed
cleaned up docstring
1 parent e98ea54 commit e042ee7

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

synapseclient/extensions/curator/schema_generation.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ class ListColumnType(ColumnType):
114114
]
115115

116116

117+
# Translates list types to their atomic type
118+
LIST_TYPE_DICT = {
119+
ListColumnType.STRING_LIST: AtomicColumnType.STRING,
120+
ListColumnType.INTEGER_LIST: AtomicColumnType.INTEGER,
121+
ListColumnType.BOOLEAN_LIST: AtomicColumnType.BOOLEAN,
122+
}
123+
124+
117125
class JSONSchemaFormat(Enum):
118126
"""
119127
Allowed formats by the JSON Schema validator used by Synapse: https://github.com/everit-org/json-schema#format-validators
@@ -135,14 +143,6 @@ class JSONSchemaFormat(Enum):
135143
RELATIVE_JSON_POINTER = "relative-json-pointer"
136144

137145

138-
# Translates list types to their atomic type
139-
LIST_TYPE_DICT = {
140-
ListColumnType.STRING_LIST: AtomicColumnType.STRING,
141-
ListColumnType.INTEGER_LIST: AtomicColumnType.INTEGER,
142-
ListColumnType.BOOLEAN_LIST: AtomicColumnType.BOOLEAN,
143-
}
144-
145-
146146
class ValidationRuleName(Enum):
147147
"""Names of validation rules that are used to create JSON Schema"""
148148

@@ -655,6 +655,8 @@ def gather_csv_attributes_relationships(
655655

656656
# get attributes from Attribute column
657657
attributes = model_df.to_dict("records")
658+
659+
# Check for presence of optional columns
658660
model_includes_column_type = "columnType" in model_df.columns
659661
model_includes_format = "Format" in model_df.columns
660662

@@ -715,19 +717,19 @@ def parse_column_type(self, attr: dict) -> dict:
715717

716718
return {"ColumnType": column_type}
717719

718-
def parse_format(self, attr: dict) -> dict[str, str]:
719-
"""Parse the format for a given attribute.
720+
def parse_format(self, attribute_dict: dict) -> dict[str, str]:
721+
"""Finds the format value if it exists and returns it as a dictionary.
720722
721723
Args:
722-
attr: The attribute dictionary.
724+
attribute_dict: The attribute dictionary.
723725
724726
Returns:
725-
A dictionary containing the parsed column type information if present
727+
A dictionary containing the format value if it exists
726728
else an empty dict
727729
"""
728730
from pandas import isna
729731

730-
format_value = attr.get("Format")
732+
format_value = attribute_dict.get("Format")
731733

732734
if isna(format_value):
733735
return {}
@@ -736,7 +738,7 @@ def parse_format(self, attr: dict) -> dict[str, str]:
736738

737739
check_allowed_values(
738740
self.dmr,
739-
entry_id=attr["Format"],
741+
entry_id=attribute_dict["Format"],
740742
value=format_string,
741743
relationship="format",
742744
)

0 commit comments

Comments
 (0)