Skip to content

Commit fa13cbb

Browse files
committed
all: Run black over all code.
Signed-off-by: Jim Mussared <[email protected]>
1 parent af3e1af commit fa13cbb

File tree

277 files changed

+11133
-8503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+11133
-8503
lines changed

make_metadata.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# MicroPython will pick up glob from the current dir otherwise.
33
import sys
4+
45
sys.path.pop(0)
56

67
import glob
@@ -68,12 +69,13 @@
6869
MicroPython-specific features to run on CPython.
6970
"""
7071

71-
MICROPYTHON_DEVELS = 'micropython-lib Developers'
72-
MICROPYTHON_DEVELS_EMAIL = '[email protected]'
73-
CPYTHON_DEVELS = 'CPython Developers'
74-
CPYTHON_DEVELS_EMAIL = '[email protected]'
75-
PYPY_DEVELS = 'PyPy Developers'
76-
PYPY_DEVELS_EMAIL = '[email protected]'
72+
MICROPYTHON_DEVELS = "micropython-lib Developers"
73+
MICROPYTHON_DEVELS_EMAIL = "[email protected]"
74+
CPYTHON_DEVELS = "CPython Developers"
75+
CPYTHON_DEVELS_EMAIL = "[email protected]"
76+
PYPY_DEVELS = "PyPy Developers"
77+
PYPY_DEVELS_EMAIL = "[email protected]"
78+
7779

7880
def parse_metadata(f):
7981
data = {}
@@ -142,7 +144,7 @@ def main():
142144
data["license"] = "MIT"
143145
elif data["srctype"] == "cpython-backport":
144146
assert module.startswith("cpython-")
145-
module = module[len("cpython-"):]
147+
module = module[len("cpython-") :]
146148
data["author"] = MICROPYTHON_DEVELS
147149
data["author_email"] = MICROPYTHON_DEVELS_EMAIL
148150
data["maintainer"] = MICROPYTHON_DEVELS
@@ -163,7 +165,9 @@ def main():
163165

164166
data["modules"] = "'" + data["name"].rsplit(".", 1)[0] + "'"
165167
if "extra_modules" in data:
166-
data["modules"] += ", " + ", ".join(["'" + x.strip() + "'" for x in data["extra_modules"].split(",")])
168+
data["modules"] += ", " + ", ".join(
169+
["'" + x.strip() + "'" for x in data["extra_modules"].split(",")]
170+
)
167171

168172
if "depends" in data:
169173
deps = ["micropython-" + x.strip() for x in data["depends"].split(",")]

micropython/test.support/setup.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import sys
2+
23
# Remove current dir from sys.path, otherwise setuptools will peek up our
34
# module instead of system's.
45
sys.path.pop(0)
56
from setuptools import setup
7+
68
sys.path.append("..")
79
import sdist_upip
810

9-
setup(name='micropython-test.support',
10-
version='0.1.3',
11-
description='test.support module for MicroPython',
12-
long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.",
13-
url='https://github.com/micropython/micropython-lib',
14-
author='micropython-lib Developers',
15-
author_email='[email protected]',
16-
maintainer='micropython-lib Developers',
17-
maintainer_email='[email protected]',
18-
license='MIT',
19-
cmdclass={'sdist': sdist_upip.sdist},
20-
packages=['test'])
11+
setup(
12+
name="micropython-test.support",
13+
version="0.1.3",
14+
description="test.support module for MicroPython",
15+
long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.",
16+
url="https://github.com/micropython/micropython-lib",
17+
author="micropython-lib Developers",
18+
author_email="[email protected]",
19+
maintainer="micropython-lib Developers",
20+
maintainer_email="[email protected]",
21+
license="MIT",
22+
cmdclass={"sdist": sdist_upip.sdist},
23+
packages=["test"],
24+
)

micropython/test.support/test/support.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import contextlib
66

77

8-
TESTFN = '@test'
8+
TESTFN = "@test"
9+
910

1011
def run_unittest(*classes):
1112
suite = unittest.TestSuite()
@@ -21,18 +22,22 @@ def run_unittest(*classes):
2122
runner = unittest.TestRunner()
2223
result = runner.run(suite)
2324

25+
2426
def can_symlink():
2527
return False
2628

29+
2730
def skip_unless_symlink(test):
2831
"""Skip decorator for tests that require functional symlink"""
2932
ok = can_symlink()
3033
msg = "Requires functional symlink implementation"
3134
return test if ok else unittest.skip(msg)(test)
3235

36+
3337
def create_empty_file(name):
3438
open(name, "w").close()
3539

40+
3641
@contextlib.contextmanager
3742
def disable_gc():
3843
have_gc = gc.isenabled()
@@ -43,11 +48,13 @@ def disable_gc():
4348
if have_gc:
4449
gc.enable()
4550

51+
4652
def gc_collect():
4753
gc.collect()
4854
gc.collect()
4955
gc.collect()
5056

57+
5158
@contextlib.contextmanager
5259
def captured_output(stream_name):
5360
org = getattr(sys, stream_name)
@@ -58,8 +65,10 @@ def captured_output(stream_name):
5865
finally:
5966
setattr(sys, stream_name, org)
6067

68+
6169
def captured_stderr():
6270
return captured_output("stderr")
6371

72+
6473
def requires_IEEE_754(f):
6574
return f

micropython/uaiohttpclient/example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ def print_stream(resp):
1414
break
1515
print(line.rstrip())
1616

17+
1718
def run(url):
1819
resp = yield from aiohttp.request("GET", url)
1920
print(resp)
2021
yield from print_stream(resp)
2122

23+
2224
import sys
2325
import logging
26+
2427
logging.basicConfig(level=logging.INFO)
2528
url = sys.argv[1]
2629
loop = asyncio.get_event_loop()

micropython/uaiohttpclient/setup.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import sys
2+
23
# Remove current dir from sys.path, otherwise setuptools will peek up our
34
# module instead of system's.
45
sys.path.pop(0)
56
from setuptools import setup
7+
68
sys.path.append("..")
79
import sdist_upip
810

9-
setup(name='micropython-uaiohttpclient',
10-
version='0.5.1',
11-
description='HTTP client module for MicroPython uasyncio module',
12-
long_description=open('README').read(),
13-
url='https://github.com/micropython/micropython-lib',
14-
author='Paul Sokolovsky',
15-
author_email='[email protected]',
16-
maintainer='micropython-lib Developers',
17-
maintainer_email='[email protected]',
18-
license='MIT',
19-
cmdclass={'sdist': sdist_upip.sdist},
20-
py_modules=['uaiohttpclient'])
11+
setup(
12+
name="micropython-uaiohttpclient",
13+
version="0.5.1",
14+
description="HTTP client module for MicroPython uasyncio module",
15+
long_description=open("README").read(),
16+
url="https://github.com/micropython/micropython-lib",
17+
author="Paul Sokolovsky",
18+
author_email="[email protected]",
19+
maintainer="micropython-lib Developers",
20+
maintainer_email="[email protected]",
21+
license="MIT",
22+
cmdclass={"sdist": sdist_upip.sdist},
23+
py_modules=["uaiohttpclient"],
24+
)

micropython/uaiohttpclient/uaiohttpclient.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
class ClientResponse:
5-
65
def __init__(self, reader):
76
self.content = reader
87

@@ -14,23 +13,22 @@ def __repr__(self):
1413

1514

1615
class ChunkedClientResponse(ClientResponse):
17-
1816
def __init__(self, reader):
1917
self.content = reader
2018
self.chunk_size = 0
2119

22-
def read(self, sz=4*1024*1024):
20+
def read(self, sz=4 * 1024 * 1024):
2321
if self.chunk_size == 0:
2422
l = yield from self.content.readline()
25-
#print("chunk line:", l)
23+
# print("chunk line:", l)
2624
l = l.split(b";", 1)[0]
2725
self.chunk_size = int(l, 16)
28-
#print("chunk size:", self.chunk_size)
26+
# print("chunk size:", self.chunk_size)
2927
if self.chunk_size == 0:
3028
# End of message
3129
sep = yield from self.content.read(2)
3230
assert sep == b"\r\n"
33-
return b''
31+
return b""
3432
data = yield from self.content.read(min(sz, self.chunk_size))
3533
self.chunk_size -= len(data)
3634
if self.chunk_size == 0:
@@ -54,9 +52,13 @@ def request_raw(method, url):
5452
# Use protocol 1.0, because 1.1 always allows to use chunked transfer-encoding
5553
# But explicitly set Connection: close, even though this should be default for 1.0,
5654
# because some servers misbehave w/o it.
57-
query = "%s /%s HTTP/1.0\r\nHost: %s\r\nConnection: close\r\nUser-Agent: compat\r\n\r\n" % (method, path, host)
58-
yield from writer.awrite(query.encode('latin-1'))
59-
# yield from writer.aclose()
55+
query = "%s /%s HTTP/1.0\r\nHost: %s\r\nConnection: close\r\nUser-Agent: compat\r\n\r\n" % (
56+
method,
57+
path,
58+
host,
59+
)
60+
yield from writer.awrite(query.encode("latin-1"))
61+
# yield from writer.aclose()
6062
return reader
6163

6264

micropython/uasyncio.core/example_call_soon.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import uasyncio.core as asyncio
22
import time
33
import logging
4+
45
logging.basicConfig(level=logging.DEBUG)
5-
#asyncio.set_debug(True)
6+
# asyncio.set_debug(True)
67

78

89
def cb():

micropython/uasyncio.core/setup.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import sys
2+
23
# Remove current dir from sys.path, otherwise setuptools will peek up our
34
# module instead of system's.
45
sys.path.pop(0)
56
from setuptools import setup
7+
68
sys.path.append("..")
79
import sdist_upip
810

9-
setup(name='micropython-uasyncio.core',
10-
version='2.0',
11-
description='Lightweight asyncio-like library for MicroPython, built around native Python coroutines. (Core event loop).',
12-
long_description='Lightweight asyncio-like library for MicroPython, built around native Python coroutines. (Core event loop).',
13-
url='https://github.com/micropython/micropython-lib',
14-
author='Paul Sokolovsky',
15-
author_email='[email protected]',
16-
maintainer='micropython-lib Developers',
17-
maintainer_email='[email protected]',
18-
license='MIT',
19-
cmdclass={'sdist': sdist_upip.sdist},
20-
packages=['uasyncio'])
11+
setup(
12+
name="micropython-uasyncio.core",
13+
version="2.0",
14+
description="Lightweight asyncio-like library for MicroPython, built around native Python coroutines. (Core event loop).",
15+
long_description="Lightweight asyncio-like library for MicroPython, built around native Python coroutines. (Core event loop).",
16+
url="https://github.com/micropython/micropython-lib",
17+
author="Paul Sokolovsky",
18+
author_email="[email protected]",
19+
maintainer="micropython-lib Developers",
20+
maintainer_email="[email protected]",
21+
license="MIT",
22+
cmdclass={"sdist": sdist_upip.sdist},
23+
packages=["uasyncio"],
24+
)

micropython/uasyncio.core/test_cancel.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
import time
2+
23
try:
34
import uasyncio.core as asyncio
5+
46
is_uasyncio = True
57
except ImportError:
68
import asyncio
9+
710
is_uasyncio = False
811
import logging
9-
#logging.basicConfig(level=logging.DEBUG)
10-
#asyncio.set_debug(True)
12+
13+
# logging.basicConfig(level=logging.DEBUG)
14+
# asyncio.set_debug(True)
1115

1216

1317
output = []
1418
cancelled = False
1519

20+
1621
def print1(msg):
1722
print(msg)
1823
output.append(msg)
1924

25+
2026
def looper1(iters):
2127
global cancelled
2228
try:
2329
for i in range(iters):
2430
print1("ping1")
2531
# sleep() isn't properly cancellable
26-
#yield from asyncio.sleep(1.0)
32+
# yield from asyncio.sleep(1.0)
2733
t = time.time()
2834
while time.time() - t < 1:
2935
yield from asyncio.sleep(0)
@@ -32,11 +38,12 @@ def looper1(iters):
3238
print1("cancelled")
3339
cancelled = True
3440

41+
3542
def looper2(iters):
3643
for i in range(iters):
3744
print1("ping2")
3845
# sleep() isn't properly cancellable
39-
#yield from asyncio.sleep(1.0)
46+
# yield from asyncio.sleep(1.0)
4047
t = time.time()
4148
while time.time() - t < 1:
4249
yield from asyncio.sleep(0)
@@ -66,7 +73,7 @@ def run_to():
6673
yield from asyncio.sleep(0)
6774

6875
# Once saw 3 ping3's output on CPython 3.5.2
69-
assert output == ['ping1', 'ping1', 'ping1', 'cancelled', 'ping2', 'ping2']
76+
assert output == ["ping1", "ping1", "ping1", "cancelled", "ping2", "ping2"]
7077

7178

7279
loop = asyncio.get_event_loop()

micropython/uasyncio.core/test_fair_schedule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async def done():
2222
global test_finished
2323
while True:
2424
if len(result) == COROS * ITERS:
25-
#print(result)
25+
# print(result)
2626
assert result == list(range(COROS)) * ITERS
2727
test_finished = True
2828
return

0 commit comments

Comments
 (0)