Skip to content

Commit f1795fe

Browse files
committed
Update fpdf2 to 2.8.5
Closes: python#14944
1 parent 947ec49 commit f1795fe

19 files changed

+1310
-293
lines changed

stubs/fpdf2/@tests/stubtest_allowlist.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22
fpdf.FPDF.set_creation_date
33
fpdf.fpdf.FPDF.set_creation_date
44

5+
# Dynamically added, deprecated arguments.
6+
fpdf.FPDF.add_font
7+
fpdf.FPDF.output
8+
fpdf.fpdf.FPDF.add_font
9+
fpdf.fpdf.FPDF.output
10+
511
# fonttools shims since we can't import it
612
fpdf._fonttools_shims
713

14+
# Deprecated attributes supported via __getattr__ and __setattr__.
15+
fpdf.deprecation.WarnOnDeprecatedModuleAttributes.FPDF_CACHE_DIR
16+
fpdf.deprecation.WarnOnDeprecatedModuleAttributes.FPDF_CACHE_MODE
17+
818
# Only present if harfbuzz is installed
919
fpdf.fonts.HarfBuzzFont
1020

stubs/fpdf2/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "2.8.4"
1+
version = "2.8.5"
22
upstream_repository = "https://github.com/PyFPDF/fpdf2"
33
requires = ["Pillow>=10.3.0"]
44

stubs/fpdf2/fpdf/_fonttools_shims.pyi

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# from fontTools.misc.loggingTools
1+
from _typeshed import Incomplete
22
from abc import ABCMeta, abstractmethod
33
from collections.abc import Mapping
44
from logging import Logger
5-
from typing import Any, Protocol
5+
from typing import Protocol
66
from typing_extensions import TypeAlias
77

88
# from fonttools.ttLib.ttGlyphSet
@@ -13,8 +13,13 @@ class _TTGlyph(Protocol):
1313

1414
_TTGlyphSet: TypeAlias = Mapping[str, _TTGlyph] # Simplified for our needs
1515

16-
# fonttools.ttLib.TTFont
17-
_TTFont: TypeAlias = Any # noqa: Y047
16+
# from fonttools.ttLib.TTFont
17+
_TTFont: TypeAlias = Incomplete # noqa: Y047
18+
19+
# from fonttools.ttLib.tables.otTables
20+
CompositeMode: TypeAlias = Incomplete
21+
Paint: TypeAlias = Incomplete
22+
PaintFormat: TypeAlias = Incomplete
1823

1924
# from fontTools.misc.loggingTools
2025

@@ -53,3 +58,6 @@ class BasePen(DecomposingPen):
5358
def lineTo(self, pt: tuple[float, float]) -> None: ...
5459
def curveTo(self, *points: tuple[float, float]) -> None: ...
5560
def qCurveTo(self, *points: tuple[float, float]) -> None: ...
61+
62+
# from fontTools.varLib.varStore
63+
VarStoreInstancer: TypeAlias = Incomplete

stubs/fpdf2/fpdf/annotations.pyi

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from _typeshed import Incomplete
22
from datetime import datetime
3-
from typing import NamedTuple
43

54
from .actions import Action
6-
from .enums import AnnotationFlag, AnnotationName, FileAttachmentAnnotationName
7-
from .syntax import Destination, Name, PDFContentStream, PDFObject
5+
from .enums import AnnotationFlag, AnnotationName, AssociatedFileRelationship, FileAttachmentAnnotationName
6+
from .syntax import Destination, Name, PDFContentStream, PDFObject, PDFString
87

98
DEFAULT_ANNOT_FLAGS: tuple[AnnotationFlag, ...]
109

@@ -87,6 +86,8 @@ class PDFEmbeddedFile(PDFContentStream):
8786
desc: str = "",
8887
creation_date: datetime | None = None,
8988
modification_date: datetime | None = None,
89+
mime_type: str | None = None,
90+
af_relationship: AssociatedFileRelationship | None = None,
9091
compress: bool = False,
9192
checksum: bool = False,
9293
) -> None: ...
@@ -95,8 +96,20 @@ class PDFEmbeddedFile(PDFContentStream):
9596
def basename(self) -> str: ...
9697
def file_spec(self) -> FileSpec: ...
9798

98-
class FileSpec(NamedTuple):
99+
class FileSpec(PDFObject):
100+
type: Name
101+
f: PDFString
102+
uf: PDFString
99103
embedded_file: PDFEmbeddedFile
104+
desc: PDFString # Only exists if provided to __init__
105+
a_f_relationship: Name # Only exists if provided to __init__
100106
basename: str
101-
desc: str
102-
def serialize(self) -> str: ...
107+
def __init__(
108+
self,
109+
embedded_file: PDFEmbeddedFile,
110+
basename: str,
111+
desc: str | None = None,
112+
af_relationship: AssociatedFileRelationship | None = None,
113+
) -> None: ...
114+
@property
115+
def e_f(self) -> str: ...

stubs/fpdf2/fpdf/data/__init__.pyi

Whitespace-only changes.

stubs/fpdf2/fpdf/data/color_profiles/__init__.pyi

Whitespace-only changes.

stubs/fpdf2/fpdf/deprecation.pyi

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
from _typeshed import Unused
2+
from collections.abc import Callable, Iterable
13
from types import ModuleType
2-
from typing import Any, NoReturn
4+
from typing import Any, NoReturn, TypeVar
5+
from typing_extensions import deprecated
36

4-
def support_deprecated_txt_arg(fn): ...
7+
_R = TypeVar("_R")
8+
_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
9+
10+
# This changes the signature by replacing a `txt` parameter with `text`.
11+
def support_deprecated_txt_arg(fn: Callable[..., _R]) -> Callable[..., _R]: ...
12+
def deprecated_parameter(parameters: Iterable[tuple[str, str]]) -> Callable[[_CallableT], _CallableT]: ...
513

614
class WarnOnDeprecatedModuleAttributes(ModuleType):
715
def __call__(self) -> NoReturn: ...
8-
def __getattr__(self, name: str) -> Any: ...
9-
def __setattr__(self, name: str, value: Any) -> None: ...
16+
@property
17+
@deprecated("deprecated in favour of FPDF(font_cache_dir=...)")
18+
def FPDF_CACHE_DIR(self) -> None: ...
19+
@FPDF_CACHE_DIR.setter
20+
@deprecated("deprecated in favour of FPDF(font_cache_dir=...)")
21+
def FPDF_CACHE_DIR(self, value: Unused, /) -> None: ...
22+
@property
23+
@deprecated("deprecated in favour of FPDF(font_cache_dir=...)")
24+
def FPDF_CACHE_MODE(self) -> None: ...
25+
@FPDF_CACHE_MODE.setter
26+
@deprecated("deprecated in favour of FPDF(font_cache_dir=...)")
27+
def FPDF_CACHE_MODE(self, value: Unused, /) -> None: ...
1028

1129
def get_stack_level() -> int: ...

0 commit comments

Comments
 (0)