Skip to content

Commit 1c9eacd

Browse files
authored
MAINT: Use mypy recursive type support (#2898)
Recursive types like the following are now supported by mypy: OutlineType = List[Union[Destination, "OutlineType"]] However, this recursuve type does not work with the Sphinx documentation generator; update comment to reflect this.
1 parent 9ffa6c6 commit 1c9eacd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pypdf/types.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
from .generic._outline import OutlineItem
1515

1616
BorderArrayType: TypeAlias = List[Union[NameObject, NumberObject, ArrayObject]]
17+
1718
OutlineItemType: TypeAlias = Union[OutlineItem, Destination]
19+
1820
FitType: TypeAlias = Literal[
1921
"/XYZ", "/Fit", "/FitH", "/FitV", "/FitR", "/FitB", "/FitBH", "/FitBV"
2022
]
21-
# Those go with the FitType: They specify values for the fit
23+
# These go with the FitType, they specify values for the fit
2224
ZoomArgType: TypeAlias = Union[NumberObject, NullObject, float]
2325
ZoomArgsType: TypeAlias = List[ZoomArgType]
2426

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

@@ -37,6 +38,7 @@
3738
"/TwoPageLeft",
3839
"/TwoPageRight",
3940
]
41+
4042
PagemodeType: TypeAlias = Literal[
4143
"/UseNone",
4244
"/UseOutlines",
@@ -45,6 +47,7 @@
4547
"/UseOC",
4648
"/UseAttachments",
4749
]
50+
4851
AnnotationSubtype: TypeAlias = Literal[
4952
"/Text",
5053
"/Link",

0 commit comments

Comments
 (0)