diff --git a/.style.yapf b/.style.yapf index 2c5517ec40..745ec88d70 100644 --- a/.style.yapf +++ b/.style.yapf @@ -178,3 +178,8 @@ split_penalty_logical_operator=0 # Use the Tab character for indentation. use_tabs=False +# Without this, yapf likes to write things like +# "foo bar {}". +# format(...) +# which is just awful. +split_before_dot=True diff --git a/test-requirements.in b/test-requirements.in index 5d63d3dc83..9f28aec952 100644 --- a/test-requirements.in +++ b/test-requirements.in @@ -9,7 +9,7 @@ pylint # for pylint finding all symbols tests jedi # for jedi code completion tests # Tools -yapf == 0.22.0 # formatting; also pinned in renovate.json +yapf == 0.24.0 # formatting flake8 # https://github.com/python-trio/trio/pull/654#issuecomment-420518745 diff --git a/test-requirements.txt b/test-requirements.txt index 9d226523c1..e2b1924a4b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -47,4 +47,4 @@ trustme==0.4.0 typed-ast==1.1.0 ; python_version < "3.7" and implementation_name == "cpython" wcwidth==0.1.7 # via prompt-toolkit wrapt==1.10.11 # via astroid -yapf==0.22.0 +yapf==0.24.0 diff --git a/trio/_core/_run.py b/trio/_core/_run.py index 644133bf7d..265068f96c 100644 --- a/trio/_core/_run.py +++ b/trio/_core/_run.py @@ -887,8 +887,9 @@ def _return_value_looks_like_wrong_library(value): # Give good error for: nursery.start_soon(some_sync_fn) raise TypeError( "trio expected an async function, but {!r} appears to be " - "synchronous" - .format(getattr(async_fn, "__qualname__", async_fn)) + "synchronous".format( + getattr(async_fn, "__qualname__", async_fn) + ) ) ###### diff --git a/trio/_socket.py b/trio/_socket.py index 133b32c2b9..507c4b07a6 100644 --- a/trio/_socket.py +++ b/trio/_socket.py @@ -389,8 +389,9 @@ def __init__(self, sock): # For example, ssl.SSLSocket subclasses socket.socket, but we # certainly don't want to blindly wrap one of those. raise TypeError( - "expected object of type 'socket.socket', not '{}" - .format(type(sock).__name__) + "expected object of type 'socket.socket', not '{}".format( + type(sock).__name__ + ) ) self._sock = sock self._sock.setblocking(False) diff --git a/trio/_sync.py b/trio/_sync.py index 51b095f671..f9a22b49d9 100644 --- a/trio/_sync.py +++ b/trio/_sync.py @@ -415,8 +415,9 @@ def __repr__(self): else: max_value_str = ", max_value={}".format(self._max_value) return ( - "" - .format(self._value, max_value_str, id(self)) + "".format( + self._value, max_value_str, id(self) + ) ) @property @@ -524,8 +525,9 @@ def __repr__(self): s1 = "unlocked" s2 = "" return ( - "<{} {} object at {:#x}{}>" - .format(s1, self.__class__.__name__, id(self), s2) + "<{} {} object at {:#x}{}>".format( + s1, self.__class__.__name__, id(self), s2 + ) ) def locked(self): @@ -858,8 +860,9 @@ def __init__(self, capacity): def __repr__(self): return ( - "" - .format(self.capacity, id(self), len(self._data)) + "".format( + self.capacity, id(self), len(self._data) + ) ) def qsize(self): diff --git a/trio/testing/_mock_clock.py b/trio/testing/_mock_clock.py index a013e4da79..09d3ea7091 100644 --- a/trio/testing/_mock_clock.py +++ b/trio/testing/_mock_clock.py @@ -100,8 +100,9 @@ def __init__(self, rate=0.0, autojump_threshold=inf): def __repr__(self): return ( - "" - .format(self.current_time(), self._rate, id(self)) + "".format( + self.current_time(), self._rate, id(self) + ) ) @property diff --git a/trio/tests/test_highlevel_serve_listeners.py b/trio/tests/test_highlevel_serve_listeners.py index c72f350618..7d237419a6 100644 --- a/trio/tests/test_highlevel_serve_listeners.py +++ b/trio/tests/test_highlevel_serve_listeners.py @@ -137,7 +137,8 @@ async def connection_watcher(*, task_status=trio.TASK_STATUS_IGNORED): await nursery.start( partial( trio.serve_listeners, - handler, [listener], + handler, + [listener], handler_nursery=handler_nursery ) ) diff --git a/trio/tests/test_sync.py b/trio/tests/test_sync.py index c6842ca2f8..c30992804f 100644 --- a/trio/tests/test_sync.py +++ b/trio/tests/test_sync.py @@ -228,7 +228,8 @@ async def test_Semaphore_bounded(): @pytest.mark.parametrize( - "lockcls", [Lock, StrictFIFOLock], ids=lambda fn: fn.__name__ + "lockcls", + [Lock, StrictFIFOLock], ids=lambda fn: fn.__name__ ) async def test_Lock_and_StrictFIFOLock(lockcls): l = lockcls() # noqa diff --git a/trio/tests/test_testing.py b/trio/tests/test_testing.py index 8abf8eb5ff..a7df5275d7 100644 --- a/trio/tests/test_testing.py +++ b/trio/tests/test_testing.py @@ -322,8 +322,9 @@ async def test_mock_clock_autojump(mock_clock): real_duration = time.monotonic() - real_start print( - "Slept {} seconds in {} seconds" - .format(10 * sum(range(10)), real_duration) + "Slept {} seconds in {} seconds".format( + 10 * sum(range(10)), real_duration + ) ) assert real_duration < 1