diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cfdaba55..74cb0ee4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,11 +20,7 @@ repos: hooks: - id: ruff args: [--fix, --show-fixes] - - - repo: https://github.com/psf/black - rev: 23.10.1 - hooks: - - id: black + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.6.1 diff --git a/pyproject.toml b/pyproject.toml index 68c05828..a0da9f5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,6 @@ version_scheme = "post-release" local_scheme = "dirty-tag" [tool.ruff] -line-length = 88 select = [ "E", "F", "W", # default flake-8 "I", # isort diff --git a/src/anyio/_backends/_asyncio.py b/src/anyio/_backends/_asyncio.py index fc027b52..1ab1443c 100644 --- a/src/anyio/_backends/_asyncio.py +++ b/src/anyio/_backends/_asyncio.py @@ -317,9 +317,7 @@ def get_callable_name(func: Callable) -> str: # Event loop # -_run_vars = ( - WeakKeyDictionary() -) # type: WeakKeyDictionary[asyncio.AbstractEventLoop, Any] +_run_vars: WeakKeyDictionary[asyncio.AbstractEventLoop, Any] = WeakKeyDictionary() def _task_started(task: asyncio.Task) -> bool: @@ -2072,7 +2070,7 @@ async def run_sync_in_worker_thread( _threadpool_idle_workers.set(idle_workers) _threadpool_workers.set(workers) - async with (limiter or cls.current_default_thread_limiter()): + async with limiter or cls.current_default_thread_limiter(): with CancelScope(shield=not cancellable): future: asyncio.Future = asyncio.Future() root_task = find_root_task() diff --git a/src/anyio/abc/_sockets.py b/src/anyio/abc/_sockets.py index f7b00b47..b321225a 100644 --- a/src/anyio/abc/_sockets.py +++ b/src/anyio/abc/_sockets.py @@ -77,9 +77,9 @@ def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]: # Provide local and remote ports for IP based sockets if self._raw_socket.family in (AddressFamily.AF_INET, AddressFamily.AF_INET6): - attributes[ - SocketAttribute.local_port - ] = lambda: self._raw_socket.getsockname()[1] + attributes[SocketAttribute.local_port] = ( + lambda: self._raw_socket.getsockname()[1] + ) if peername is not None: remote_port = peername[1] attributes[SocketAttribute.remote_port] = lambda: remote_port diff --git a/src/anyio/to_process.py b/src/anyio/to_process.py index f3ccef5c..2867d42d 100644 --- a/src/anyio/to_process.py +++ b/src/anyio/to_process.py @@ -98,7 +98,7 @@ async def send_raw_command(pickled_cmd: bytes) -> object: _process_pool_idle_workers.set(idle_workers) get_async_backend().setup_process_pool_exit_at_shutdown(workers) - async with (limiter or current_default_process_limiter()): + async with limiter or current_default_process_limiter(): # Pop processes from the pool (starting from the most recently used) until we # find one that hasn't exited yet process: Process diff --git a/tests/streams/test_text.py b/tests/streams/test_text.py index 804c8fd3..f1f59099 100644 --- a/tests/streams/test_text.py +++ b/tests/streams/test_text.py @@ -31,8 +31,7 @@ async def test_send() -> None: @pytest.mark.xfail( - platform.python_implementation() == "PyPy" - and sys.pypy_version_info < (7, 3, 2), # type: ignore[attr-defined] + platform.python_implementation() == "PyPy" and sys.pypy_version_info < (7, 3, 2), # type: ignore[attr-defined] reason="PyPy has a bug in its incremental UTF-8 decoder (#3274)", ) async def test_receive_encoding_error() -> None: diff --git a/tests/test_from_thread.py b/tests/test_from_thread.py index 168c9086..ab577f7e 100644 --- a/tests/test_from_thread.py +++ b/tests/test_from_thread.py @@ -479,7 +479,8 @@ def taskfunc(*, task_status: TaskStatus) -> None: with start_blocking_portal(anyio_backend_name, anyio_backend_options) as portal: future, start_value = portal.start_task( - taskfunc, name="testname" # type: ignore[arg-type] + taskfunc, # type: ignore[arg-type] + name="testname", ) assert start_value == "testname"