From 91e389c58d0bc2d2846773369eeaf3433160729f Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 6 Mar 2023 16:16:31 +0100 Subject: [PATCH] Bump ruff to 0.0.253 (#89211) Co-authored-by: Paulus Schoutsen --- .pre-commit-config.yaml | 2 +- homeassistant/components/ps4/media_player.py | 5 ++++- homeassistant/components/zha/core/gateway.py | 5 ++++- requirements_test_pre_commit.txt | 2 +- tests/test_runner.py | 13 +++++-------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ab481ac4eaf..357e2663fcc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.247 + rev: v0.0.253 hooks: - id: ruff args: diff --git a/homeassistant/components/ps4/media_player.py b/homeassistant/components/ps4/media_player.py index 8799aad65d4..23438dd80c4 100644 --- a/homeassistant/components/ps4/media_player.py +++ b/homeassistant/components/ps4/media_player.py @@ -188,7 +188,10 @@ class PS4Device(MediaPlayerEntity): self._attr_source = self._attr_media_title self._attr_media_content_type = None # Get data from PS Store. - asyncio.ensure_future(self.async_get_title_data(title_id, name)) + self.hass.async_create_background_task( + self.async_get_title_data(title_id, name), + "ps4.media_player-get_title_data", + ) else: if self.state != MediaPlayerState.IDLE: self.idle() diff --git a/homeassistant/components/zha/core/gateway.py b/homeassistant/components/zha/core/gateway.py index 2f1b22e0ea2..1bc77d3f360 100644 --- a/homeassistant/components/zha/core/gateway.py +++ b/homeassistant/components/zha/core/gateway.py @@ -393,7 +393,10 @@ class ZHAGateway: device_info = zha_device.zha_device_info zha_device.async_cleanup_handles() async_dispatcher_send(self._hass, f"{SIGNAL_REMOVE}_{str(zha_device.ieee)}") - asyncio.ensure_future(self._async_remove_device(zha_device, entity_refs)) + self._hass.async_create_task( + self._async_remove_device(zha_device, entity_refs), + "ZHAGateway._async_remove_device", + ) if device_info is not None: async_dispatcher_send( self._hass, diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index 863b61afe5f..e2deb067d7d 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -14,5 +14,5 @@ pycodestyle==2.10.0 pydocstyle==6.2.3 pyflakes==3.0.1 pyupgrade==3.3.1 -ruff==0.0.247 +ruff==0.0.253 yamllint==1.28.0 diff --git a/tests/test_runner.py b/tests/test_runner.py index 25b75b94c3b..e4af1df2b80 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -84,11 +84,9 @@ def test_run_does_not_block_forever_with_shielded_task( """Test we can shutdown and not block forever.""" test_dir = tmpdir.mkdir("config") default_config = runner.RuntimeConfig(test_dir) - created_tasks = False + tasks = [] async def _async_create_tasks(*_): - nonlocal created_tasks - async def async_raise(*_): try: await asyncio.sleep(2) @@ -101,11 +99,10 @@ def test_run_does_not_block_forever_with_shielded_task( except asyncio.CancelledError: await asyncio.sleep(2) - asyncio.ensure_future(asyncio.shield(async_shielded())) - asyncio.ensure_future(asyncio.sleep(2)) - asyncio.ensure_future(async_raise()) + tasks.append(asyncio.ensure_future(asyncio.shield(async_shielded()))) + tasks.append(asyncio.ensure_future(asyncio.sleep(2))) + tasks.append(asyncio.ensure_future(async_raise())) await asyncio.sleep(0.1) - created_tasks = True return 0 with patch.object(runner, "TASK_CANCELATION_TIMEOUT", 1), patch( @@ -115,7 +112,7 @@ def test_run_does_not_block_forever_with_shielded_task( ): runner.run(default_config) - assert created_tasks is True + assert len(tasks) == 3 assert ( "Task could not be canceled and was still running after shutdown" in caplog.text )