From 15b69bfa98f87b60ce3e5b15771c600f39556b66 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 4 Sep 2025 18:56:51 +0500 Subject: [PATCH] sql, stream - define `wrapped_data` to provide more clear errors --- src/ifcopenshell-python/ifcopenshell/sql.py | 7 ++++++- src/ifcopenshell-python/ifcopenshell/stream.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/sql.py b/src/ifcopenshell-python/ifcopenshell/sql.py index 6b757f4f5b..44044fe687 100644 --- a/src/ifcopenshell-python/ifcopenshell/sql.py +++ b/src/ifcopenshell-python/ifcopenshell/sql.py @@ -51,7 +51,6 @@ class sqlite(file): if not Path(filepath).exists(): raise FileNotFoundError(f"File doesn't exist: {filepath}") - self.wrapped_data = None self.history_size = 64 self.history = [] self.future = [] @@ -270,6 +269,12 @@ class sqlite(file): # Override to avoid clean up data unrelated to sqlite file. pass + def wrapped_data(self) -> NoReturn: + class_name = str(type(self)) + raise Exception( + f"No `wrapped_data` for {class_name}. `ifcopenshell.{class_name}` is probably confused with `ifcopenshell.file`." + ) + @property def schema(self) -> ifcopenshell.util.schema.IFC_SCHEMA: return self._schema diff --git a/src/ifcopenshell-python/ifcopenshell/stream.py b/src/ifcopenshell-python/ifcopenshell/stream.py index 83de74771a..47e814e0fe 100644 --- a/src/ifcopenshell-python/ifcopenshell/stream.py +++ b/src/ifcopenshell-python/ifcopenshell/stream.py @@ -88,7 +88,6 @@ try: class stream(file): def __init__(self, filepath: str): - self.wrapped_data = None self.history_size = 64 self.history = [] self.future = [] @@ -288,6 +287,12 @@ try: # Override to avoid clean up unrelated to stream file. pass + def wrapped_data(self) -> NoReturn: + class_name = str(type(self)) + raise Exception( + f"No `wrapped_data` for {class_name}. `ifcopenshell.{class_name}` is probably confused with `ifcopenshell.file`." + ) + @property def schema(self) -> ifcopenshell.util.schema.IFC_SCHEMA: return self._schema