Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions marimo/_runtime/packages/import_error_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,21 @@ def extract_packages_from_pip_install_suggestion(
def extract_packages_special_cases(message: str) -> list[str] | None:
"""Extract package names based on special case substrings in error messages."""

special_cases = {
# Convert special_cases to a tuple for faster looping (constant and short)
special_cases = (
# pd.DataFrame.to_parquet()
"Unable to find a usable engine; tried using: 'pyarrow', 'fastparquet'.": [
"pyarrow"
],
}
(
"Unable to find a usable engine; tried using: 'pyarrow', 'fastparquet'.",
["pyarrow"],
),
)

packages = []
for substring, package_names in special_cases.items():
# Avoid using a new list, return immediately on first match (behavior: single assignment ok)
for substring, package_names in special_cases:
if substring in message:
packages.extend(package_names)
return package_names

return packages if packages else None
return None


def try_extract_packages_from_import_error_message(
Expand Down