Skip to content

update typing #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 44 additions & 34 deletions python/pyclipr/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Literal, Never, overload
from typing import Any, Iterable, Literal, Never, overload

import numpy as np
import numpy.typing as npt
Expand All @@ -24,27 +24,18 @@ Intersection: ClipType = ...
Xor: ClipType = ...


class FillType:
EvenOdd: FillType = ...
NonZero: FillType = ...
Positive: FillType = ...
Negative: FillType = ...

EvenOdd: FillType = ...
NonZero: FillType = ...
Positive: FillType = ...
Negative: FillType = ...
class FillRule:
EvenOdd: FillRule = ...
NonZero: FillRule = ...
Positive: FillRule = ...
Negative: FillRule = ...


class JoinType:
Square: JoinType = ...
Round: JoinType = ...
Miter: JoinType = ...

Square: JoinType = ... # FIXME
Round: JoinType = ... # FIXME
Miter: JoinType = ...


class EndType:
Square: EndType = ...
Expand All @@ -53,12 +44,6 @@ class EndType:
Polygon: EndType = ...
Round: EndType = ...

Square: EndType = ... # FIXME
Butt: EndType = ...
Joined: EndType = ...
Polygon: EndType = ...
Round: EndType = ... # FIXME


clipperVersion: str = ...

Expand Down Expand Up @@ -122,7 +107,7 @@ class PolyTreeD:


def polyTreeToPaths64(arg0: PolyTree) -> Any: ... # TODO
def orientation(path: Any, scaleFactor: float) -> bool: ... # TODO
def orientation(path: npt.NDArray[np.float64], scaleFactor: float = ...) -> bool: ...
def polyTreeToPaths(arg0: PolyTree) -> Any: ... # TODO
def simplifyPath(path: Any, epsilon: float, isOpenPath: bool = ...) -> Any: ... # TODO
def simplifyPaths(paths: Any, epsilon: float, isOpenPath: bool = ...) -> Any: ... # TODO
Expand All @@ -141,7 +126,7 @@ class Clipper:

def addPaths(
self,
paths: list[npt.NDArray[np.float64]],
paths: Iterable[npt.NDArray[np.float64]],
pathType: PathType,
isOpen: bool = ...
) -> None: ...
Expand All @@ -150,7 +135,7 @@ class Clipper:
def execute(
self,
clipType: ClipType,
fillType: FillType = ...,
fillRule: FillRule = ...,
*,
returnOpenPaths: Literal[False] = ...,
returnZ: Literal[False] = ...
Expand All @@ -160,12 +145,24 @@ class Clipper:
def execute(
self,
clipType: ClipType,
fillType: FillType = ...,
fillRule: FillRule = ...,
*,
returnOpenPaths: Literal[False] = ...,
returnZ: Literal[True] = ...
returnZ: Literal[True]
) -> tuple[
list[npt.NDArray[np.float64]],
list[npt.NDArray[np.float64]]
]: ...

@overload
def execute(
self,
clipType: ClipType,
fillRule: FillRule = ...,
*,
returnOpenPaths: Literal[True],
returnZ: Literal[False] = ...
) -> tuple[
list[npt.NDArray[np.float64]],
list[npt.NDArray[np.float64]]
]: ...
Expand All @@ -174,10 +171,10 @@ class Clipper:
def execute(
self,
clipType: ClipType,
fillType: FillType = ...,
fillRule: FillRule = ...,
*,
returnOpenPaths: Literal[True] = ...,
returnZ: bool = ...
returnOpenPaths: Literal[True],
returnZ: Literal[True]
) -> tuple[
list[npt.NDArray[np.float64]],
list[npt.NDArray[np.float64]],
Expand All @@ -189,7 +186,7 @@ class Clipper:
def execute2(
self,
clipType: ClipType,
fillType: FillType = ...,
fillRule: FillRule = ...,
*,
returnOpenPaths: Literal[False] = ...,
returnZ: bool = ...
Expand All @@ -199,10 +196,23 @@ class Clipper:
def execute2(
self,
clipType: ClipType,
fillType: FillType = ...,
fillRule: FillRule = ...,
*,
returnOpenPaths: Literal[True] = ...,
returnZ: bool = ...
returnOpenPaths: Literal[True],
returnZ: Literal[False] = ...
) -> tuple[
PolyTreeD,
list[npt.NDArray[np.float64]]
]: ...

@overload
def execute2(
self,
clipType: ClipType,
fillRule: FillRule = ...,
*,
returnOpenPaths: Literal[True],
returnZ: Literal[True]
) -> tuple[
PolyTreeD,
list[npt.NDArray[np.float64]],
Expand All @@ -229,7 +239,7 @@ class ClipperOffset:

def addPaths(
self,
paths: list[npt.NDArray[np.float64]],
paths: Iterable[npt.NDArray[np.float64]],
joinType: JoinType,
endType: EndType = ...
) -> None: ...
Expand Down