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

Skip to content

Commit 977f486

Browse files
committed
Move type hints to stubs directory
1 parent 7521d87 commit 977f486

File tree

16 files changed

+74
-49
lines changed

16 files changed

+74
-49
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ install:
2323
script:
2424
- py.test --display=":42.0"
2525
- flake8 mss
26-
# - mypy --check-untyped-defs --warn-incomplete-stub -m mss
2726

2827
after_script:
2928
- xpra stop :42

docs/source/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ Screenshot of the monitor 1 with callback::
3333

3434

3535
def on_exists(fname):
36+
# type: (str) -> None
3637
''' Callback example when we try to overwrite an existing screenshot. '''
3738

3839
if isfile(fname):
3940
newfile = fname + '.old'
4041
print('{0} -> {1}'.format(fname, newfile))
4142
rename(fname, newfile)
42-
return True
4343

4444

4545
for filename in sct.save(mon=1, callback=on_exists):

examples/callback.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
from os import rename
88
from os.path import isfile
99

10-
from mss import mss, ScreenshotError
10+
from mss.exception import ScreenshotError
11+
from mss.factory import mss
1112

1213

1314
def main():
15+
# type: () -> int
1416
''' Usage example. '''
1517

1618
def on_exists(fname):
19+
# type: (str) -> None
1720
''' Callback example when we try to overwrite an existing
1821
screenshot.
1922
'''
@@ -22,26 +25,25 @@ def on_exists(fname):
2225
newfile = fname + '.old'
2326
print('{0} -> {1}'.format(fname, newfile))
2427
rename(fname, newfile)
25-
return True
2628

2729
try:
28-
with mss() as screenshotter:
30+
with mss() as sct:
2931
# For MacOS X only
30-
# screenshotter.max_displays = 32
32+
# sct.max_displays = 32
3133

3234
print('One screenshot per monitor')
33-
for filename in screenshotter.save():
35+
for filename in sct.save():
3436
print(filename)
3537

3638
print("\nScreenshot of the monitor 1")
37-
print(next(screenshotter.save(mon=1, output='monitor-%d.png')))
39+
print(next(sct.save(mon=1, output='monitor-%d.png')))
3840

3941
print("\nA screenshot to grab them all")
40-
print(next(screenshotter.save(mon=-1, output='fullscreen.png')))
42+
print(next(sct.save(mon=-1, output='fullscreen.png')))
4143

4244
print("\nScreenshot of the monitor 1, with callback")
43-
print(next(screenshotter.save(mon=1, output='mon-%d.png',
44-
callback=on_exists)))
45+
print(next(sct.save(mon=1, output='mon-%d.png',
46+
callback=on_exists)))
4547

4648
return 0
4749
except ScreenshotError as ex:

examples/linux-display_keyword.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
Source: https://github.com/BoboTiG/python-mss
55
'''
66

7-
from mss import ScreenshotError
7+
from mss.exception import ScreenshotError
88
from mss.linux import MSS
99

1010

1111
def main():
12+
# type: () -> int
1213
''' Usage example with a specific display. '''
1314

1415
display = ':0.0'
1516
print('Screenshot of display "{0}"'.format(display))
1617

1718
try:
18-
with MSS(display=display) as screenshotter:
19+
with MSS(display=display) as sct:
1920
output = 'monitor{0}-%d.png'.format(display)
20-
for filename in screenshotter.save(output=output):
21+
for filename in sct.save(output=output):
2122
print(filename)
2223

2324
return 0

examples/pil.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,30 @@
44
Source: https://github.com/BoboTiG/python-mss
55
'''
66

7-
from mss import mss, ScreenshotError
7+
from mss.exception import ScreenshotError
8+
from mss.factory import mss
89
from PIL import Image
910

1011

1112
def main():
13+
# type: () -> int
1214
''' PIL example using frombytes(). '''
1315

1416
try:
15-
with mss() as screenshotter:
17+
with mss() as sct:
1618
# We retrieve monitors informations:
17-
monitors = screenshotter.enum_display_monitors()
19+
monitors = sct.enum_display_monitors()
1820

1921
# Get rid of the first, as it represents the "All in One" monitor:
2022
for num, monitor in enumerate(monitors[1:], 1):
2123
# Get raw pixels from the screen.
2224
# This method will store screen size into `width` and `height`
2325
# and raw pixels into `image`.
24-
screenshotter.get_pixels(monitor)
26+
sct.get_pixels(monitor)
2527

2628
# Create an Image:
27-
size = (screenshotter.width, screenshotter.height)
28-
img = Image.frombytes('RGB', size, screenshotter.image)
29+
size = (sct.width, sct.height)
30+
img = Image.frombytes('RGB', size, sct.image)
2931

3032
# And save it!
3133
output = 'monitor-{0}.png'.format(num)

mss/base.pyi

Lines changed: 0 additions & 16 deletions
This file was deleted.

mss/factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .exception import ScreenshotError
1010

1111

12-
def mss(*args, **kwargs):
12+
def mss(**kwargs):
1313
''' Factory returning a proper MSS class instance.
1414
1515
It detects the plateform we are running on
@@ -31,4 +31,4 @@ def mss(*args, **kwargs):
3131
err = 'System "{0}" not implemented.'.format(operating_system)
3232
raise ScreenshotError(err)
3333

34-
return MSS(*args, **kwargs)
34+
return MSS(**kwargs)

mss/factory.pyi

Lines changed: 0 additions & 4 deletions
This file was deleted.

mss/windows.pyi

Lines changed: 0 additions & 6 deletions
This file was deleted.

stubs/mss/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Stubs for mss

0 commit comments

Comments
 (0)