From 48f62c0b5b07bf9669e22ed25dc0814cbd44d6a5 Mon Sep 17 00:00:00 2001 From: Andrej Date: Thu, 29 May 2025 18:29:51 +0500 Subject: [PATCH] ifcopenshell_wrapper.pyi - update from the latest build I guess previously I used some of my local builds, so some symbols were missing. --- .../ifcopenshell/ifcopenshell_wrapper.pyi | 134 +++++++++++++----- .../util/scripts/validate_stub.py | 97 +++++++------ 2 files changed, 152 insertions(+), 79 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index 070a607104..1f03e93043 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -132,11 +132,6 @@ class BRepElement(Element): @property def volume(self): ... -class CacheShapes: - name: Any - description: Any - defaultvalue: Any - class CgalEmitOriginalEdges: name: Any description: Any @@ -262,6 +257,15 @@ class GeometrySerializer: def settings(self, *args): ... def write(self, *args): ... +class GltfSerializer(WriteOnlyGeometrySerializer): + def finalize(self): ... + def isTesselated(self): ... + def ready(self): ... + def setFile(self, arg2): ... + def setUnitNameAndMagnitude(self, arg2, arg3): ... + def write(self, *args): ... + def writeHeader(self): ... + class HdfSerializer(GeometrySerializer): def finalize(self): ... def isTesselated(self): ... @@ -293,9 +297,13 @@ class IfcEntityInstanceData: ... class IfcLateBoundEntity(IfcBaseEntity): def declaration(self): ... -class InstanceReference: ... +class InstanceReference: + file_offset: Any + v: Any class Iterator: + initialization_outcome_: Any + processed_: Any def bounds_max(self): ... def bounds_min(self): ... def compute_bounds(self, with_geometry): ... @@ -316,11 +324,6 @@ class Iterator: def unit_magnitude(self): ... def unit_name(self): ... -class OcctNoCleanTriangulation: - name: Any - description: Any - defaultvalue: Any - class OpaqueCoordinate_3: def get(self, i): ... def set(self, i, n): ... @@ -334,11 +337,6 @@ class OpaqueNumber: def to_double(self): ... def to_string(self): ... -class PermissiveShapeReuse: - name: Any - description: Any - defaultvalue: Any - class Representation: def entity(self): ... @property @@ -544,6 +542,8 @@ class XmlSerializerFactory: @staticmethod def implementations(): ... +class _SwigNonDynamicMeta(type): ... + class abstract_arrangement: def get_face_pairs(self): ... def merge(self, edge_indices): ... @@ -574,6 +574,7 @@ class boolean_result: INTERSECTION: Any SUBTRACTION: Any UNION: Any + operation: Any def calc_hash(self): ... @property def children(self): ... @@ -583,11 +584,21 @@ class boolean_result: def operation_str(op): ... class bspline_curve(curve): + control_points: Any + degree: Any + knots: Any + multiplicities: Any + weights: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... class bspline_surface(surface): + control_points: Any + degree: Any + knots: Any + multiplicities: Any + weights: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -607,6 +618,7 @@ class cant_function(function_item): def start(self): ... class circle(curve): + radius: Any def calc_hash(self): ... def clone_(self): ... @staticmethod @@ -615,7 +627,13 @@ class circle(curve): @property def matrix(self): ... -class clash: ... +class clash: + a: Any + b: Any + clash_type: Any + distance: Any + p1: Any + p2: Any class clashes: def append(self, x): ... @@ -673,6 +691,7 @@ class curve(geom_item): def print_impl(self, o, classname, indent): ... class cylinder(surface): + radius: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -697,7 +716,9 @@ class direction3: def components(self): ... def kind(self): ... -class drawing_meta: ... +class drawing_meta: + matrix_3: Any + pln_3d: Any class edge(trimmed_curve): def calc_hash(self): ... @@ -705,6 +726,8 @@ class edge(trimmed_curve): def kind(self): ... class ellipse(curve): + radius: Any + radius2: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -729,6 +752,8 @@ class entity(declaration): def supertype(self): ... class entity_instance: + file_: Any + id_: Any def data(self, *args): ... def declaration(self): ... def file_pointer(self): ... @@ -768,9 +793,9 @@ class enumeration_type(declaration): def lookup_enum_offset(self, string): ... def lookup_enum_value(self, i): ... -class equal_functor: ... - class extrusion(sweep): + depth: Any + direction: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -778,6 +803,7 @@ class extrusion(sweep): def matrix(self): ... class face: + basis: Any def calc_hash(self): ... @property def children(self): ... @@ -791,6 +817,8 @@ class file: INSTANCE_ID: Any INSTANCE_TYPE: Any ATTRIBUTE_INDEX: Any + guid_map_: Any + stream: Any def FreshId(self): ... def add(self, entity, id): ... def addEntities(self, entities): ... @@ -846,6 +874,7 @@ class file_open_status: def value(self): ... class fn_evaluator: + settings_: Any def clone(self): ... def end(self): ... def evaluate(self, u): ... @@ -870,7 +899,9 @@ class functor_item(function_item): def kind(self): ... def start(self): ... -class geom_item(item): ... +class geom_item(item): + matrix: Any + surface_style: Any class geometry_exception: def what(self): ... @@ -884,7 +915,6 @@ class gradient_function(function_item): def kind(self): ... def start(self): ... -class hash_functor: ... class horizontal_plan_at_element: ... class implicit_item(geom_item): ... @@ -901,6 +931,8 @@ class inverse_attribute: def type_of_aggregation_string(self): ... class item: + instance: Any + orientation: Any def calc_hash(self): ... def clone_(self): ... def hash(self): ... @@ -931,6 +963,7 @@ class line_segment: def swap(self, v): ... class loft: + axis: Any def calc_hash(self): ... @property def children(self): ... @@ -939,6 +972,9 @@ class loft: def print_impl(self, o, indent): ... class loop: + closed: Any + external: Any + fi: Any def calc_hash(self): ... def calculate_linear_edge_curves(self): ... @property @@ -954,6 +990,7 @@ class matrix4(item): AFFINE_W_UNIFORM_SCALE: Any AFFINE_W_NONUNIFORM_SCALE: Any OTHER: Any + tag: Any def calc_hash(self): ... def clone_(self): ... @property @@ -972,6 +1009,9 @@ class node(item): def kind(self): ... class offset_curve(curve): + basis: Any + offset: Any + reference: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -1016,8 +1056,19 @@ class point3: def components(self): ... def kind(self): ... -class polygon_2: ... -class ray_intersection_result: ... +class polygon_2: + boundary: Any + inner_boundaries: Any + point_inside: Any + +class ray_intersection_result: + distance: Any + dot_product: Any + instance: Any + normal: Any + position: Any + ray_distance: Any + style_index: Any class ray_intersection_results: def append(self, x): ... @@ -1044,6 +1095,9 @@ class ray_intersection_results: def swap(self, v): ... class revolve(sweep): + angle: Any + axis_origin: Any + direction: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -1065,6 +1119,7 @@ class select_type(declaration): def select_list(self): ... class shell: + closed: Any def calc_hash(self): ... @property def children(self): ... @@ -1094,6 +1149,7 @@ class solid: def matrix(self): ... class sphere(surface): + radius: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -1101,6 +1157,13 @@ class sphere(surface): def matrix(self): ... class style(item): + diffuse: Any + name: Any + specular: Any + specularity: Any + surface: Any + transparency: Any + use_surface_color: Any def calc_hash(self): ... def clone_(self): ... def get_color(self): ... @@ -1268,9 +1331,12 @@ class svg_polygons: def size(self): ... def swap(self, v): ... -class sweep(geom_item): ... +class sweep(geom_item): + basis: Any class sweep_along_curve(sweep): + curve: Any + surface: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -1279,6 +1345,8 @@ class too_many_faces_exception(geometry_exception): ... class topology_error: ... class torus(surface): + radius1: Any + radius2: Any def calc_hash(self): ... def clone_(self): ... def kind(self): ... @@ -1306,6 +1374,11 @@ class tree: def write_h5(self): ... class trimmed_curve(geom_item): + basis: Any + curve_sense: Any + start: Any + end: Any + def reverse(self): ... class type_by_kind: @@ -1316,12 +1389,7 @@ class type_declaration(declaration): def as_type_declaration(self): ... def declared_type(self): ... -def Triangulation_box_project_uvs(vertices, normals): ... -def Triangulation_empty(settings): ... -def XmlSerializerFactory_implementations(): ... def arrange_polygons(polygons): ... -def boolean_result_operation_str(op): ... -def circle_from_3_points(p1, p2, p3): ... def clear_schemas(): ... def construct_iterator_with_include_exclude(geometry_library, settings, file, elems, include, num_threads): ... def construct_iterator_with_include_exclude_globalid(geometry_library, settings, file, elems, include, num_threads): ... @@ -1329,10 +1397,6 @@ def construct_iterator_with_include_exclude_id(geometry_library, settings, file, def create_box(*args): ... def create_epeck(*args): ... def create_shape(*args): ... -def file_createTimestamp(): ... -def file_guid_map(*args): ... -def file_traverse(instance, max_level): ... -def file_traverse_breadth_first(instance, max_level): ... def flatten(deep): ... def get_feature(x): ... def get_info_cpp(v, include_identifier): ... @@ -1359,8 +1423,6 @@ def svg_to_line_segments(data, class_name): ... def svg_to_polygons(data, class_name): ... def taxonomy_item_repr(i): ... def tesselate(schema_name, shape_str, d): ... -def tree_is_manifold(fs): ... -def tree_vector_to_list(ps): ... def turn_off_detailed_logging(): ... def turn_on_detailed_logging(): ... def version(): ... diff --git a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py index 4e98f1d4ca..495eab0341 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py +++ b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py @@ -102,63 +102,73 @@ def get_names_tree_lines(tree: ast.Module) -> list[str]: continue subname_ = target.id - if subname_.startswith("_"): + if subname_.startswith(("_", "thisown")): continue value = subnode.value - # Catching wrappers like: - # - `matrix = property(matrix_getter)` - # - `matrix = property(matrix_getter, matrix_setter)` - # - `operation_str = staticmethod(operation_str)` - if isinstance(value, ast.Call): + if not isinstance(value, ast.Call): + subname = subname_ + else: + # Catching wrappers like: + # - `matrix = property(matrix_getter)` + # - `matrix = property(matrix_getter, matrix_setter)` + # - `operation_str = staticmethod(operation_str)` func = value.func if not isinstance(func, ast.Name) or ((func_id := func.id) not in ("property", "staticmethod")): continue args = [arg.id for arg in value.args if isinstance(arg, ast.Name)] len_args = len(args) - assert len_args in (1, 2) + if len_args in (1, 2): - def find_method_by_name(name: str) -> Union[str, None]: - function_def = f"def {name}(" - return next( - ( - func_ - for func_ in subnames - if isinstance(func_, str) and func_.startswith(function_def) - ), - None, - ) + def find_method_by_name(name: str) -> Union[str, None]: + function_def = f"def {name}(" + return next( + ( + func_ + for func_ in subnames + if isinstance(func_, str) and func_.startswith(function_def) + ), + None, + ) - # Use `set` for cases like `description = property(description, description)`. - wrapped_function = None - for arg in set(args): - assert (wrapped_function := find_method_by_name(arg)) - subnames.remove(wrapped_function) + # Use `set` for cases like `description = property(description, description)`. + wrapped_function = None + for arg in set(args): + assert (wrapped_function := find_method_by_name(arg)) + subnames.remove(wrapped_function) - # TODO: sort it out in wrapper.py - # There's one annoying case in Element.product - # when property is overriding existing function, without using it. - # We should probably just exclude that function from the wrapper. - overridden_name = find_method_by_name(subname_) - if overridden_name: - subnames.remove(overridden_name) + # TODO: sort it out in wrapper.py + # There's one annoying case in Element.product + # when property is overriding existing function, without using it. + # We should probably just exclude that function from the wrapper. + overridden_name = find_method_by_name(subname_) + if overridden_name: + subnames.remove(overridden_name) - if len_args == 2: - # Has both getter and setter, can be defined as a simple attribute. - subname = subname_ - elif len_args == 1: - if func_id == "property": - # Has just getter, read-only, need to define it using a wrapper. - subname = (f"@{func_id}", f"def {subname_}(self): ...") - elif func_id == "staticmethod": - assert wrapped_function is not None - subname = (f"@{func_id}", f"def {subname_}({wrapped_function.split('(')[1]}") + if len_args == 2: + # Has both getter and setter, can be defined as a simple attribute. + subname = subname_ + elif len_args == 1: + if func_id == "property": + # Has just getter, read-only, need to define it using a wrapper. + subname = (f"@{func_id}", f"def {subname_}(self): ...") + elif func_id == "staticmethod": + assert wrapped_function is not None + subname = (f"@{func_id}", f"def {subname_}({wrapped_function.split('(')[1]}") + else: + assert_never(func_id) else: - assert_never(func_id) + assert_never(len_args) else: - assert_never(len_args) - else: - subname = subname_ + attr_args = [ + arg + for arg in value.args + if isinstance(arg, ast.Attribute) + and isinstance(arg.value, ast.Name) + and arg.value.id == "_ifcopenshell_wrapper" + ] + assert len(attr_args) == 2 + subname = subname_ if subname is not None: subnames.add(subname) @@ -226,6 +236,7 @@ def main() -> None: fromfile="stub.pyi classes", tofile="wrapper.py classes", lineterm="", + n=10, ) diff = list(diff)