diff options
author | Yury Selivanov <yury@magic.io> | 2017-12-10 23:36:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-10 23:36:12 (GMT) |
commit | 6370f345e1d5829e1fba59cd695c8b82c5a8c620 (patch) | |
tree | ba648772068abc784cef9e7b2e0be159646d7514 /Lib/asyncio/locks.py | |
parent | c4d9df5fd719ad08e68e0950ce22a80f43e4f35d (diff) | |
download | cpython-6370f345e1d5829e1fba59cd695c8b82c5a8c620.zip cpython-6370f345e1d5829e1fba59cd695c8b82c5a8c620.tar.gz cpython-6370f345e1d5829e1fba59cd695c8b82c5a8c620.tar.bz2 |
bpo-32262: Fix codestyle; use f-strings formatting where necessary. (#4775)
Diffstat (limited to 'Lib/asyncio/locks.py')
-rw-r--r-- | Lib/asyncio/locks.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/Lib/asyncio/locks.py b/Lib/asyncio/locks.py index 57eb69e..54f6258 100644 --- a/Lib/asyncio/locks.py +++ b/Lib/asyncio/locks.py @@ -1,6 +1,6 @@ """Synchronization primitives.""" -__all__ = ['Lock', 'Event', 'Condition', 'Semaphore', 'BoundedSemaphore'] +__all__ = ('Lock', 'Event', 'Condition', 'Semaphore', 'BoundedSemaphore') import collections import warnings @@ -157,8 +157,8 @@ class Lock(_ContextManagerMixin): res = super().__repr__() extra = 'locked' if self._locked else 'unlocked' if self._waiters: - extra = '{},waiters:{}'.format(extra, len(self._waiters)) - return '<{} [{}]>'.format(res[1:-1], extra) + extra = f'{extra}, waiters:{len(self._waiters)}' + return f'<{res[1:-1]} [{extra}]>' def locked(self): """Return True if lock is acquired.""" @@ -233,8 +233,8 @@ class Event: res = super().__repr__() extra = 'set' if self._value else 'unset' if self._waiters: - extra = '{},waiters:{}'.format(extra, len(self._waiters)) - return '<{} [{}]>'.format(res[1:-1], extra) + extra = f'{extra}, waiters:{len(self._waiters)}' + return f'<{res[1:-1]} [{extra}]>' def is_set(self): """Return True if and only if the internal flag is true.""" @@ -310,8 +310,8 @@ class Condition(_ContextManagerMixin): res = super().__repr__() extra = 'locked' if self.locked() else 'unlocked' if self._waiters: - extra = '{},waiters:{}'.format(extra, len(self._waiters)) - return '<{} [{}]>'.format(res[1:-1], extra) + extra = f'{extra}, waiters:{len(self._waiters)}' + return f'<{res[1:-1]} [{extra}]>' async def wait(self): """Wait until notified. @@ -419,11 +419,10 @@ class Semaphore(_ContextManagerMixin): def __repr__(self): res = super().__repr__() - extra = 'locked' if self.locked() else 'unlocked,value:{}'.format( - self._value) + extra = 'locked' if self.locked() else f'unlocked, value:{self._value}' if self._waiters: - extra = '{},waiters:{}'.format(extra, len(self._waiters)) - return '<{} [{}]>'.format(res[1:-1], extra) + extra = f'{extra}, waiters:{len(self._waiters)}' + return f'<{res[1:-1]} [{extra}]>' def _wake_up_next(self): while self._waiters: |