From 21cf1c75a9184e3a4cb6467d026cb496b8b1452a Mon Sep 17 00:00:00 2001 From: engineerlisa <7405881+engineerlisa@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:19:51 -0500 Subject: [PATCH 1/2] Fix: dependency hints on ImportError (714) --- src/evaluate/loading.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evaluate/loading.py b/src/evaluate/loading.py index a9cbbe60..32f089dd 100644 --- a/src/evaluate/loading.py +++ b/src/evaluate/loading.py @@ -265,7 +265,7 @@ def _download_additional_modules( raise ImportError( f"To be able to use {name}, you need to install the following dependencies" f"{[lib_name for lib_name, lib_path in needs_to_be_installed]} using 'pip install " - f"{' '.join([lib_path for lib_name, lib_path in needs_to_be_installed])}' for instance'" + f"{' '.join([lib_name for lib_name, lib_path in needs_to_be_installed])}' for instance'" ) return local_imports From 1a1180a1fc627d82c7a22677806d39a45576b760 Mon Sep 17 00:00:00 2001 From: engineerlisa <7405881+engineerlisa@users.noreply.github.com> Date: Mon, 10 Nov 2025 15:00:01 -0500 Subject: [PATCH 2/2] improve error messages, cleanup --- src/evaluate/loading.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/evaluate/loading.py b/src/evaluate/loading.py index 32f089dd..379ee4ae 100644 --- a/src/evaluate/loading.py +++ b/src/evaluate/loading.py @@ -243,7 +243,7 @@ def _download_additional_modules( elif import_type == "external": url_or_filename = import_path else: - raise ValueError("Wrong import_type") + raise ValueError(f"Wrong import_type: {import_type!r}. Expected 'library', 'internal', or 'external'.") local_import_path = cached_path( url_or_filename, @@ -255,17 +255,17 @@ def _download_additional_modules( # Check library imports needs_to_be_installed = set() - for library_import_name, library_import_path in library_imports: + for library_import_name, _ in library_imports: try: - lib = importlib.import_module(library_import_name) # noqa F841 + importlib.import_module(library_import_name) # noqa F841 except ImportError: library_import_name = "scikit-learn" if library_import_name == "sklearn" else library_import_name - needs_to_be_installed.add((library_import_name, library_import_path)) + needs_to_be_installed.add(library_import_name) if needs_to_be_installed: + missing = sorted(needs_to_be_installed) raise ImportError( - f"To be able to use {name}, you need to install the following dependencies" - f"{[lib_name for lib_name, lib_path in needs_to_be_installed]} using 'pip install " - f"{' '.join([lib_name for lib_name, lib_path in needs_to_be_installed])}' for instance'" + f"To be able to use {name}, you need to install these dependencies: " + f"{', '.join(missing)} using the command 'pip install {' '.join(missing)}'." ) return local_imports