You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def instance(self):
"""
Retrieve the single (expected) instance of this 'Part' (of `Category.MODEL`) as a 'Part'.
See `Part.instances()` method for documentation.
:return: pykechain.models.Part
:raises: NotFoundError, MultipleFoundError
"""
instances_list = list(self.instances())
if len(instances_list) == 1:
return instances_list[0]
else:
raise MultipleFoundError("Part {} has more than a single instance. "
"Use the `Part.instances()` method".format(self.name))
It should look something like this:
def instance(self):
"""
Retrieve the single (expected) instance of this 'Part' (of `Category.MODEL`) as a 'Part'.
See `Part.instances()` method for documentation.
:return: pykechain.models.Part
:raises: NotFoundError, MultipleFoundError
"""
instances_list = list(self.instances())
if len(instances_list) == 1:
return instances_list[0]
elif len(instances_list) > 1:
raise MultipleFoundError("Part {} has more than a single instance. "
"Use the `Part.instances()` method".format(self.name))
elif len(instances_list) < 1:
raise NotFoundError("Part {} has no instance. "
"Use the `Part.instances()` method".format(self.name))
The text was updated successfully, but these errors were encountered:
The code looks like this:
It should look something like this:
The text was updated successfully, but these errors were encountered: