From 843376bb1b718b159dc1e3ec7bd8088011edc401 Mon Sep 17 00:00:00 2001 From: Stefano Fiorucci Date: Wed, 10 Apr 2024 09:02:08 +0200 Subject: [PATCH] forward declaration of AnalyzeResult (#7523) --- haystack/components/converters/azure.py | 4 ++-- ...AnalyzeResult-forward-declaration-5ed1bd9b6dc62c6f.yaml | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/AnalyzeResult-forward-declaration-5ed1bd9b6dc62c6f.yaml diff --git a/haystack/components/converters/azure.py b/haystack/components/converters/azure.py index 0907d053c..60b41fd5b 100644 --- a/haystack/components/converters/azure.py +++ b/haystack/components/converters/azure.py @@ -185,7 +185,7 @@ class AzureOCRDocumentConverter: docs = [*tables, text] return docs - def _convert_tables(self, result: AnalyzeResult, meta: Optional[Dict[str, Any]]) -> List[Document]: + def _convert_tables(self, result: "AnalyzeResult", meta: Optional[Dict[str, Any]]) -> List[Document]: """ Converts the tables extracted by Azure's Document Intelligence service into Haystack Documents. :param result: The AnalyzeResult Azure object @@ -294,7 +294,7 @@ class AzureOCRDocumentConverter: return converted_tables - def _convert_to_natural_text(self, result: AnalyzeResult, meta: Optional[Dict[str, Any]]) -> Document: + def _convert_to_natural_text(self, result: "AnalyzeResult", meta: Optional[Dict[str, Any]]) -> Document: """ This converts the `AnalyzeResult` object into a single Document. We add "\f" separators between to differentiate between the text on separate pages. This is the expected format for the PreProcessor. diff --git a/releasenotes/notes/AnalyzeResult-forward-declaration-5ed1bd9b6dc62c6f.yaml b/releasenotes/notes/AnalyzeResult-forward-declaration-5ed1bd9b6dc62c6f.yaml new file mode 100644 index 000000000..15986221c --- /dev/null +++ b/releasenotes/notes/AnalyzeResult-forward-declaration-5ed1bd9b6dc62c6f.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Forward declaration of `AnalyzeResult` type in `AzureOCRDocumentConverter`. + + `AnalyzeResult` is already imported in a lazy import block. + The forward declaration avoids issues when `azure-ai-formrecognizer>=3.2.0b2` is not installed.