From 6038373ee5e31796c5823becaf8e5398600f2434 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 19 Mar 2026 18:56:51 +0500 Subject: [PATCH] ifcopenshell_wrapper.pyi - sync default values, validate_stub - suggest default values --- .../ifcopenshell/ifcopenshell_wrapper.pyi | 36 +++++++++---------- .../util/scripts/validate_stub.py | 9 ++++- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi index 6d041c699f..74fd9dd49b 100644 --- a/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi +++ b/src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi @@ -114,7 +114,7 @@ class IfcSpfHeader: class BRep(Representation): def __init__(self, settings, entity, id, shapes): ... - def as_compound(self, force_meters): ... + def as_compound(self, force_meters=False): ... def begin(self): ... def calculate_projected_surface_area(self, ax, along_x, along_y, along_z): ... def calculate_surface_area(self, arg2): ... @@ -154,7 +154,7 @@ class ConversionResult: def Style(self): ... def StylePtr(self): ... def append(self, trsf): ... - def apply_transform(self, unit_scale): ... + def apply_transform(self, unit_scale=1.0): ... def hasStyle(self): ... def prepend(self, trsf): ... def setStyle(self, newStyle): ... @@ -323,7 +323,7 @@ class InstanceStreamer: def hasSemicolon(self): ... def inverses(self, *args): ... def pushPage(self, page): ... - def readInstancePy(self, type_as_declaration_instance): ... + def readInstancePy(self, type_as_declaration_instance=False): ... def references(self, *args): ... def semicolonCount(self): ... def status(self): ... @@ -497,8 +497,8 @@ class SvgSerializer(WriteOnlyGeometrySerializer): def setPrintSpaceNames(self, b): ... def setProfileThreshold(self, i): ... def setScale(self, s): ... - def setSectionHeight(self, h, storey): ... - def setSectionHeightsFromStoreys(self, offset): ... + def setSectionHeight(self, h, storey=None): ... + def setSectionHeightsFromStoreys(self, offset=1.2): ... def setSectionRef(self, s): ... def setSegmentProjection(self, b): ... def setSpaceNameTransform(self, v): ... @@ -517,10 +517,10 @@ class SvgSerializer(WriteOnlyGeometrySerializer): class SwigPyIterator: def advance(self, n): ... def copy(self): ... - def decr(self, n): ... + def decr(self, n=1): ... def distance(self, x): ... def equal(self, x): ... - def incr(self, n): ... + def incr(self, n=1): ... def next(self): ... def previous(self): ... def value(self): ... @@ -597,7 +597,7 @@ class TtlWktSerializer(WriteOnlyGeometrySerializer): def ready(self): ... def setFile(self, arg2): ... def setUnitNameAndMagnitude(self, arg2, arg3): ... - def ttl_object_id(self, o, postfix): ... + def ttl_object_id(self, o, postfix=None): ... def write(self, *args): ... def writeHeader(self): ... @@ -773,7 +773,7 @@ class context: def write(self, arg2): ... class curve(geom_item): - def print_impl(self, o, classname, indent): ... + def print_impl(self, o, classname, indent=0): ... class cylinder(surface): radius: Any @@ -907,8 +907,8 @@ class entity_instance: def setArgumentAsNull(self, i): ... def setArgumentAsString(self, i, a): ... def set_attribute_value(self, *args): ... - def toString(self, arg2, upper): ... - def to_string(self, valid_spf): ... + def toString(self, arg2, upper=False): ... + def to_string(self, valid_spf=True): ... def unset_attribute_value(self, i): ... class enumeration_type(declaration): @@ -947,7 +947,7 @@ class face: class file: def FreshId(self): ... - def add(self, entity: entity_instance, id: int) -> entity_instance: ... + def add(self, entity: entity_instance, id: int = -1) -> entity_instance: ... def addEntities(self, entities): ... def add_type_ref(self, new_entity): ... def batch(self) -> None: @@ -1038,9 +1038,9 @@ class file: def storage_mode(self): ... def to_string(self): ... @staticmethod - def traverse(instance: entity_instance, max_level: int) -> tuple[entity_instance, ...]: ... + def traverse(instance: entity_instance, max_level: int = -1) -> tuple[entity_instance, ...]: ... @staticmethod - def traverse_breadth_first(instance: entity_instance, max_level: int) -> tuple[entity_instance, ...]: ... + def traverse_breadth_first(instance: entity_instance, max_level: int = -1) -> tuple[entity_instance, ...]: ... def types(self) -> tuple[str, ...]: """Return a tuple of classes present in the file. @@ -1610,7 +1610,7 @@ class tree: def protrusion_distances(self): ... def select(self, *args): ... def select_box(self, *args): ... - def select_ray(self, p0, d, length): ... + def select_ray(self, p0, d, length=1000.0): ... def styles(self): ... def uint8_to_b64(self, uuids_array): ... @staticmethod @@ -1648,7 +1648,7 @@ def create_epeck(*args): ... def create_shape(*args): ... def flatten(deep): ... def get_feature(x): ... -def get_info_cpp(v, include_identifier): ... +def get_info_cpp(v, include_identifier=True): ... def get_log(): ... def guess_file_type(fn): ... def helmert_curve_point(A0, A1, A2, s): ... @@ -1658,14 +1658,14 @@ def line_segments_to_polygons(s, eps, segments): ... def map_shape(settings, instance): ... def nary_union(sequence): ... def new_IfcBaseClass(schema_identifier: str, name: str) -> entity_instance: ... -def open(fn, readonly): ... +def open(fn, readonly=False): ... def parse_ifcxml(filename): ... def polygons_to_svg(*args): ... def read(data): ... def register_schema(arg1): ... def schema_by_name(arg1: str) -> schema_definition: ... def schema_names() -> tuple[str, ...]: ... -def serialise(schema_name, shape_str, advanced): ... +def serialise(schema_name, shape_str, advanced=True): ... def set_feature(x, v): ... def set_log_format_json(): ... def set_log_format_text(): ... diff --git a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py index 8eb603810c..168323ec0e 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py +++ b/src/ifcopenshell-python/ifcopenshell/util/scripts/validate_stub.py @@ -61,7 +61,14 @@ def get_function_node_name(node: ast.FunctionDef) -> Union[SubnameType, None]: 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] + arg_nodes = node.args.args + defaults = [None] * (len(arg_nodes) - len(node.args.defaults)) + node.args.defaults + args: list[str] = [] + for arg, default in zip(arg_nodes, defaults): + if default is None: + args.append(arg.arg) + else: + args.append(f"{arg.arg}={ast.unparse(default)}") # Skip non-informative constructors. if is_init and args == ["self"]: