From 314c0dced82dbd27c23ae45fafcb9e581f43dee4 Mon Sep 17 00:00:00 2001 From: Raduan77 Date: Wed, 18 Dec 2024 10:45:05 +0100 Subject: [PATCH] format via black --- pyproject.toml | 1 + src/markitdown/_async_wrapper.py | 10 ++++++---- tests/test_async_markitdown.py | 12 +++--------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2434f35..991b1e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ dependencies = [ dev-dependencies = [ "pytest>=7.0", "pytest-asyncio>=0.23.0", + "black>=23.7.0", ] [project.urls] diff --git a/src/markitdown/_async_wrapper.py b/src/markitdown/_async_wrapper.py index 41e928d..5efc9ba 100644 --- a/src/markitdown/_async_wrapper.py +++ b/src/markitdown/_async_wrapper.py @@ -1,16 +1,18 @@ """Async wrapper for MarkItDown.""" + import asyncio from functools import partial from typing import Optional, Union from ._markitdown import MarkItDown, DocumentConverterResult + class AsyncMarkItDown: """Async wrapper for MarkItDown that runs operations in a thread pool.""" def __init__(self, markitdown: Optional[MarkItDown] = None): """Initialize the async wrapper. - + Args: markitdown: Optional MarkItDown instance to wrap. If not provided, a new instance will be created. @@ -28,14 +30,14 @@ class AsyncMarkItDown: async def convert(self, file_path: str, **kwargs) -> DocumentConverterResult: """Convert a file to markdown asynchronously. - + This runs the synchronous convert operation in a thread pool to avoid blocking the event loop. - + Args: file_path: Path to the file to convert **kwargs: Additional arguments to pass to the converter - + Returns: DocumentConverterResult containing the converted markdown """ diff --git a/tests/test_async_markitdown.py b/tests/test_async_markitdown.py index a71ae0d..61ce0c6 100644 --- a/tests/test_async_markitdown.py +++ b/tests/test_async_markitdown.py @@ -207,15 +207,9 @@ async def test_async_markitdown_concurrent(): # Create a list of tasks tasks = [] for _ in range(5): - tasks.append( - markitdown.convert(os.path.join(TEST_FILES_DIR, "test.docx")) - ) - tasks.append( - markitdown.convert(os.path.join(TEST_FILES_DIR, "test.xlsx")) - ) - tasks.append( - markitdown.convert(os.path.join(TEST_FILES_DIR, "test.pptx")) - ) + tasks.append(markitdown.convert(os.path.join(TEST_FILES_DIR, "test.docx"))) + tasks.append(markitdown.convert(os.path.join(TEST_FILES_DIR, "test.xlsx"))) + tasks.append(markitdown.convert(os.path.join(TEST_FILES_DIR, "test.pptx"))) # Run all tasks concurrently results = await asyncio.gather(*tasks)