diff --git a/homeassistant/components/downloader/services.py b/homeassistant/components/downloader/services.py index cce8c9d65b0..bb1b968dd99 100644 --- a/homeassistant/components/downloader/services.py +++ b/homeassistant/components/downloader/services.py @@ -65,12 +65,10 @@ def download_file(service: ServiceCall) -> None: else: if filename is None and "content-disposition" in req.headers: - match = re.findall( + if match := re.search( r"filename=(\S+)", req.headers["content-disposition"] - ) - - if match: - filename = match[0].strip("'\" ") + ): + filename = match.group(1).strip("'\" ") if not filename: filename = os.path.basename(url).strip() diff --git a/homeassistant/components/qbus/entity.py b/homeassistant/components/qbus/entity.py index ec800c15afa..91e4d83b548 100644 --- a/homeassistant/components/qbus/entity.py +++ b/homeassistant/components/qbus/entity.py @@ -48,11 +48,8 @@ def add_new_outputs( def format_ref_id(ref_id: str) -> str | None: """Format the Qbus ref_id.""" - matches: list[str] = re.findall(_REFID_REGEX, ref_id) - - if len(matches) > 0: - if ref_id := matches[0]: - return ref_id.replace("/", "-") + if match := _REFID_REGEX.search(ref_id): + return match.group(1).replace("/", "-") return None