Skip to content

Commit 387049b

Browse files
committed
[property] Move special_dtypes Definition to dtypes.py
Related to issue #318.
1 parent 70ebb0d commit 387049b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

odml/dtypes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def default_values(dtype):
6262

6363
_dtype_map = {'str': 'string', 'bool': 'boolean'}
6464

65+
special_dtypes = ["url", "person", "text"]
66+
6567

6668
def infer_dtype(value):
6769
dtype = (type(value)).__name__

odml/property.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,9 @@ def extend(self, obj, strict=True):
587587
return
588588

589589
new_value = self._convert_value_input(obj)
590-
special_dtypes = ["url", "person", "text"]
591590
if len(new_value) > 0 and strict and dtypes.infer_dtype(new_value[0]) != self.dtype:
592591

593-
if not (dtypes.infer_dtype(new_value[0]) == "string" and self.dtype in special_dtypes):
592+
if not (dtypes.infer_dtype(new_value[0]) == "string" and self.dtype in dtypes.special_dtypes):
594593
raise ValueError("odml.Property.extend: "
595594
"passed value data type does not match dtype!")
596595

@@ -620,10 +619,9 @@ def append(self, obj, strict=True):
620619
if len(new_value) > 1:
621620
raise ValueError("odml.property.append: Use extend to add a list of values!")
622621

623-
special_dtypes = ["url", "person", "text"]
624622
if len(new_value) > 0 and strict and dtypes.infer_dtype(new_value[0]) != self.dtype:
625623

626-
if not (dtypes.infer_dtype(new_value[0]) == "string" and self.dtype in special_dtypes):
624+
if not (dtypes.infer_dtype(new_value[0]) == "string" and self.dtype in dtypes.special_dtypes):
627625
raise ValueError("odml.Property.append: "
628626
"passed value data type does not match dtype!")
629627

0 commit comments

Comments
 (0)