Skip to content

Commit

Permalink
Improved typing for split_by_perimeter
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Oct 28, 2024
1 parent 5ed1499 commit 312b50c
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/build123d/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -2780,15 +2780,25 @@ def split(self, surface: Union[Plane, Face], keep: Keep = Keep.TOP) -> Self:

return result.unwrap(fully=True)

@overload
def split_by_perimeter(
self, perimeter: Union[Edge, Wire], keep: Keep = Keep.INSIDE
) -> Union[
self, perimeter: Union[Edge, Wire], keep: Literal[Keep.INSIDE, Keep.OUTSIDE]
) -> Union[Optional[Shell], Optional[Face]]: ...

@overload
def split_by_perimeter(
self, perimeter: Union[Edge, Wire], keep: Literal[Keep.BOTH]
) -> tuple[
Union[Optional[Shell], Optional[Face]],
tuple[
Union[Optional[Shell], Optional[Face]],
Union[Optional[Shell], Optional[Face]],
],
]:
Union[Optional[Shell], Optional[Face]],
]: ...
@overload
def split_by_perimeter(
self, perimeter: Union[Edge, Wire]
) -> Union[Optional[Shell], Optional[Face]]: ...
def split_by_perimeter(
self, perimeter: Union[Edge, Wire], keep: Keep = Keep.INSIDE
):
"""split_by_perimeter
Divide the faces of this object into those within the perimeter
Expand All @@ -2805,9 +2815,15 @@ def split_by_perimeter(
ValueError: keep must be one of Keep.INSIDE|OUTSIDE|BOTH
Returns:
Union[Union[Optional[Shell], Optional[Face]],tuple[Union[Optional[Shell],
Optional[Face]],Union[Optional[Shell], Optional[Face]]]:]: either inside,
outside or both
Union[Optional[Shell], Optional[Face],
Tuple[Optional[Shell], Optional[Face]]]: The result of the split operation.
- **Keep.INSIDE**: Returns the inside part as a `Shell` or `Face`, or `None`
if no inside part is found.
- **Keep.OUTSIDE**: Returns the outside part as a `Shell` or `Face`, or `None`
if no outside part is found.
- **Keep.BOTH**: Returns a tuple `(inside, outside)` where each element is
either a `Shell`, `Face`, or `None` if no corresponding part is found.
"""

Expand Down

0 comments on commit 312b50c

Please sign in to comment.