Skip to content

Commit cc45a7f

Browse files
committed
Use black autoformatting
1 parent 37b012e commit cc45a7f

18 files changed

+462
-417
lines changed

promise/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
__SETUP__ = False
1111

1212

13-
VERSION = (2, 1, 0, 'final', 0)
13+
VERSION = (2, 1, 0, "final", 0)
1414

1515
__version__ = get_version(VERSION)
1616

@@ -22,17 +22,17 @@
2222
is_thenable,
2323
async_instance,
2424
get_default_scheduler,
25-
set_default_scheduler
25+
set_default_scheduler,
2626
)
2727
from .schedulers.immediate import ImmediateScheduler
2828

2929
__all__ = [
30-
'Promise',
31-
'promise_for_dict',
32-
'promisify',
33-
'is_thenable',
34-
'async_instance',
35-
'get_default_scheduler',
36-
'set_default_scheduler',
37-
'ImmediateScheduler'
30+
"Promise",
31+
"promise_for_dict",
32+
"promisify",
33+
"is_thenable",
34+
"async_instance",
35+
"get_default_scheduler",
36+
"set_default_scheduler",
37+
"ImmediateScheduler",
3838
]

promise/async_.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Based on https://github.com/petkaantonov/bluebird/blob/master/src/promise.js
22
from collections import deque
3+
34
if False:
45
from .promise import Promise
56
from typing import Any, Callable, Optional, Union # flake8: noqa
67

78

89
class Async(object):
9-
1010
def __init__(self, trampoline_enabled=True):
1111
self.is_tick_used = False
1212
self.late_queue = deque() # type: ignore
@@ -48,18 +48,14 @@ def invoke(self, fn, scheduler):
4848
if self.trampoline_enabled:
4949
self._async_invoke(fn, scheduler)
5050
else:
51-
scheduler.call(
52-
fn
53-
)
51+
scheduler.call(fn)
5452

5553
def settle_promises(self, promise):
5654
# type: (Promise) -> None
5755
if self.trampoline_enabled:
5856
self._async_settle_promise(promise)
5957
else:
60-
promise.scheduler.call(
61-
promise._settle_promises
62-
)
58+
promise.scheduler.call(promise._settle_promises)
6359

6460
def throw_later(self, reason, scheduler):
6561
# type: (Exception, Any) -> None
@@ -74,22 +70,24 @@ def fn():
7470
def drain_queue(self, queue):
7571
# type: (deque) -> None
7672
from .promise import Promise
73+
7774
while queue:
7875
fn = queue.popleft()
79-
if (isinstance(fn, Promise)):
76+
if isinstance(fn, Promise):
8077
fn._settle_promises()
8178
continue
8279
fn()
8380

8481
def drain_queue_until_resolved(self, promise):
8582
# type: (Promise) -> None
8683
from .promise import Promise
84+
8785
queue = self.normal_queue
8886
while queue:
8987
if not promise.is_pending:
9088
return
9189
fn = queue.popleft()
92-
if (isinstance(fn, Promise)):
90+
if isinstance(fn, Promise):
9391
fn._settle_promises()
9492
continue
9593
fn()

promise/compat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
except ImportError:
44

55
class Future: # type: ignore
6-
76
def __init__(self):
87
raise Exception("You need asyncio for using Futures")
98

@@ -19,10 +18,10 @@ def ensure_future(): # type: ignore
1918
def iscoroutine(obj): # type: ignore
2019
return False
2120

21+
2222
try:
2323
from .iterate_promise import iterate_promise
2424
except (SyntaxError, ImportError):
2525

2626
def iterate_promise(promise): # type: ignore
27-
raise Exception(
28-
'You need "yield from" syntax for iterate in a Promise.')
27+
raise Exception('You need "yield from" syntax for iterate in a Promise.')

0 commit comments

Comments
 (0)