Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Use mypy recursive type support #2898

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pypdf/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@
from .generic._outline import OutlineItem

BorderArrayType: TypeAlias = List[Union[NameObject, NumberObject, ArrayObject]]

OutlineItemType: TypeAlias = Union[OutlineItem, Destination]

FitType: TypeAlias = Literal[
"/XYZ", "/Fit", "/FitH", "/FitV", "/FitR", "/FitB", "/FitBH", "/FitBV"
]
# Those go with the FitType: They specify values for the fit
# These go with the FitType, they specify values for the fit
ZoomArgType: TypeAlias = Union[NumberObject, NullObject, float]
ZoomArgsType: TypeAlias = List[ZoomArgType]

# Recursive types like the following are not yet supported by mypy:
# OutlineType = List[Union[Destination, "OutlineType"]]
# See https://github.com/python/mypy/issues/731
# Hence use this for the moment:
OutlineType = List[Union[Destination, List[Union[Destination, List[Destination]]]]]
OutlineType = List[Union[Destination, "OutlineType"]]

LayoutType: TypeAlias = Literal[
"/NoLayout",
Expand All @@ -37,6 +35,7 @@
"/TwoPageLeft",
"/TwoPageRight",
]

PagemodeType: TypeAlias = Literal[
"/UseNone",
"/UseOutlines",
Expand All @@ -45,6 +44,7 @@
"/UseOC",
"/UseAttachments",
]

AnnotationSubtype: TypeAlias = Literal[
"/Text",
"/Link",
Expand Down
Loading