-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Update fpdf2 stubs to 2.6.1 #9546
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
Changes from 1 commit
eaaab5b
2a98699
1e0a195
2bbf381
ccb8268
ce0bf38
73a5a81
bebe274
95db1e4
4a81e0e
c35a6df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
version = "2.6.0" | ||
requires = ["types-Pillow"] | ||
version = "2.6.1" | ||
requires = ["cryptography", "types-Pillow"] | ||
|
||
[tool.stubtest] | ||
ignore_missing_stub = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from _typeshed import Incomplete, SupportsLenAndGetItem | ||
from collections.abc import Generator, Iterable | ||
from typing import ClassVar, Protocol, TypeVar | ||
from typing_extensions import TypeAlias | ||
|
||
from .enums import EncryptionMethod | ||
from .fpdf import FPDF | ||
from .syntax import Name, PDFObject | ||
|
||
_Key: TypeAlias = SupportsLenAndGetItem[int] | ||
_T_co = TypeVar("_T_co", covariant=True) | ||
|
||
import_error: ImportError | None | ||
|
||
class _SupportsGetItem(Protocol[_T_co]): | ||
def __getitem__(self, __k: int) -> _T_co: ... | ||
|
||
class ARC4: | ||
MOD: ClassVar[int] | ||
def KSA(self, key: _Key) -> list[int]: ... | ||
def PRGA(self, S: _SupportsGetItem[int]) -> Generator[int, None, None]: ... | ||
def encrypt(self, key: _Key, text: Iterable[int]) -> list[int]: ... | ||
|
||
class CryptFilter: | ||
def __init__(self, mode, length) -> None: ... | ||
srittau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def serialize(self) -> str: ... | ||
|
||
class EncryptionDictionary(PDFObject): | ||
filter: Name | ||
length: int | ||
r: int | ||
o: str | ||
u: str | ||
v: int | ||
p: int | ||
encrypt_metadata: str # not always defined | ||
c_f: str # not always defined | ||
stm_f: Name | ||
str_f: Name | ||
def __init__(self, security_handler: StandardSecurityHandler) -> None: ... | ||
|
||
class StandardSecurityHandler: | ||
DEFAULT_PADDING: ClassVar[bytes] | ||
fpdf: FPDF | ||
access_permission: int | ||
owner_permission: str | ||
srittau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
user_password: str | ||
encryption_method: EncryptionMethod | None | ||
cf: CryptFilter | None | ||
key_length: int | ||
v: int | ||
r: int | ||
srittau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# The following fields are only defined after a call to generate_passwords(). | ||
file_id: Incomplete | ||
info_id: Incomplete | ||
o: str | ||
k: str | ||
u: str | ||
|
||
def __init__( | ||
self, | ||
fpdf: FPDF, | ||
owner_password: str, | ||
user_password: str | None = None, | ||
permission: Incomplete | None = None, | ||
encryption_method: EncryptionMethod | None = None, | ||
encrypt_metadata: bool = False, | ||
) -> None: ... | ||
def generate_passwords(self, file_id) -> None: ... | ||
def get_encryption_obj(self) -> EncryptionDictionary: ... | ||
def encrypt(self, text: str | bytes | bytearray, obj_id) -> bytes: ... | ||
def encrypt_string(self, string, obj_id): ... | ||
def encrypt_stream(self, stream, obj_id): ... | ||
def is_aes_algorithm(self) -> bool: ... | ||
def encrypt_bytes(self, data, obj_id) -> list[int]: ... | ||
def encrypt_AES_cryptography(self, key, data): ... | ||
def get_initialization_vector(self, size: int) -> bytearray: ... | ||
def padded_password(self, password: str) -> bytearray: ... | ||
def generate_owner_password(self) -> str: ... | ||
def generate_user_password(self) -> str: ... | ||
def generate_encryption_key(self) -> bytes: ... | ||
|
||
def md5(data: bytes) -> bytes: ... | ||
def int32(n: int) -> int: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ from _typeshed import Incomplete, StrPath | |
from collections.abc import Callable, Iterable, Sequence | ||
from contextlib import _GeneratorContextManager | ||
from io import BytesIO | ||
from re import Pattern | ||
from typing import Any, ClassVar, NamedTuple, overload | ||
from typing_extensions import Literal, TypeAlias | ||
|
||
|
@@ -12,10 +13,12 @@ from PIL import Image | |
from .annotations import AnnotationDict, PDFEmbeddedFile | ||
from .drawing import DrawingContext, PaintedPath | ||
from .enums import ( | ||
AccessPermission, | ||
Align, | ||
AnnotationFlag, | ||
AnnotationName, | ||
Corner, | ||
EncryptionMethod, | ||
FileAttachmentAnnotationName, | ||
PageLayout, | ||
PathPaintRule, | ||
|
@@ -72,6 +75,8 @@ class FPDF: | |
MARKDOWN_BOLD_MARKER: ClassVar[str] | ||
MARKDOWN_ITALICS_MARKER: ClassVar[str] | ||
MARKDOWN_UNDERLINE_MARKER: ClassVar[str] | ||
MARKDOWN_LINK_REGEX: ClassVar[Pattern[str]] | ||
MARKDOWN_LINK_COLOR: ClassVar[Incomplete | None] | ||
|
||
HTML2FPDF_CLASS: ClassVar[type[HTML2FPDF]] | ||
|
||
|
@@ -144,6 +149,15 @@ class FPDF: | |
format: _Format | tuple[float, float] = ..., | ||
font_cache_dir: Literal["DEPRECATED"] = ..., | ||
) -> None: ... | ||
# The following definition crashes stubtest. | ||
# def set_encryption( | ||
# self, | ||
# owner_password: str, | ||
# user_password: str | None = None, | ||
# encryption_method: EncryptionMethod | str = ..., | ||
# permissions: AccessPermission = ..., | ||
# encrypt_metadata: bool = False, | ||
# ) -> None: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs further investigation for which I didn't have time yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just ran this against stubtest HEAD and this seems to fix it. I'll update the comment. |
||
# args and kwargs are passed to HTML2FPDF_CLASS constructor. | ||
def write_html(self, text: str, *args: Any, **kwargs: Any) -> None: ... | ||
@property | ||
|
@@ -288,8 +302,12 @@ class FPDF: | |
def set_font_size(self, size: float) -> None: ... | ||
def set_char_spacing(self, spacing: float) -> None: ... | ||
def set_stretching(self, stretching: float) -> None: ... | ||
def add_link(self) -> int: ... | ||
def set_link(self, link, y: int = ..., x: int = ..., page: int = ..., zoom: float | Literal["null"] = ...) -> None: ... | ||
def add_link( | ||
self, y: float = 0, x: float = 0, page: int = -1, zoom: float | Literal["null"] = "null" # noqa: Y020 | ||
AlexWaygood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) -> int: ... | ||
def set_link( | ||
self, link, y: float = 0, x: float = 0, page: int = -1, zoom: float | Literal["null"] = "null" # noqa: Y020 | ||
) -> None: ... | ||
def link( | ||
self, x: float, y: float, w: float, h: float, link: str | int, alt_text: str | None = ..., border_width: int = ... | ||
) -> AnnotationDict: ... | ||
|
@@ -364,6 +382,9 @@ class FPDF: | |
def text(self, x: float, y: float, txt: str = ...) -> None: ... | ||
def rotate(self, angle: float, x: float | None = ..., y: float | None = ...) -> None: ... | ||
def rotation(self, angle: float, x: float | None = ..., y: float | None = ...) -> _GeneratorContextManager[None]: ... | ||
def skew( | ||
self, ax: float = 0, ay: float = 0, x: float | None = None, y: float | None = None | ||
) -> _GeneratorContextManager[None]: ... | ||
def local_context( | ||
self, | ||
font_family: Incomplete | None = ..., | ||
|
@@ -415,14 +436,15 @@ class FPDF: | |
def image( | ||
self, | ||
name: str | Image.Image | BytesIO | StrPath, | ||
x: float | None = ..., | ||
y: float | None = ..., | ||
w: float = ..., | ||
h: float = ..., | ||
type: str = ..., | ||
link: str = ..., | ||
title: str | None = ..., | ||
alt_text: str | None = ..., | ||
x: float | Align | None = None, | ||
y: float | None = None, | ||
w: float = 0, | ||
h: float = 0, | ||
type: str = "", | ||
link: str = "", | ||
srittau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
title: str | None = None, | ||
alt_text: str | None = None, | ||
dims: tuple[float, float] | None = None, | ||
) -> _Image: ... | ||
def ln(self, h: float | None = ...) -> None: ... | ||
def get_x(self) -> float: ... | ||
|
@@ -477,4 +499,4 @@ class FPDF: | |
level5: TitleStyle | None = ..., | ||
level6: TitleStyle | None = ..., | ||
) -> None: ... | ||
def start_section(self, name: str, level: int = ...) -> None: ... | ||
def start_section(self, name: str, level: int = 0, strict: bool = True) -> None: ... |
Uh oh!
There was an error while loading. Please reload this page.