Problem
After updating the version, the interface of some function has changed. My static type checker did not pick it up resulting in unexpected failures.
Solution suggestion
Adding some basic type annotations would have caught this issue upfront.
Example:
from io import BytesIO
from typing import Literal
def get_xml_from_pdf(
pdf_file: str | bytes | BytesIO,
check_xsd: bool = True,
check_schematron: bool = True,
filenames: list[str] = []
) -> tuple[str | Literal[False], bytes | Literal[False]]:
...
or compatible with python 3.7+
from io import BytesIO
from typing import List, Tuple, Union
from typing_extensions import Literal # for Python 3.7
def get_xml_from_pdf(
pdf_file: Union[str, bytes, BytesIO],
check_xsd: bool = True,
check_schematron: bool = True,
filenames: List[str] = None,
) -> Tuple[Union[str, Literal[False]], Union[bytes, Literal[False]]]:
...
Problem
After updating the version, the interface of some function has changed. My static type checker did not pick it up resulting in unexpected failures.
Solution suggestion
Adding some basic type annotations would have caught this issue upfront.
Example:
or compatible with python 3.7+