Skip to content

Commit

Permalink
Try fixing missing pillow types
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 31, 2022
1 parent 642d58b commit 598b336
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion stubs/D3DShot/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version = "0.1.*"
requires = ["numpy", "torch", "comtypes"]
requires = ["numpy", "torch", "comtypes", "types-Pillow"]

[tool.stubtest]
ignore_missing_stub = false
6 changes: 3 additions & 3 deletions stubs/D3DShot/d3dshot/capture_output.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import enum
from _typeshed import Incomplete
from typing_extensions import TypeAlias

from PIL.Image import Image
from PIL import Image

_Frame: TypeAlias = Incomplete
# _Frame: TypeAlias = Image | npt.NDArray[np.int32] | npt.NDArray[np.float32] | _Tensor
# _Frame: TypeAlias = Image.Image | npt.NDArray[np.int32] | npt.NDArray[np.float32] | _Tensor
_Pointer: TypeAlias = Incomplete

class CaptureOutputs(enum.Enum):
Expand All @@ -25,5 +25,5 @@ class CaptureOutput:
def process(
self, pointer: _Pointer, size: int, width: int, height: int, region: tuple[int, int, int, int], rotation: int
) -> _Frame: ...
def to_pil(self, frame: _Frame) -> Image: ...
def to_pil(self, frame: _Frame) -> Image.Image: ...
def stack(self, frames: list[_Frame], stack_dimension) -> _Frame: ...
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing_extensions import TypeAlias

from d3dshot.capture_output import CaptureOutput as CaptureOutput
from PIL.Image import Image
from PIL import Image

# TODO: Complete types once we can import non-types dependencies
# See: https://github.com/python/typeshed/issues/5768
Expand All @@ -17,5 +17,5 @@ class NumpyCaptureOutput(CaptureOutput):
def process(
self, pointer: _Pointer, size: int, width: int, height: int, region: tuple[int, int, int, int], rotation: int
) -> NDArray: ...
def to_pil(self, frame: NDArray) -> Image: ...
def to_pil(self, frame: NDArray) -> Image.Image: ...
def stack(self, frames: list[NDArray] | NDArray, stack_dimension: int) -> NDArray: ...
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing_extensions import TypeAlias

from d3dshot.capture_output import CaptureOutput as CaptureOutput
from PIL.Image import Image
from PIL import Image

# TODO: Complete types once we can import non-types dependencies
# See: https://github.com/python/typeshed/issues/5768
Expand All @@ -17,5 +17,5 @@ class NumpyFloatCaptureOutput(CaptureOutput):
def process(
self, pointer: _Pointer, size: int, width: int, height: int, region: tuple[int, int, int, int], rotation: int
) -> NDArray: ...
def to_pil(self, frame: NDArray) -> Image: ...
def to_pil(self, frame: NDArray) -> Image.Image: ...
def stack(self, frames: list[NDArray] | NDArray, stack_dimension: int) -> NDArray: ...
8 changes: 4 additions & 4 deletions stubs/D3DShot/d3dshot/capture_outputs/pil_capture_output.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ from _typeshed import Incomplete
from typing_extensions import TypeAlias

from d3dshot.capture_output import CaptureOutput as CaptureOutput
from PIL.Image import Image
from PIL import Image

_Pointer: TypeAlias = Incomplete

class PILCaptureOutput(CaptureOutput):
def __init__(self) -> None: ...
def process(
self, pointer: _Pointer, size: int, width: int, height: int, region: tuple[int, int, int, int], rotation: int
) -> Image: ...
def to_pil(self, frame: Image) -> Image: ...
def stack(self, frames: list[Image], stack_dimension: int) -> list[Image]: ...
) -> Image.Image: ...
def to_pil(self, frame: Image.Image) -> Image.Image: ...
def stack(self, frames: list[Image.Image], stack_dimension: int) -> list[Image.Image]: ...
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing_extensions import TypeAlias

from d3dshot.capture_output import CaptureOutput as CaptureOutput
from PIL.Image import Image
from PIL import Image

# TODO: Complete types once we can import non-types dependencies
# See: https://github.com/python/typeshed/issues/5768
Expand All @@ -15,5 +15,5 @@ class PytorchCaptureOutput(CaptureOutput):
def process(
self, pointer: _Pointer, size: int, width: int, height: int, region: tuple[int, int, int, int], rotation: int
) -> _Tensor: ...
def to_pil(self, frame: _Tensor) -> Image: ...
def to_pil(self, frame: _Tensor) -> Image.Image: ...
def stack(self, frames: list[_Tensor], stack_dimension: int) -> _Tensor: ...
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing_extensions import TypeAlias

