From d4d7cabdc5ea918288464a3306aba773a87195dc Mon Sep 17 00:00:00 2001 From: Frank Martinez Date: Tue, 7 Oct 2025 12:04:08 -0500 Subject: [PATCH] [bindings] Fix overload order --- src/App/GeoFeature.pyi | 2 +- src/App/Material.pyi | 3 +-- src/App/StringHasher.pyi | 9 ++++---- src/Base/Metadata.pyi | 4 ++-- src/Base/Placement.pyi | 4 ++++ src/Base/Quantity.pyi | 16 ++++++------- src/Base/Unit.pyi | 1 - src/Gui/LinkView.pyi | 41 +++++++++++++++++----------------- src/Mod/Part/App/TopoShape.pyi | 17 +++++++------- 9 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/App/GeoFeature.pyi b/src/App/GeoFeature.pyi index e42bc5be0e..1fec4bed82 100644 --- a/src/App/GeoFeature.pyi +++ b/src/App/GeoFeature.pyi @@ -3,7 +3,7 @@ from __future__ import annotations from DocumentObject import DocumentObject -from Base import Placement +from Base.Placement import Placement from typing import Any, Final, Optional class GeoFeature(DocumentObject): diff --git a/src/App/Material.pyi b/src/App/Material.pyi index d27a9df51e..aa54204aa6 100644 --- a/src/App/Material.pyi +++ b/src/App/Material.pyi @@ -24,8 +24,6 @@ class Material(PyObjectBase): UserDocu: This is the Material class """ - @overload - def __init__(self, *args: Any, **kwargs: Any) -> None: ... def set(self, string: str, /) -> None: """ Set(string) -- Set the material. @@ -35,6 +33,7 @@ class Material(PyObjectBase): Satin, Metalized, Neon GNC, Chrome, Aluminium, Obsidian, Neon PHC, Jade, Ruby or Emerald. """ ... + AmbientColor: Any = ... """Ambient color""" diff --git a/src/App/StringHasher.pyi b/src/App/StringHasher.pyi index 7a881f4edd..b0b4d97840 100644 --- a/src/App/StringHasher.pyi +++ b/src/App/StringHasher.pyi @@ -19,7 +19,9 @@ class StringHasher(BaseClass): """ @overload - def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def getID(self, txt: str, base64: bool = False, /) -> Any: ... + @overload + def getID(self, id: int, base64: bool = False, /) -> Any: ... def getID(self, arg: Any, base64: bool = False, /) -> Any: """ getID(txt|id, base64=False) -> StringID @@ -34,16 +36,13 @@ class StringHasher(BaseClass): """ ... - @overload - def getID(self, txt: str, base64: bool = False, /) -> Any: ... - @overload - def getID(self, id: int, base64: bool = False, /) -> Any: ... @constmethod def isSame(self, other: "StringHasher", /) -> bool: """ Check if two hasher are the same """ ... + Count: Final[int] = 0 """Return count of used hashes""" diff --git a/src/Base/Metadata.pyi b/src/Base/Metadata.pyi index 627775c30a..ae989b1cc1 100644 --- a/src/Base/Metadata.pyi +++ b/src/Base/Metadata.pyi @@ -12,8 +12,8 @@ def export(**kwargs): """ ... -def constmethod(): ... -def no_args(): ... +def constmethod(method): ... +def no_args(method): ... def forward_declarations(source_code): """ A decorator to attach forward declarations to a class. diff --git a/src/Base/Placement.pyi b/src/Base/Placement.pyi index d45cd4873f..616a15cdf8 100644 --- a/src/Base/Placement.pyi +++ b/src/Base/Placement.pyi @@ -120,6 +120,8 @@ class Placement(PyObjectBase): def rotate( self, center: Sequence[float], axis: Sequence[float], angle: float, *, comp: bool = False ) -> None: ... + + @overload def rotate(self, center: Vector, axis: Vector, angle: float, *, comp: bool = False) -> None: """ rotate(center, axis, angle, comp) -> None @@ -138,6 +140,8 @@ class Placement(PyObjectBase): optional keyword only argument, if True (default=False), behave like TopoShape.rotate() (i.e. the resulting placements are interchangeable). """ + + def rotate(self, *args, **kwargs) -> None: ... @constmethod diff --git a/src/Base/Quantity.pyi b/src/Base/Quantity.pyi index 8845cfad4b..7afbef1d47 100644 --- a/src/Base/Quantity.pyi +++ b/src/Base/Quantity.pyi @@ -54,6 +54,10 @@ class Quantity(PyObjectBase): def __init__(self, string: str) -> None: ... # fmt: on + @overload + def toStr(self, /) -> str: ... + @overload + def toStr(self, decimals: int, /) -> str: ... @constmethod def toStr(self, decimals: int = ..., /) -> str: """ @@ -64,10 +68,6 @@ class Quantity(PyObjectBase): """ ... - @overload - def toStr(self, /) -> str: ... - @overload - def toStr(self, decimals: int, /) -> str: ... @constmethod def getUserPreferred(self) -> Tuple["Quantity", str]: """ @@ -97,6 +97,10 @@ class Quantity(PyObjectBase): """ ... + @overload + def __round__(self, /) -> int: ... + @overload + def __round__(self, ndigits: int, /) -> float: ... @constmethod def __round__(self, ndigits: int = ..., /) -> Union[int, float]: """ @@ -105,7 +109,3 @@ class Quantity(PyObjectBase): """ ... - @overload - def __round__(self, /) -> int: ... - @overload - def __round__(self, ndigits: int, /) -> float: ... diff --git a/src/Base/Unit.pyi b/src/Base/Unit.pyi index 876b713069..e33fb19567 100644 --- a/src/Base/Unit.pyi +++ b/src/Base/Unit.pyi @@ -5,7 +5,6 @@ from __future__ import annotations from Metadata import export from PyObjectBase import PyObjectBase from Quantity import Quantity -from Unit import Unit from typing import Final, Tuple, overload @export( diff --git a/src/Gui/LinkView.pyi b/src/Gui/LinkView.pyi index 0c4027e2d0..0235143cd1 100644 --- a/src/Gui/LinkView.pyi +++ b/src/Gui/LinkView.pyi @@ -25,6 +25,14 @@ class LinkView(BaseClass): """ ... + @overload + def setMaterial(self, material: None, /) -> None: ... + @overload + def setMaterial(self, material: Any, /) -> None: ... + @overload + def setMaterial(self, material: List[Any], /) -> None: ... + @overload + def setMaterial(self, material: Dict[int, Any], /) -> None: ... def setMaterial(self, material: Any, /) -> None: """ setMaterial(Material): set the override material of the entire linked object @@ -41,14 +49,11 @@ class LinkView(BaseClass): """ ... + @overload - def setMaterial(self, material: None, /) -> None: ... + def setType(self, type: int, /) -> None: ... @overload - def setMaterial(self, material: Any, /) -> None: ... - @overload - def setMaterial(self, material: List[Any], /) -> None: ... - @overload - def setMaterial(self, material: Dict[int, Any], /) -> None: ... + def setType(self, type: int, sublink: bool, /) -> None: ... def setType(self, type: int, sublink: bool = True, /) -> None: """ setType(type, sublink=True): set the link type. @@ -65,9 +70,11 @@ class LinkView(BaseClass): ... @overload - def setType(self, type: int, /) -> None: ... + def setTransform(self, matrix: Any, /) -> None: ... @overload - def setType(self, type: int, sublink: bool, /) -> None: ... + def setTransform(self, matrix: List[Any], /) -> None: ... + @overload + def setTransform(self, matrix: Dict[int, Any], /) -> None: ... def setTransform(self, matrix: Any, /) -> None: """ setTransform(matrix): set transformation of the linked object @@ -80,12 +87,6 @@ class LinkView(BaseClass): """ ... - @overload - def setTransform(self, matrix: Any, /) -> None: ... - @overload - def setTransform(self, matrix: List[Any], /) -> None: ... - @overload - def setTransform(self, matrix: Dict[int, Any], /) -> None: ... def setChildren(self, children: List[Any], vis: List[Any] = [], type: int = 0, /) -> None: """ setChildren([obj...],vis=[],type=0) @@ -102,6 +103,12 @@ class LinkView(BaseClass): """ ... + @overload + def setLink(self, obj: Any, /) -> None: ... + @overload + def setLink(self, obj: Any, subname: str, /) -> None: ... + @overload + def setLink(self, obj: Any, subname: List[str], /) -> None: ... def setLink(self, obj: Any, subname: Any = None, /) -> None: """ setLink(object): Set the link @@ -119,12 +126,6 @@ class LinkView(BaseClass): """ ... - @overload - def setLink(self, obj: Any, /) -> None: ... - @overload - def setLink(self, obj: Any, subname: str, /) -> None: ... - @overload - def setLink(self, obj: Any, subname: List[str], /) -> None: ... def getDetailPath(self, element: Any, /) -> Tuple[Any, Any]: """ getDetailPath(element): get the 3d path an detail of an element. diff --git a/src/Mod/Part/App/TopoShape.pyi b/src/Mod/Part/App/TopoShape.pyi index de97dbf347..d59ebef2ae 100644 --- a/src/Mod/Part/App/TopoShape.pyi +++ b/src/Mod/Part/App/TopoShape.pyi @@ -521,6 +521,12 @@ class TopoShape(ComplexGeoData): """ ... + @overload + @constmethod + def makeFillet(self, radius: float, edgeList: List, /) -> TopoShape: ... + @overload + @constmethod + def makeFillet(self, radius1: float, radius2: float, edgeList: List, /) -> TopoShape: ... @constmethod def makeFillet(self, *args) -> TopoShape: """ @@ -531,12 +537,13 @@ class TopoShape(ComplexGeoData): """ ... + @overload @constmethod - def makeFillet(self, radius: float, edgeList: List, /) -> TopoShape: ... + def makeChamfer(self, radius: float, edgeList: List, /) -> TopoShape: ... @overload @constmethod - def makeFillet(self, radius1: float, radius2: float, edgeList: List, /) -> TopoShape: ... + def makeChamfer(self, radius1: float, radius2: float, edgeList: List, /) -> TopoShape: ... @constmethod def makeChamfer(self, *args) -> TopoShape: """ @@ -547,12 +554,6 @@ class TopoShape(ComplexGeoData): """ ... - @overload - @constmethod - def makeChamfer(self, radius: float, edgeList: List, /) -> TopoShape: ... - @overload - @constmethod - def makeChamfer(self, radius1: float, radius2: float, edgeList: List, /) -> TopoShape: ... @constmethod def makeThickness(self, faces: List, offset: float, tolerance: float, /) -> TopoShape: """