From e14146d7c915d244d591eb65d42424f347dedc1a Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 11 Jun 2024 15:06:44 +0200 Subject: [PATCH] Fix consider-using-with pylint warnings in matrix tests (#119365) --- tests/components/matrix/conftest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/components/matrix/conftest.py b/tests/components/matrix/conftest.py index f65deea8dad..bb5448a8a09 100644 --- a/tests/components/matrix/conftest.py +++ b/tests/components/matrix/conftest.py @@ -24,6 +24,7 @@ from nio import ( ) from PIL import Image import pytest +from typing_extensions import Generator from homeassistant.components.matrix import ( CONF_COMMANDS, @@ -305,9 +306,9 @@ def command_events(hass: HomeAssistant): @pytest.fixture -def image_path(tmp_path: Path): +def image_path(tmp_path: Path) -> Generator[tempfile._TemporaryFileWrapper]: """Provide the Path to a mock image.""" image = Image.new("RGBA", size=(50, 50), color=(256, 0, 0)) - image_file = tempfile.NamedTemporaryFile(dir=tmp_path) - image.save(image_file, "PNG") - return image_file + with tempfile.NamedTemporaryFile(dir=tmp_path) as image_file: + image.save(image_file, "PNG") + yield image_file