From 5c3c27916ec708eb94d7dfba2932b94799a6e512 Mon Sep 17 00:00:00 2001 From: j-t-1 <120829237+j-t-1@users.noreply.github.com> Date: Fri, 11 Oct 2024 08:58:22 +0100 Subject: [PATCH] MAINT: Use mypy recursive type support In mypy>=1.7 recursive type support is built-in. --- pypdf/types.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pypdf/types.py b/pypdf/types.py index e383dc7b1..eae867911 100644 --- a/pypdf/types.py +++ b/pypdf/types.py @@ -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", @@ -37,6 +35,7 @@ "/TwoPageLeft", "/TwoPageRight", ] + PagemodeType: TypeAlias = Literal[ "/UseNone", "/UseOutlines", @@ -45,6 +44,7 @@ "/UseOC", "/UseAttachments", ] + AnnotationSubtype: TypeAlias = Literal[ "/Text", "/Link",