Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7cb58e9

Browse files
committed
Add type hints
1 parent f1f0a9c commit 7cb58e9

File tree

7 files changed

+53
-1
lines changed

7 files changed

+53
-1
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ before_install:
1616
- xpra --xvfb="Xorg +extension RANDR -config `pwd`/tests/dummy.xorg.conf -logfile ${HOME}/.xpra/xorg.log" start :42
1717

1818
install:
19+
- pip install mypy
1920
- python setup.py install
2021

21-
script: py.test --display=":42.0"
22+
script:
23+
- py.test --display=":42.0"
24+
- mypy --check-untyped-defs --warn-incomplete-stub -m mss
2225

2326
after_script:
2427
- xpra stop :42

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ History:
44

55
dev
66
- change license to MIT
7+
- add type hints
78
- add documentation (fix #10)
89
- add tests and use Travis CI (fix #9)
910
- Linux: remove MSS library

mss/base.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import Callable, Iterator
2+
3+
4+
class MSSBase(object):
5+
monitors = [] # type: list
6+
image = None # type: bytes
7+
width = 0 # type: int
8+
height = 0 # type: int
9+
10+
def __enter__(self) -> object: ...
11+
def __exit__(self, exc_type, exc_value, traceback) -> None: ...
12+
def bgra_to_rgb(self, raw: bytearray) -> bytes: ...
13+
def enum_display_monitors(self, force: bool=False) -> list: ...
14+
def get_pixels(self, monitor: dict) -> bytes: ...
15+
def save(self, mon: int=0, output: str='monitor-%d.png', callback: Callable[[str], None]=None) -> Iterator[str]: ...
16+
def to_png(self, data: bytes, output: str) -> None: ...

mss/darwin.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import Any
2+
from .base import MSSBase
3+
4+
5+
def cgfloat() -> Any: ...
6+
def get_infinity(maxi: bool=False) -> float: ...
7+
8+
9+
class MSS(MSSBase):
10+
def _set_argtypes(self) -> None: ...
11+
def _set_restypes(self) -> None: ...

mss/factory.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from typing import Any
2+
3+
4+
def mss(*args: Any, **kwargs: Any) -> object: ...

mss/linux.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from .base import MSSBase
2+
3+
4+
class MSS(MSSBase):
5+
def __del__(self) -> None: ...
6+
def __init__(self, display: str=None) -> None: ...
7+
def _set_argtypes(self) -> None: ...
8+
def _set_restypes(self) -> None: ...
9+
10+
11+
def arch() -> int: ...

mss/windows.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import Callable
2+
from .base import MSSBase
3+
4+
5+
def set_argtypes(callback: Callable) -> None: ...
6+
def set_restypes() -> None: ...

0 commit comments

Comments
 (0)