From e4ae06c7ad480adb6e546da92a90fd0d586de452 Mon Sep 17 00:00:00 2001 From: Klaijan Sinteppadon Date: Tue, 3 Oct 2023 20:15:45 -0400 Subject: [PATCH] linting --- test_unstructured/partition/xlsx/test_xlsx.py | 2 +- unstructured/partition/xlsx.py | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/test_unstructured/partition/xlsx/test_xlsx.py b/test_unstructured/partition/xlsx/test_xlsx.py index 6525ba84a4..b3e564bc9d 100644 --- a/test_unstructured/partition/xlsx/test_xlsx.py +++ b/test_unstructured/partition/xlsx/test_xlsx.py @@ -228,4 +228,4 @@ def test_partition_xlsx_metadata_language_from_filename(filename="example-docs/s def test_partition_xlsx_subtables(filename="example-docs/vodafone.xlsx"): elements = partition_xlsx(filename) assert sum(isinstance(element, Table) for element in elements) == 3 - assert len(elements) == 6 \ No newline at end of file + assert len(elements) == 6 diff --git a/unstructured/partition/xlsx.py b/unstructured/partition/xlsx.py index a23bbfc574..b136eca98d 100644 --- a/unstructured/partition/xlsx.py +++ b/unstructured/partition/xlsx.py @@ -113,17 +113,20 @@ def partition_xlsx( single_non_empty_rows, single_non_empty_row_contents = _single_non_empty_rows( subtable, ) - front_non_consecutive, last_non_consecutive = _find_first_and_last_non_consecutive_row( + ( + front_non_consecutive, + last_non_consecutive, + ) = _find_first_and_last_non_consecutive_row( single_non_empty_rows, ) metadata = _get_metadata( - include_metadata, - sheet_name, - page_number, - metadata_filename or filename, - metadata_last_modified or last_modification_date, - ) + include_metadata, + sheet_name, + page_number, + metadata_filename or filename, + metadata_last_modified or last_modification_date, + ) # NOTE(klaijan) - need to explicitly define the condition to avoid the case of 0 if front_non_consecutive is not None and last_non_consecutive is not None: @@ -372,9 +375,9 @@ def _check_content_element_type(text: str) -> Element: def _get_metadata( include_metadata: bool = True, - sheet_name: str = "", - page_number: int = -1, - filename: str = "", + sheet_name: Optional[str] = None, + page_number: Optional[int] = -1, + filename: Optional[str] = None, last_modification_date: Union[str, None] = None, ) -> ElementMetadata: """Returns metadata depending on `include_metadata` flag""" @@ -387,4 +390,4 @@ def _get_metadata( ) else: metadata = ElementMetadata() - return metadata \ No newline at end of file + return metadata