diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 85ed00125a..abb6a67872 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -197,9 +197,7 @@ class entity_instance_mixin: except IndexError as e: # get_argument_index returns 0xFFFFFFFF if attribute is not found if index == 0xFFFFFFFF: - raise AttributeError( - "entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), key) - ) + raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), key)) raise e def __getitem__(self, key: int) -> Any: @@ -210,18 +208,17 @@ class entity_instance_mixin: def __setitem__(self, idx: int, value: T) -> T: if self.file and self.file.transaction: self.file.transaction.store_edit(self, idx, value) - + self.set_attribute_value_py(idx, value) return value - def __eq__(self, other: entity_instance_mixin) -> bool: if not isinstance(self, type(other)): return False else: raise NotImplementedError - + def is_entity(self) -> bool: """Tests whether the instance is an entity type as opposed to a simple data type. diff --git a/src/ifcopenshell-python/ifcopenshell/file.py b/src/ifcopenshell-python/ifcopenshell/file.py index 82e17c217b..35c3697b51 100644 --- a/src/ifcopenshell-python/ifcopenshell/file.py +++ b/src/ifcopenshell-python/ifcopenshell/file.py @@ -232,8 +232,10 @@ class Transaction: else: assert_never(operation["action"]) + import struct + def consume_buffer(val, inner): while val: s = struct.unpack("@q", val[:8])[0] @@ -506,22 +508,22 @@ class file_mixin: registry = {} - def post_init(self, iden = None): + def post_init(self, iden=None): if iden is None: iden = int(self.this) if state := self.registry.get(iden): self.state = state else: - self.state = self.registry[iden] = [[],[],None] + self.state = self.registry[iden] = [[], [], None] @property def history(self): return self.state[0] - + @property def future(self): return self.state[1] - + @property def transaction(self): return self.state[2] @@ -529,7 +531,7 @@ class file_mixin: @transaction.setter def transaction(self, v): self.state[2] = v - + def set_history_size(self, size: int) -> None: self.history_size = size while len(self.history) > self.history_size: @@ -699,7 +701,6 @@ class file_mixin: else: raise TypeError("Indexing into file requires either an integral number or compressed guid string") - def add(self, inst: ifcopenshell.entity_instance, _id: int = None) -> ifcopenshell.entity_instance: """Adds an entity including any dependent entities to an IFC file. If the entity already exists, it is not re-added. Existence of entity is checked by it's `.identity()`. @@ -710,7 +711,7 @@ class file_mixin: if self.transaction: max_id = self.getMaxId() - + result = self._add(inst, -1 if _id is None else _id) if self.transaction: diff --git a/src/ifcopenshell-python/ifcopenshell/geom/main.py b/src/ifcopenshell-python/ifcopenshell/geom/main.py index ba0eba673c..c86175fb07 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/main.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/main.py @@ -507,9 +507,7 @@ def create_shape( """ return wrap_shape_creation( settings, - ifcopenshell_wrapper.create_shape( - settings, inst, repr if repr is not None else None, geometry_library - ), + ifcopenshell_wrapper.create_shape(settings, inst, repr if repr is not None else None, geometry_library), ) diff --git a/src/ifcopenshell-python/ifcopenshell/sql.py b/src/ifcopenshell-python/ifcopenshell/sql.py index 579231240e..4b5bd38078 100644 --- a/src/ifcopenshell-python/ifcopenshell/sql.py +++ b/src/ifcopenshell-python/ifcopenshell/sql.py @@ -430,9 +430,7 @@ class sqlite_entity(entity_instance): self.sqlite_wrapper.inverse_attribute_cache[name] = tuple(results) return self.sqlite_wrapper.inverse_attribute_cache[name] - raise AttributeError( - "entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name) - ) + raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name)) def unserialise_value(self, value): if isinstance(value, (tuple, list)): diff --git a/src/ifcopenshell-python/ifcopenshell/stream.py b/src/ifcopenshell-python/ifcopenshell/stream.py index 6f4309f1b8..6fdae02c4c 100644 --- a/src/ifcopenshell-python/ifcopenshell/stream.py +++ b/src/ifcopenshell-python/ifcopenshell/stream.py @@ -387,9 +387,7 @@ try: self.stream_wrapper.inverse_attribute_cache[name] = tuple(results) return self.stream_wrapper.inverse_attribute_cache[name] - raise AttributeError( - "entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name) - ) + raise AttributeError("entity instance of type '%s' has no attribute '%s'" % (self.is_a(True), name)) def __eq__(self, other: stream_entity) -> bool: if not isinstance(self, type(other)): diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 743d8d15c8..e6b662a9b3 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -639,9 +639,7 @@ def set_element_value( except: # Try to cast data_type = ifcopenshell.util.attribute.get_primitive_type( - element.declaration() - .as_entity() - .attribute_by_index(element.get_argument_index(key)) + element.declaration().as_entity().attribute_by_index(element.get_argument_index(key)) ) if data_type == "string": value = str(value)