Skip to content

Commit

Permalink
refactor type hints to avoid mutable default args
Browse files Browse the repository at this point in the history
  • Loading branch information
Coniferish committed Nov 8, 2023
1 parent eaddd67 commit 6516806
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion unstructured/partition/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def prepare_languages_for_tesseract(languages: Optional[List[str]] = ["eng"]):
return "+".join(converted_languages)


def check_user_defined_languages(languages, ocr_languages):
def check_user_defined_languages(languages: Optional[List[str]], ocr_languages: Optional[str]):
# The auto `partition` function uses `None` as a default because the default for
# `partition_pdf` and `partition_img` conflict with the other partitioners that use ["auto"]
if languages is None:
Expand Down
10 changes: 5 additions & 5 deletions unstructured/partition/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def partition_pdf(
strategy: str = "auto",
infer_table_structure: bool = False,
ocr_languages: Optional[str] = None, # changing to optional for deprecation
languages: List[str] = ["eng"],
languages: Optional[List[str]] = None,
include_metadata: bool = True, # used by decorator
metadata_filename: Optional[str] = None, # used by decorator
metadata_last_modified: Optional[str] = None,
Expand Down Expand Up @@ -183,7 +183,7 @@ def extractable_elements(
filename: str = "",
file: Optional[Union[bytes, IO[bytes]]] = None,
include_page_breaks: bool = False,
languages: List[str] = None,
languages: Optional[List[str]] = None,
metadata_last_modified: Optional[str] = None,
**kwargs: Any,
):
Expand Down Expand Up @@ -219,7 +219,7 @@ def partition_pdf_or_image(
strategy: str = "auto",
infer_table_structure: bool = False,
ocr_languages: Optional[str] = None,
languages: Optional[List[str]] = ["eng"],
languages: Optional[List[str]] = None,
metadata_last_modified: Optional[str] = None,
extract_images_in_pdf: bool = False,
image_output_dir_path: Optional[str] = None,
Expand Down Expand Up @@ -463,7 +463,7 @@ def _partition_pdf_with_pdfminer(
file: Optional[IO[bytes]] = None,
include_page_breaks: bool = False,
metadata_last_modified: Optional[str] = None,
languages: List[str] = None,
languages: Optional[List[str]] = None,
**kwargs: Any,
) -> List[Element]:
"""Partitions a PDF using PDFMiner instead of using a layoutmodel. Used for faster
Expand Down Expand Up @@ -524,7 +524,7 @@ def _process_pdfminer_pages(
fp: BinaryIO,
filename: str = "",
include_page_breaks: bool = False,
languages: List[str] = None,
languages: Optional[List[str]] = None,
metadata_last_modified: Optional[str] = None,
sort_mode: str = SORT_MODE_XY_CUT,
**kwargs,
Expand Down

0 comments on commit 6516806

Please sign in to comment.