From 5ccdf187d5c312dfba77ba9085989f1d9876ba9a Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 3 Jun 2024 12:25:05 +0500 Subject: [PATCH] change type of exception when setting non-optional property to TypeError TypeError is more correct since error occurs when user is trying to set some attribute value with None while atttribute doesn't support None type. ValueError is typically raised when provided value has a correct type but unsupported value. --- src/ifcopenshell-python/ifcopenshell/entity_instance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index de3ce535a6..5de590b9f5 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -332,7 +332,7 @@ class entity_instance: self.wrapped_data.setArgumentAsNull(idx) except RuntimeError as e: if e.args == ("Attribute not set",): - raise ValueError( + raise TypeError( "attribute '%s' is not optional for entity instance of type '%s'" % (self.wrapped_data.get_argument_name(idx), self.wrapped_data.is_a(True)) )