Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions stubs/fpdf2/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@
fpdf.FPDF.set_creation_date
fpdf.fpdf.FPDF.set_creation_date

# Dynamically added, deprecated arguments.
fpdf.FPDF.add_font
fpdf.FPDF.output
fpdf.fpdf.FPDF.add_font
fpdf.fpdf.FPDF.output

# fonttools shims since we can't import it
fpdf._fonttools_shims

# Deprecated attributes supported via __getattr__ and __setattr__.
fpdf.deprecation.WarnOnDeprecatedModuleAttributes.FPDF_CACHE_DIR
fpdf.deprecation.WarnOnDeprecatedModuleAttributes.FPDF_CACHE_MODE

# Only present if harfbuzz is installed
fpdf.fonts.HarfBuzzFont

Expand Down
2 changes: 1 addition & 1 deletion stubs/fpdf2/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "2.8.4"
version = "2.8.5"
upstream_repository = "https://github.com/PyFPDF/fpdf2"
requires = ["Pillow>=10.3.0"]

Expand Down
16 changes: 12 additions & 4 deletions stubs/fpdf2/fpdf/_fonttools_shims.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# from fontTools.misc.loggingTools
from _typeshed import Incomplete
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping
from logging import Logger
from typing import Any, Protocol
from typing import Protocol
from typing_extensions import TypeAlias

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

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

# fonttools.ttLib.TTFont
_TTFont: TypeAlias = Any # noqa: Y047
# from fonttools.ttLib.TTFont
_TTFont: TypeAlias = Incomplete # noqa: Y047

# from fonttools.ttLib.tables.otTables
CompositeMode: TypeAlias = Incomplete
Paint: TypeAlias = Incomplete
PaintFormat: TypeAlias = Incomplete

# from fontTools.misc.loggingTools

Expand Down Expand Up @@ -53,3 +58,6 @@ class BasePen(DecomposingPen):
def lineTo(self, pt: tuple[float, float]) -> None: ...
def curveTo(self, *points: tuple[float, float]) -> None: ...
def qCurveTo(self, *points: tuple[float, float]) -> None: ...

# from fontTools.varLib.varStore
VarStoreInstancer: TypeAlias = Incomplete
25 changes: 19 additions & 6 deletions stubs/fpdf2/fpdf/annotations.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from _typeshed import Incomplete
from datetime import datetime
from typing import NamedTuple

from .actions import Action
from .enums import AnnotationFlag, AnnotationName, FileAttachmentAnnotationName
from .syntax import Destination, Name, PDFContentStream, PDFObject
from .enums import AnnotationFlag, AnnotationName, AssociatedFileRelationship, FileAttachmentAnnotationName
from .syntax import Destination, Name, PDFContentStream, PDFObject, PDFString

DEFAULT_ANNOT_FLAGS: tuple[AnnotationFlag, ...]

Expand Down Expand Up @@ -87,6 +86,8 @@ class PDFEmbeddedFile(PDFContentStream):
desc: str = "",
creation_date: datetime | None = None,
modification_date: datetime | None = None,
mime_type: str | None = None,
af_relationship: AssociatedFileRelationship | None = None,
compress: bool = False,
checksum: bool = False,
) -> None: ...
Expand All @@ -95,8 +96,20 @@ class PDFEmbeddedFile(PDFContentStream):
def basename(self) -> str: ...
def file_spec(self) -> FileSpec: ...

class FileSpec(NamedTuple):
class FileSpec(PDFObject):
type: Name
f: PDFString
uf: PDFString
embedded_file: PDFEmbeddedFile
desc: PDFString # Only exists if provided to __init__
a_f_relationship: Name # Only exists if provided to __init__
basename: str
desc: str
def serialize(self) -> str: ...
def __init__(
self,
embedded_file: PDFEmbeddedFile,
basename: str,
desc: str | None = None,
af_relationship: AssociatedFileRelationship | None = None,
) -> None: ...
@property
def e_f(self) -> str: ...
Empty file.
Empty file.
26 changes: 22 additions & 4 deletions stubs/fpdf2/fpdf/deprecation.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
from _typeshed import Unused
from collections.abc import Callable, Iterable
from types import ModuleType
from typing import Any, NoReturn
from typing import Any, NoReturn, TypeVar
from typing_extensions import deprecated

def support_deprecated_txt_arg(fn): ...
_R = TypeVar("_R")
_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])

# This changes the signature by replacing a `txt` parameter with `text`.
def support_deprecated_txt_arg(fn: Callable[..., _R]) -> Callable[..., _R]: ...
def deprecated_parameter(parameters: Iterable[tuple[str, str]]) -> Callable[[_CallableT], _CallableT]: ...

class WarnOnDeprecatedModuleAttributes(ModuleType):
def __call__(self) -> NoReturn: ...
def __getattr__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
@property
@deprecated("deprecated in favour of FPDF(font_cache_dir=...)")
def FPDF_CACHE_DIR(self) -> None: ...
@FPDF_CACHE_DIR.setter
@deprecated("deprecated in favour of FPDF(font_cache_dir=...)")
def FPDF_CACHE_DIR(self, value: Unused, /) -> None: ...
@property
@deprecated("deprecated in favour of FPDF(font_cache_dir=...)")
def FPDF_CACHE_MODE(self) -> None: ...
@FPDF_CACHE_MODE.setter
@deprecated("deprecated in favour of FPDF(font_cache_dir=...)")
def FPDF_CACHE_MODE(self, value: Unused, /) -> None: ...

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