From b050f4c042087841db78cd11fce5a1873e7b0e20 Mon Sep 17 00:00:00 2001 From: Martonveghcode Date: Sun, 28 Jun 2026 18:36:43 +0200 Subject: [PATCH] Improve invalid source type error --- packages/markitdown/src/markitdown/_markitdown.py | 2 +- packages/markitdown/tests/test_module_misc.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/markitdown/src/markitdown/_markitdown.py b/packages/markitdown/src/markitdown/_markitdown.py index f6aa4df0e..736c98e2c 100644 --- a/packages/markitdown/src/markitdown/_markitdown.py +++ b/packages/markitdown/src/markitdown/_markitdown.py @@ -319,7 +319,7 @@ def convert( return self.convert_stream(source, stream_info=stream_info, **kwargs) else: raise TypeError( - f"Invalid source type: {type(source)}. Expected str, requests.Response, BinaryIO." + f"Invalid source type: {type(source)}. Expected str, pathlib.Path, requests.Response, or BinaryIO." ) def convert_local( diff --git a/packages/markitdown/tests/test_module_misc.py b/packages/markitdown/tests/test_module_misc.py index 4d62e4919..995670bb2 100644 --- a/packages/markitdown/tests/test_module_misc.py +++ b/packages/markitdown/tests/test_module_misc.py @@ -432,6 +432,19 @@ def test_exceptions() -> None: assert type(exc_info.value.attempts[0].converter).__name__ == "PptxConverter" +def test_invalid_source_type_error_lists_supported_types() -> None: + markitdown = MarkItDown() + + with pytest.raises(TypeError) as exc_info: + markitdown.convert(None) + + message = str(exc_info.value) + assert "str" in message + assert "pathlib.Path" in message + assert "requests.Response" in message + assert "BinaryIO" in message + + @pytest.mark.skipif( skip_exiftool, reason="do not run if exiftool is not installed",