feat: Use forward reference for AnalyzeResult #6030
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
The static method
_convert_azure_result_to_document
in theAzureOCRDocumentConverter
class was causing aNameError
due to the direct use ofAnalyzeResult
from theazure.ai.formrecognizer
package, which is an optional dependency. This PR addresses this issue to ensure smooth functionality even when the optional package isn't installed.AnalyzeResult
Type Error in `AzureOCRDocumentConverter #6028What
The fix involves using a forward reference for
AnalyzeResult
in the method signature of_convert_azure_result_to_document
.How Can It Be Used
After this fix, users won't get the
NameError
as before. If they do have the package and want to utilize the full functionality, they can do so without any errors.How Did You Test It
azure.ai.formrecognizer
package installed to ensure noNameError
is thrown.azure.ai.formrecognizer
package and tested the full functionality of theAzureOCRDocumentConverter
class to ensure it works as expected.