Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: precise typing for stream and json parameters #189

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
7 changes: 3 additions & 4 deletions src/markitdown/_markitdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down