from d3dshot.capture_output import CaptureOutput as CaptureOutput
from PIL.Image import Image
from PIL import Image

# TODO: Complete types once we can import non-types dependencies
# See: https://github.com/python/typeshed/issues/5768
Expand All @@ -15,5 +15,5 @@ class PytorchFloatCaptureOutput(CaptureOutput):
def process(
self, pointer: _Pointer, size: int, width: int, height: int, region: tuple[int, int, int, int], rotation: int
) -> _Tensor: ...
def to_pil(self, frame: _Tensor) -> Image: ...
def to_pil(self, frame: _Tensor) -> Image.Image: ...
def stack(self, frames: list[_Tensor], stack_dimension: int) -> _Tensor: ...
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ from _typeshed import Incomplete
from typing_extensions import TypeAlias

from d3dshot.capture_output import CaptureOutput as CaptureOutput
from PIL.Image import Image
from PIL import Image

# TODO: Complete types once we can import non-types dependencies
# See: https://github.com/python/typeshed/issues/5768
# from torch import device, Tensor
_Tensor: TypeAlias = Incomplete
_device: TypeAlias = Incomplete
_Device: TypeAlias = Incomplete
_Pointer: TypeAlias = Incomplete

class PytorchFloatGPUCaptureOutput(CaptureOutput):
device: _device
device: _Device
def __init__(self) -> None: ...
def process(
self, pointer: _Pointer, size: int, width: int, height: int, region: tuple[int, int, int, int], rotation: int
) -> _Tensor: ...
def to_pil(self, frame: _Tensor) -> Image: ...
def to_pil(self, frame: _Tensor) -> Image.Image: ...
def stack(self, frames: list[_Tensor], stack_dimension: int) -> _Tensor: ...
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ from _typeshed import Incomplete
from typing_extensions import TypeAlias

from d3dshot.capture_output import CaptureOutput as CaptureOutput
from PIL.Image import Image
from PIL import Image

# TODO: Complete types once we can import non-types dependencies
# See: https://github.com/python/typeshed/issues/5768
# from torch import device, Tensor
_Tensor: TypeAlias = Incomplete
_device: TypeAlias = Incomplete
_Device: TypeAlias = Incomplete

_Pointer: TypeAlias = Incomplete

class PytorchGPUCaptureOutput(CaptureOutput):
device: _device
device: _Device
def __init__(self) -> None: ...
def process(
self, pointer: _Pointer, size: int, width: int, height: int, region: tuple[int, int, int, int], rotation: int
) -> _Tensor: ...
def to_pil(self, frame: _Tensor) -> Image: ...
def to_pil(self, frame: _Tensor) -> Image.Image: ...
def stack(self, frames: list[_Tensor], stack_dimension: int): ...
2 changes: 1 addition & 1 deletion stubs/D3DShot/d3dshot/d3dshot.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from d3dshot.capture_output import CaptureOutput as CaptureOutput, CaptureOutput
from d3dshot.display import Display as Display

_Frame: TypeAlias = Incomplete
# _Frame: TypeAlias = Image | npt.NDArray[np.int32] | npt.NDArray[np.float32] | _Tensor
# _Frame: TypeAlias = Image.Image | npt.NDArray[np.int32] | npt.NDArray[np.float32] | _Tensor

class D3DShot:
displays: list[Display]
Expand Down
5 changes: 2 additions & 3 deletions stubs/D3DShot/d3dshot/display.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Literal
from typing_extensions import TypeAlias
from typing_extensions import Literal, TypeAlias

_Frame: TypeAlias = Incomplete
# _Frame: TypeAlias = Image | npt.NDArray[np.int32] | npt.NDArray[np.float32] | _Tensor
# _Frame: TypeAlias = Image.Image | npt.NDArray[np.int32] | npt.NDArray[np.float32] | _Tensor
_Pointer: TypeAlias = Incomplete

class Display:
Expand Down
2 changes: 1 addition & 1 deletion stubs/D3DShot/d3dshot/dll/dxgi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from typing_extensions import TypeAlias
_IUnknown: TypeAlias = Incomplete

_Frame: TypeAlias = Incomplete
# _Frame: TypeAlias = Image | npt.NDArray[np.int32] | npt.NDArray[np.float32] | Tensor
# _Frame: TypeAlias = Image.Image | npt.NDArray[np.int32] | npt.NDArray[np.float32] | Tensor
_Pointer: TypeAlias = Incomplete

class LUID(ctypes.Structure): ...
Expand Down

0 comments on commit 598b336

Please sign in to comment.