From 02e36211ff6d9e5296f7ed066af85cf5b0a948b0 Mon Sep 17 00:00:00 2001 From: s-hertel <19572925+s-hertel@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:17:23 -0500 Subject: [PATCH] Remove unnecessary parameter, and correct type hint --- lib/ansible/galaxy/collection/concrete_artifact_manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/galaxy/collection/concrete_artifact_manager.py b/lib/ansible/galaxy/collection/concrete_artifact_manager.py index 58d21b71abb..b69990b4e4a 100644 --- a/lib/ansible/galaxy/collection/concrete_artifact_manager.py +++ b/lib/ansible/galaxy/collection/concrete_artifact_manager.py @@ -14,7 +14,7 @@ import yaml from contextlib import contextmanager from hashlib import sha256 -from http.client import IncompleteRead +from http.client import IncompleteRead, HTTPResponse from urllib.error import URLError from urllib.parse import urldefrag from shutil import rmtree @@ -496,7 +496,7 @@ def _download_file(url, b_path, expected_hash, validate_certs, token=None, timeo with open(b_file_path, 'wb') as download_file: # type: t.BinaryIO try: - actual_hash = _consume_file(resp, write_to=download_file, length=resp.length) + actual_hash = _consume_file(resp, write_to=download_file) except IncompleteRead as orig_exc: raise AnsibleError(f"Downloading {url} failed") from orig_exc @@ -512,9 +512,10 @@ def _download_file(url, b_path, expected_hash, validate_certs, token=None, timeo return b_file_path -def _consume_file(read_from: t.BinaryIO, write_to: t.BinaryIO = None, *, length: None | str | int = None) -> str: +def _consume_file(read_from: t.BinaryIO | HTTPResponse, write_to: t.BinaryIO | None = None) -> str: bufsize = 65536 sha256_digest = sha256() + length = getattr(read_from, 'length', None) actual_length = 0 remaining = None while True: