diff --git a/ontopy/ontodoc.py b/ontopy/ontodoc.py index 802b75bd3..2d0045ebb 100644 --- a/ontopy/ontodoc.py +++ b/ontopy/ontodoc.py @@ -393,29 +393,29 @@ def itemdoc( if hasattr(item, "instances"): points = [] for instance in item.instances(): - try: - if item in instance.is_instance_of: - points.append( - point_style.format( - point=asstring(instance, link_style), - ontology=onto, - ) - ) - if points: - value = points_style.format( - points="".join(points), ontology=onto - ) - doc.append( - annotation_style.format( - key="Individuals", value=value, ontology=onto - ) - ) - except TypeError: + if isinstance(instance.is_instance_of, property): warnings.warn( f'Ignoring instance "{instance}" which is both and ' "indivudual and class. Ontodoc does not support " "punning at the present moment." ) + continue + if item in instance.is_instance_of: + points.append( + point_style.format( + point=asstring(instance, link_style), + ontology=onto, + ) + ) + if points: + value = points_style.format( + points="".join(points), ontology=onto + ) + doc.append( + annotation_style.format( + key="Individuals", value=value, ontology=onto + ) + ) return "\n".join(doc)