Commit 1636471a authored by Yannick DAYER's avatar Yannick DAYER
Browse files

gettatr to return None when attribute is missing.

parent 579ab80c
......@@ -15,15 +15,15 @@ SAMPLE_DATA_ATTRS = ("data", "samples")
def _copy_attributes(sample, parent, kwargs):
"""Copies attributes from a dictionary to self."""
if parent is not None:
if getattr(parent, "_delayed_attributes") is not None:
if getattr(parent, "_delayed_attributes", None) is not None:
setattr(sample, "_delayed_attributes", parent._delayed_attributes)
for key in parent.__dict__:
if key.startswith("_") or key in SAMPLE_DATA_ATTRS:
# Prevent the assignment of delayed attributes when copying
if getattr(parent, "_delayed_attributes") is not None and key in getattr(
parent, "_delayed_attributes"
if getattr(
parent, "_delayed_attributes", None
) is not None and key in getattr(parent, "_delayed_attributes"):
setattr(sample, key, None)
setattr(sample, key, getattr(parent, key))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment