Skip to content

Commit 78042b0

Browse files
committed
[property] PEP8 code cleanup
This commit fixes the following PEP98 code warnings: - no-else-return - no-else-raise - protected-access (section._merged) - no-self-use (_convert_value_input -> staticmethod)
1 parent 0629dce commit 78042b0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

odml/property.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ def parent(self):
253253
def parent(self, new_parent):
254254
if new_parent is None and self._parent is None:
255255
return
256-
elif new_parent is None and self._parent is not None:
256+
257+
if new_parent is None and self._parent is not None:
257258
self._parent.remove(self)
258259
self._parent = None
259260
elif self._validate_parent(new_parent):
@@ -319,7 +320,8 @@ def _validate_values(self, values):
319320
return False
320321
return True
321322

322-
def _convert_value_input(self, new_value):
323+
@staticmethod
324+
def _convert_value_input(new_value):
323325
"""
324326
This method ensures, that the passed new value is a list.
325327
If new_value is a string, it will convert it to a list of
@@ -403,14 +405,12 @@ def values(self, new_value):
403405
new_value = odml_tuple_import(t_count, new_value)
404406

405407
if not self._validate_values(new_value):
408+
msg = "odml.Property.values: passed values are not of consistent type"
406409
if self._dtype in ("date", "time", "datetime"):
407410
req_format = dtypes.default_values(self._dtype)
408-
msg = "odml.Property.values: passed values are not of consistent type "
409-
msg += "\'%s\'! Format should be \'%s\'." % (self._dtype, req_format)
410-
raise ValueError(msg)
411-
else:
412-
msg = "odml.Property.values: passed values are not of consistent type!"
413-
raise ValueError(msg)
411+
msg += " \'%s\'! Format should be \'%s\'." % (self._dtype, req_format)
412+
raise ValueError(msg)
413+
414414
self._values = [dtypes.get(v, self.dtype) for v in new_value]
415415

416416
# Validate and inform user if the current values cardinality is violated
@@ -714,10 +714,10 @@ def get_merged_equivalent(self):
714714
Return the merged object (i.e. if the parent section is linked to another one,
715715
return the corresponding property of the linked section) or None.
716716
"""
717-
if self.parent is None or self.parent._merged is None:
717+
if self.parent is None or not self.parent.is_merged:
718718
return None
719719

720-
return self.parent._merged.contains(self)
720+
return self.parent.get_merged_equivalent().contains(self)
721721

722722
@inherit_docstring
723723
def get_terminology_equivalent(self):

0 commit comments

Comments
 (0)