From 2bad8611222559b09df2b45b6ca522412aaf9aff Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 20 Mar 2026 12:01:04 +0500 Subject: [PATCH] ifcopenshell_wrapper.pyi - support varargs and kwargs in constructors --- .../ifcopenshell/ifcopenshell_wrapper.pyi | 65 ++++++++++++++++++- .../util/scripts/validate_stub.py | 9 ++- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index 74fd9dd49b..b2f868ec24 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -104,6 +104,7 @@ class IfcSpfHeader: https://standards.buildingsmart.org/documents/Implementation/ImplementationGuide_IFCHeaderData_Version_1.0.2.pdf """ + def __init__(self, *args): ... def file(self, *args): ... def file_description_py(self): ... def file_name_py(self): ... @@ -153,6 +154,7 @@ class ConversionResult: def Shape(self): ... def Style(self): ... def StylePtr(self): ... + def __init__(self, *args): ... def append(self, trsf): ... def apply_transform(self, unit_scale=1.0): ... def hasStyle(self): ... @@ -162,6 +164,7 @@ class ConversionResult: class ConversionResultShape: def Serialize(self, place, arg3): ... def Triangulate(self, *args): ... + def __init__(self, *args, **kwargs): ... def add(self, arg2): ... def area(self): ... def axis(self): ... @@ -196,6 +199,7 @@ class ConversionResultShape: def wrap_in_compound(self): ... class DoubleArray3: + def __init__(self, *args): ... def back(self): ... def begin(self): ... def empty(self): ... @@ -270,6 +274,7 @@ class Element: class GeometrySerializer: READ_BREP: Any READ_TRIANGULATION: Any + def __init__(self, *args, **kwargs): ... def geometry_settings(self, *args): ... def isTesselated(self): ... def object_id(self, o): ... @@ -301,6 +306,7 @@ class HdfSerializer(GeometrySerializer): def writeHeader(self): ... class IfcBaseEntity(entity_instance): + def __init__(self, *args, **kwargs): ... def declaration(self): ... def get(self, name): ... def get_inverse(self, name): ... @@ -308,15 +314,18 @@ class IfcBaseEntity(entity_instance): def set_id(self, i): ... class IfcBaseType(entity_instance): + def __init__(self, *args, **kwargs): ... def declaration(self): ... -class IfcEntityInstanceData: ... +class IfcEntityInstanceData: + def __init__(self, *args, **kwargs): ... class IfcLateBoundEntity(IfcBaseEntity): def __init__(self, decl, data): ... def declaration(self): ... class InstanceStreamer: + def __init__(self, *args): ... def bypassTypes(self, type_names): ... def bypassed_instances(self): ... coerce_attribute_count: bool @@ -329,6 +338,7 @@ class InstanceStreamer: def status(self): ... class Iterator: + def __init__(self, *args): ... initialization_outcome_: Any processed_: Any def bounds_max(self): ... @@ -374,6 +384,7 @@ class Iterator: class JsonSerializer: JSON_DIALECT_CREOOX: Any + def __init__(self, *args): ... def finalize(self): ... def ready(self): ... def setFile(self, arg2): ... @@ -386,14 +397,17 @@ class MakeVolume: name: Any class OpaqueCoordinate_3: + def __init__(self, *args): ... def get(self, i): ... def set(self, i, n): ... class OpaqueCoordinate_4: + def __init__(self, *args): ... def get(self, i): ... def set(self, i, n): ... class OpaqueNumber: + def __init__(self, *args, **kwargs): ... def clone(self): ... def to_double(self): ... def to_string(self): ... @@ -419,6 +433,7 @@ class RocksDBPrefixIterator: def value(self): ... class RocksDbSerializer: + def __init__(self, *args): ... def finalize(self): ... def ready(self): ... def setFile(self, arg2): ... @@ -515,6 +530,7 @@ class SvgSerializer(WriteOnlyGeometrySerializer): def writeHeader(self): ... class SwigPyIterator: + def __init__(self, *args, **kwargs): ... def advance(self, n): ... def copy(self): ... def decr(self, n=1): ... @@ -532,6 +548,7 @@ class Transformation: def matrix(self): ... class Triangulation(Representation): + def __init__(self, *args): ... def addEdge(self, item_id, style, i0, i1): ... def addFace(self, *args): ... def addNormal(self, X, Y, Z): ... @@ -586,6 +603,7 @@ class Triangulation(Representation): def verts_buffer(self) -> bytes: ... class TriangulationElement(Element): + def __init__(self, *args): ... @property def geometry(self) -> Triangulation: ... def geometry_pointer(self): ... @@ -613,6 +631,7 @@ class WaveFrontOBJSerializer(WriteOnlyGeometrySerializer): def writeMaterial(self, style): ... class WriteOnlyGeometrySerializer(GeometrySerializer): + def __init__(self, *args, **kwargs): ... def read(self, *args): ... class XmlSerializer: @@ -625,6 +644,7 @@ class XmlSerializer: class _SwigNonDynamicMeta(type): ... class abstract_arrangement: + def __init__(self, *args, **kwargs): ... def get_face_pairs(self): ... def merge(self, edge_indices): ... def num_edges(self): ... @@ -686,11 +706,13 @@ class bspline_surface(surface): def kind(self): ... class buffer: + def __init__(self, *args): ... def filename(self): ... def get_value(self): ... def is_ready(self): ... class cant_function(function_item): + def __init__(self, *args): ... def calc_hash(self): ... def clone_(self): ... def end(self): ... @@ -718,6 +740,7 @@ class clash: p2: Any class clashes: + def __init__(self, *args): ... def append(self, x): ... def assign(self, n, x): ... def back(self): ... @@ -751,6 +774,7 @@ class collection: def matrix(self): ... class colour(item): + def __init__(self, *args): ... def r(self) -> float: ... def g(self) -> float: ... def b(self) -> float: ... @@ -764,6 +788,7 @@ class colour(item): def kind(self) -> int: ... class context: + def __init__(self, *args): ... def add(self, segments): ... def build(self): ... def get_face_pairs(self): ... @@ -773,6 +798,7 @@ class context: def write(self, arg2): ... class curve(geom_item): + def __init__(self, *args, **kwargs): ... def print_impl(self, o, classname, indent=0): ... class cylinder(surface): @@ -800,6 +826,7 @@ class declaration: def type(self): ... class direction3: + def __init__(self, *args): ... def calc_hash(self): ... def clone_(self): ... @property @@ -811,6 +838,7 @@ class drawing_meta: pln_3d: Any class edge(trimmed_curve): + def __init__(self, *args): ... def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -854,6 +882,7 @@ class entity(declaration): def supertype(self) -> Union[entity, None]: ... class entity_instance: + def __init__(self, *args, **kwargs): ... file: ifcopenshell.file """Reference to IFC file to prevent it's garbage collection, if entity is still used.""" @@ -947,6 +976,7 @@ class face: class file: def FreshId(self): ... + def __init__(self, *args): ... def add(self, entity: entity_instance, id: int = -1) -> entity_instance: ... def addEntities(self, entities): ... def add_type_ref(self, new_entity): ... @@ -1057,9 +1087,11 @@ class file_open_status: UNSUPPORTED_SCHEMA: int INVALID_SYNTAX: int UNKNOWN: int + def __init__(self, *args): ... def value(self): ... class fn_evaluator: + def __init__(self, *args, **kwargs): ... settings_: Any def clone(self): ... def end(self): ... @@ -1068,6 +1100,7 @@ class fn_evaluator: def start(self): ... class function_item(implicit_item): + def __init__(self, *args, **kwargs): ... def calc_hash(self): ... def end(self): ... def kind(self): ... @@ -1075,10 +1108,12 @@ class function_item(implicit_item): def start(self): ... class function_item_evaluator: + def __init__(self, *args): ... def evaluate(self, *args): ... def evaluation_points(self, *args): ... class functor_item(function_item): + def __init__(self, *args): ... def calc_hash(self): ... def clone_(self): ... def end(self): ... @@ -1086,6 +1121,7 @@ class functor_item(function_item): def start(self): ... class geom_item(item): + def __init__(self, *args, **kwargs): ... matrix: Any surface_style: Any @@ -1099,6 +1135,7 @@ class geometry_conversion_result: representation: Any class gradient_function(function_item): + def __init__(self, *args): ... def calc_hash(self): ... def clone_(self): ... def end(self): ... @@ -1110,7 +1147,9 @@ class gradient_function(function_item): class equal_functor: ... class hash_functor: ... class horizontal_plan_at_element: ... -class implicit_item(geom_item): ... + +class implicit_item(geom_item): + def __init__(self, *args, **kwargs): ... class inverse_attribute: def __init__(self, name, type_of_aggregation, bound1, bound2, entity_reference, attribute_reference): ... @@ -1126,6 +1165,7 @@ class inverse_attribute: def type_of_aggregation_string(self): ... class item: + def __init__(self, *args, **kwargs): ... instance: Any orientation: Any def calc_hash(self): ... @@ -1148,6 +1188,7 @@ class line(curve): def matrix(self): ... class line_segment: + def __init__(self, *args): ... def back(self): ... def begin(self): ... def empty(self): ... @@ -1190,6 +1231,7 @@ class matrix4(item): AFFINE_W_UNIFORM_SCALE: Any AFFINE_W_NONUNIFORM_SCALE: Any OTHER: Any + def __init__(self, *args): ... tag: Any def calc_hash(self): ... def clone_(self): ... @@ -1221,6 +1263,7 @@ class offset_curve(curve): def kind(self): ... class offset_function(function_item): + def __init__(self, *args): ... def calc_hash(self): ... def clone_(self): ... def end(self): ... @@ -1242,6 +1285,7 @@ class parameter_type: def as_simple_type(self) -> Union[simple_type, None]: ... class piecewise_function(function_item): + def __init__(self, *args): ... def calc_hash(self): ... def clone_(self): ... def end(self): ... @@ -1261,6 +1305,7 @@ class plane(surface): def matrix(self): ... class point3: + def __init__(self, *args): ... def calc_hash(self): ... def clone_(self): ... @property @@ -1282,6 +1327,7 @@ class ray_intersection_result: style_index: Any class ray_intersection_results: + def __init__(self, *args): ... def append(self, x): ... def assign(self, n, x): ... def back(self): ... @@ -1384,6 +1430,7 @@ class sphere(surface): def matrix(self): ... class style(item): + def __init__(self, *args): ... diffuse: colour name: str """E.g. 'IfcSurfaceStyleShading-218', where 218 is style's STEP id.""" @@ -1418,9 +1465,11 @@ class style(item): def kind(self) -> int: ... -class surface(geom_item): ... +class surface(geom_item): + def __init__(self, *args, **kwargs): ... class svg_groups_of_line_segments: + def __init__(self, *args): ... def append(self, x): ... def assign(self, n, x): ... def back(self): ... @@ -1445,6 +1494,7 @@ class svg_groups_of_line_segments: def swap(self, v): ... class svg_groups_of_polygons: + def __init__(self, *args): ... def append(self, x): ... def assign(self, n, x): ... def back(self): ... @@ -1469,6 +1519,7 @@ class svg_groups_of_polygons: def swap(self, v): ... class svg_line_segments: + def __init__(self, *args): ... def append(self, x): ... def assign(self, n, x): ... def back(self): ... @@ -1493,6 +1544,7 @@ class svg_line_segments: def swap(self, v): ... class svg_loop: + def __init__(self, *args): ... def append(self, x): ... def assign(self, n, x): ... def back(self): ... @@ -1517,6 +1569,7 @@ class svg_loop: def swap(self, v): ... class svg_loops: + def __init__(self, *args): ... def append(self, x): ... def assign(self, n, x): ... def back(self): ... @@ -1541,6 +1594,7 @@ class svg_loops: def swap(self, v): ... class svg_point: + def __init__(self, *args): ... def back(self): ... def begin(self): ... def empty(self): ... @@ -1554,6 +1608,7 @@ class svg_point: def swap(self, v): ... class svg_polygons: + def __init__(self, *args): ... def append(self, x): ... def assign(self, n, x): ... def back(self): ... @@ -1578,9 +1633,11 @@ class svg_polygons: def swap(self, v): ... class sweep(geom_item): + def __init__(self, *args, **kwargs): ... basis: Any class sweep_along_curve(sweep): + def __init__(self, *args): ... curve: Any surface: Any direction: Any @@ -1598,6 +1655,7 @@ class torus(surface): def matrix(self): ... class tree: + def __init__(self, *args): ... def add_element(self, *args): ... def add_file(self, *args): ... def clash_clearance_many(self, set_a, set_b, clearance, check_all): ... @@ -1618,6 +1676,7 @@ class tree: def write_h5(self): ... class trimmed_curve(geom_item): + def __init__(self, *args, **kwargs): ... basis: Any curve_sense: Any start: Any diff --git a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py index 168323ec0e..1c3b6cb001 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py +++ b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py @@ -70,13 +70,16 @@ def get_function_node_name(node: ast.FunctionDef) -> Union[SubnameType, None]: else: args.append(f"{arg.arg}={ast.unparse(default)}") + if arg := node.args.vararg: + args.append(f"*{arg.arg}") + + if arg := node.args.kwarg: + args.append(f"**{arg.arg}") + # Skip non-informative constructors. if is_init and args == ["self"]: return None - if node.args.vararg: - args.append("*args") - node_name = f"def {node.name}" node_name = f"{node_name}({', '.join(args)}): ..."