Skip to content

Commit eca18aa

Browse files
1st1ned-deily
authored andcommitted
bpo-34616: Fix code style and unbreak buildbots (GH-13473)
See also PR GH-13148.
1 parent 7abf8c6 commit eca18aa

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

Lib/test/test_builtin.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,10 @@ def f(): """doc"""
367367
def test_compile_top_level_await(self):
368368
"""Test whether code some top level await can be compiled.
369369
370-
Make sure it compiles only with the PyCF_ALLOW_TOP_LEVEL_AWAIT flag set,
371-
and make sure the generated code object has the CO_COROUTINE flag set in
372-
order to execute it with `await eval(.....)` instead of exec, or via a
373-
FunctionType.
370+
Make sure it compiles only with the PyCF_ALLOW_TOP_LEVEL_AWAIT flag
371+
set, and make sure the generated code object has the CO_COROUTINE flag
372+
set in order to execute it with `await eval(.....)` instead of exec,
373+
or via a FunctionType.
374374
"""
375375

376376
# helper function just to check we can run top=level async-for
@@ -379,35 +379,37 @@ async def arange(n):
379379
yield i
380380

381381
modes = ('single', 'exec')
382-
code_samples = ['''a = await asyncio.sleep(0, result=1)''',
383-
'''async for i in arange(1):
384-
a = 1''',
385-
'''async with asyncio.Lock() as l:
386-
a = 1''']
382+
code_samples = [
383+
'''a = await asyncio.sleep(0, result=1)''',
384+
'''async for i in arange(1):
385+
a = 1''',
386+
'''async with asyncio.Lock() as l:
387+
a = 1'''
388+
]
387389
policy = maybe_get_event_loop_policy()
388390
try:
389-
for mode, code_sample in product(modes,code_samples):
391+
for mode, code_sample in product(modes, code_samples):
390392
source = dedent(code_sample)
391-
with self.assertRaises(SyntaxError, msg=f"{source=} {mode=}"):
392-
compile(source, '?' , mode)
393+
with self.assertRaises(
394+
SyntaxError, msg=f"source={source} mode={mode}"):
395+
compile(source, '?', mode)
393396

394397
co = compile(source,
395398
'?',
396399
mode,
397400
flags=ast.PyCF_ALLOW_TOP_LEVEL_AWAIT)
398401

399402
self.assertEqual(co.co_flags & CO_COROUTINE, CO_COROUTINE,
400-
msg=f"{source=} {mode=}")
401-
403+
msg=f"source={source} mode={mode}")
402404

403405
# test we can create and advance a function type
404-
globals_ = {'asyncio': asyncio, 'a':0, 'arange': arange}
406+
globals_ = {'asyncio': asyncio, 'a': 0, 'arange': arange}
405407
async_f = FunctionType(co, globals_)
406408
asyncio.run(async_f())
407409
self.assertEqual(globals_['a'], 1)
408410

409411
# test we can await-eval,
410-
globals_ = {'asyncio': asyncio, 'a':0, 'arange': arange}
412+
globals_ = {'asyncio': asyncio, 'a': 0, 'arange': arange}
411413
asyncio.run(eval(co, globals_))
412414
self.assertEqual(globals_['a'], 1)
413415
finally:
@@ -416,7 +418,8 @@ async def arange(n):
416418
def test_compile_async_generator(self):
417419
"""
418420
With the PyCF_ALLOW_TOP_LEVEL_AWAIT flag added in 3.8, we want to
419-
make sure AsyncGenerators are still properly not marked with CO_COROUTINE
421+
make sure AsyncGenerators are still properly not marked with the
422+
CO_COROUTINE flag.
420423
"""
421424
code = dedent("""async def ticker():
422425
for i in range(10):
@@ -428,7 +431,6 @@ def test_compile_async_generator(self):
428431
exec(co, glob)
429432
self.assertEqual(type(glob['ticker']()), AsyncGeneratorType)
430433

431-
432434
def test_delattr(self):
433435
sys.spam = 1
434436
delattr(sys, 'spam')

0 commit comments

Comments
 (0)