From e9e6856467ff89f2933f11f2bc0f64362a706e9f Mon Sep 17 00:00:00 2001 From: Konstantin Verner <52051213+konverner@users.noreply.github.com> Date: Sat, 21 Dec 2024 14:40:47 +0100 Subject: [PATCH] chore: precise typing --- src/markitdown/_markitdown.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/markitdown/_markitdown.py b/src/markitdown/_markitdown.py index 789c1e5..17657a3 100644 --- a/src/markitdown/_markitdown.py +++ b/src/markitdown/_markitdown.py @@ -14,7 +14,7 @@ import traceback import zipfile from xml.dom import minidom -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union, IO from pathlib import Path from urllib.parse import parse_qs, quote, unquote, urlparse, urlunparse from warnings import warn, resetwarnings, catch_warnings @@ -525,7 +525,7 @@ def _get( return metadata[k] return default - def _findKey(self, json: Any, key: str) -> Union[str, None]: # TODO: Fix json type + def _findKey(self, json: Union[dict, list, Any], key: str) -> Union[str, None]: if isinstance(json, list): for elm in json: ret = self._findKey(elm, key) @@ -1330,9 +1330,8 @@ def convert_local( # Convert return self._convert(path, extensions, **kwargs) - # TODO what should stream's type be? def convert_stream( - self, stream: Any, **kwargs: Any + self, stream: IO[Any], **kwargs: Any ) -> DocumentConverterResult: # TODO: deal with kwargs # Prepare a list of extensions to try (in order of priority) ext = kwargs.get("file_extension")