Skip to content

Commit d6bb083

Browse files
committed
Correct camera stubs
list_cameras might return the list [0], so it could be a list of int. Also remove the default value from the Camera.init device parameter. It's not present in the _camera backends.
1 parent 0c2020e commit d6bb083

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

buildconfig/stubs/pygame/camera.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from pygame.typing import IntPoint
77
def get_backends() -> list[str]: ...
88
def init(backend: str | None = None) -> None: ...
99
def quit() -> None: ...
10-
def list_cameras() -> list[str]: ...
10+
def list_cameras() -> list[str] | list[int]: ...
1111
def colorspace(
1212
surface: Surface, color: Literal["YUV", "HSV"], dest_surface: Surface = ..., /
1313
) -> Surface: ...
@@ -34,7 +34,7 @@ class AbstractCamera(ABC):
3434
class Camera(AbstractCamera):
3535
def __init__(
3636
self,
37-
device: str | int = 0,
37+
device: str | int,
3838
size: IntPoint = (640, 480),
3939
format: str = "RGB",
4040
) -> None: ...

src_py/_camera_opencv.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def list_cameras_darwin():
3333

3434

3535
class Camera:
36+
# device should not have a default argument!!
37+
# leaving here for compatibility, but I fixed the stubs.
3638
def __init__(self, device=0, size=(640, 480), mode="RGB"):
3739
self._device_index = device
3840
self._size = size

0 commit comments

Comments
 (0)