From cb113ae8da95bb945004f61fd79669737946038b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 19 Mar 2026 18:16:24 +0500 Subject: [PATCH] ifcopenshell_wrapper.pyi - support stubs for constructors --- .../ifcopenshell/ifcopenshell_wrapper.pyi | 29 +++++++++++++++++++ .../util/scripts/validate_stub.py | 9 +++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index f2ae415ead..4933c0b6b0 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -113,6 +113,7 @@ class IfcSpfHeader: def write(self, out): ... class BRep(Representation): + def __init__(self, settings, entity, id, shapes): ... def as_compound(self, force_meters): ... def begin(self): ... def calculate_projected_surface_area(self, ax, along_x, along_y, along_z): ... @@ -125,6 +126,7 @@ class BRep(Representation): def size(self): ... class BRepElement(Element): + def __init__(self, id, parent_id, name, type, guid, context, trsf, geometry, product): ... def calculate_projected_surface_area(self, along_x, along_y, along_z): ... @property def geometry(self) -> BRep: ... @@ -135,6 +137,7 @@ class BRepElement(Element): def volume(self): ... class ColladaSerializer(WriteOnlyGeometrySerializer): + def __init__(self, dae_filename, geometry_settings, settings): ... def finalize(self): ... def isTesselated(self): ... def object_id(self, o): ... @@ -206,6 +209,7 @@ class DoubleArray3: def swap(self, v): ... class Element: + def __init__(self, settings, id, parent_id, name, type, guid, context, trsf, product): ... # TODO: Remove from the wrapper? def SetParents(self, newparents): ... # TODO: could it be None? @@ -275,6 +279,7 @@ class GeometrySerializer: def write(self, *args): ... class GltfSerializer(WriteOnlyGeometrySerializer): + def __init__(self, filename, geometry_settings, settings): ... def finalize(self): ... def isTesselated(self): ... def ready(self): ... @@ -284,6 +289,7 @@ class GltfSerializer(WriteOnlyGeometrySerializer): def writeHeader(self): ... class HdfSerializer(GeometrySerializer): + def __init__(self, hdf_filename, geometry_settings, settings, read_only=False): ... def finalize(self): ... def isTesselated(self): ... def read(self, *args): ... @@ -307,6 +313,7 @@ class IfcBaseType(entity_instance): class IfcEntityInstanceData: ... class IfcLateBoundEntity(IfcBaseEntity): + def __init__(self, decl, data): ... def declaration(self): ... class InstanceStreamer: @@ -386,6 +393,7 @@ class OpaqueNumber: def to_string(self): ... class Representation: + def __init__(self, settings, entity, id): ... def entity(self): ... @property def id(self) -> str: @@ -398,6 +406,7 @@ class Representation: def settings(self): ... class RocksDBPrefixIterator: + def __init__(self, storage, prefix): ... def key(self): ... def next(self): ... def valid(self): ... @@ -410,6 +419,7 @@ class RocksDbSerializer: def writeHeader(self): ... class Serialization(Representation): + def __init__(self, brep): ... @property def brep_data(self): ... @property @@ -418,6 +428,7 @@ class Serialization(Representation): def surface_styles(self): ... class SerializedElement(Element): + def __init__(self, shape_model): ... @property def geometry(self) -> Serialization: ... @@ -434,6 +445,7 @@ class Settings: def setting_names(self): ... class SvgSerializer(WriteOnlyGeometrySerializer): + def __init__(self, out_filename, geometry_settings, settings): ... SH_NONE: Any SH_FULL: Any SH_LEFT: Any @@ -508,6 +520,7 @@ class SwigPyIterator: def value(self): ... class Transformation: + def __init__(self, settings, matrix): ... def data(self): ... @property def matrix(self): ... @@ -572,6 +585,7 @@ class TriangulationElement(Element): def geometry_pointer(self): ... class TtlWktSerializer(WriteOnlyGeometrySerializer): + def __init__(self, filename, geometry_settings, settings): ... def finalize(self): ... def isTesselated(self): ... def ready(self): ... @@ -582,6 +596,7 @@ class TtlWktSerializer(WriteOnlyGeometrySerializer): def writeHeader(self): ... class WaveFrontOBJSerializer(WriteOnlyGeometrySerializer): + def __init__(self, obj_filename, mtl_filename, geometry_settings, settings): ... def finalize(self): ... def isTesselated(self): ... def ready(self): ... @@ -595,6 +610,7 @@ class WriteOnlyGeometrySerializer(GeometrySerializer): def read(self, *args): ... class XmlSerializer: + def __init__(self, file, xml_filename): ... def finalize(self): ... def ready(self): ... def setFile(self, arg2): ... @@ -610,6 +626,7 @@ class abstract_arrangement: def write(self, polygons, progress): ... class aggregation_type(parameter_type): + def __init__(self, type_of_aggregation, bound1, bound2, type_of_element): ... array_type: Any bag_type: Any list_type: Any @@ -622,6 +639,7 @@ class aggregation_type(parameter_type): def type_of_element(self) -> parameter_type: ... class attribute: + def __init__(self, name, type_of_attribute, optional): ... def name(self) -> str: ... def optional(self) -> bool: ... def type_of_attribute(self) -> parameter_type: ... @@ -760,6 +778,7 @@ class cylinder(surface): def matrix(self): ... class declaration: + def __init__(self, name, index_in_schema): ... def _is(self, *args: Union[str, declaration]) -> bool: ... def as_entity(self) -> Union[entity, None]: ... def as_enumeration_type(self) -> Union[enumeration_type, None]: ... @@ -800,6 +819,7 @@ class ellipse(curve): def matrix(self): ... class entity(declaration): + def __init__(self, name, is_abstract, index_in_schema, supertype): ... def all_attributes(self) -> tuple[attribute, ...]: ... def all_inverse_attributes(self) -> tuple[inverse_attribute, ...]: ... def argument_types(self) -> tuple[str, ...]: @@ -886,6 +906,7 @@ class entity_instance: def unset_attribute_value(self, i): ... class enumeration_type(declaration): + def __init__(self, name, index_in_schema, enumeration_items): ... def argument_types(self) -> tuple[str, ...]: ... def as_enumeration_type(self) -> enumeration_type: ... def enumeration_items(self) -> tuple[str, ...]: ... @@ -898,6 +919,7 @@ class enumeration_type(declaration): ... class extrusion(sweep): + def __init__(self, m, basis, dir, d): ... depth: Any direction: Any def calc_hash(self): ... @@ -1085,6 +1107,7 @@ class horizontal_plan_at_element: ... class implicit_item(geom_item): ... class inverse_attribute: + def __init__(self, name, type_of_aggregation, bound1, bound2, entity_reference, attribute_reference): ... bag_type: Any set_type: Any unspecified_type: Any @@ -1173,6 +1196,7 @@ class matrix4(item): def pre_multiply_scale(self, s): ... class named_type(parameter_type): + def __init__(self, declared_type): ... def _is(self, *args): ... def as_named_type(self) -> named_type: ... def declared_type(self) -> declaration: ... @@ -1276,6 +1300,7 @@ class ray_intersection_results: def swap(self, v): ... class revolve(sweep): + def __init__(self, m, basis, pnt, dir, a): ... angle: Any axis_origin: Any direction: Any @@ -1286,6 +1311,7 @@ class revolve(sweep): def matrix(self): ... class schema_definition: + def __init__(self, name, declarations, factory): ... def declaration_by_name(self, *args: str) -> declaration: """ :return: ``declaration`` but upcasted to the most advanced available type @@ -1307,6 +1333,7 @@ class schema_definition: def name(self) -> str: ... class select_type(declaration): + def __init__(self, name, index_in_schema, select_list): ... def as_select_type(self) -> select_type: ... def select_list(self) -> tuple[declaration, ...]: ... @@ -1321,6 +1348,7 @@ class shell: def print_impl(self, o, indent): ... class simple_type(parameter_type): + def __init__(self, declared_type): ... binary_type: Any boolean_type: Any integer_type: Any @@ -1595,6 +1623,7 @@ class type_by_kind: max: Any class type_declaration(declaration): + def __init__(self, name, index_in_schema, declared_type): ... def argument_types(self): ... def as_type_declaration(self) -> type_declaration: ... def declared_type(self): ... diff --git a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py index 5ba2466f29..8eb603810c 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py +++ b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py @@ -57,9 +57,16 @@ def get_function_node_name(node: ast.FunctionDef) -> Union[SubnameType, None]: :return: Function node name as ``SubnameType`` or ``None``, if function wasn't processed and can be skipped. """ node_name = node.name - if node_name.startswith("_") and node_name not in ("_is",): + is_init = node_name == "__init__" + + if node_name.startswith("_") and node_name not in ("_is",) and not is_init: return None args = [a.arg for a in node.args.args] + + # Skip non-informative constructors. + if is_init and args == ["self"]: + return None + if node.args.vararg: args.append("*args")