Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaijan committed Oct 4, 2023
1 parent 4bf6805 commit e4ae06c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test_unstructured/partition/xlsx/test_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
assert len(elements) == 6
25 changes: 14 additions & 11 deletions unstructured/partition/xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"""
Expand All @@ -387,4 +390,4 @@ def _get_metadata(
)
else:
metadata = ElementMetadata()
return metadata
return metadata

0 comments on commit e4ae06c

Please sign in to comment.