Skip to content

Commit

Permalink
A1
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal committed Jul 1, 2023
1 parent 8340387 commit 7d18a9b
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 81 deletions.
30 changes: 15 additions & 15 deletions fpdf/annotations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hashlib
from datetime import datetime
from typing import NamedTuple, Tuple, Union
from typing import NamedTuple, Tuple, Union, Optional, Dict

from .actions import Action
from .enums import AnnotationFlag, AnnotationName, FileAttachmentAnnotationName
Expand Down Expand Up @@ -31,18 +31,18 @@ def __init__(
width: int,
height: int,
flags: Tuple[AnnotationFlag] = DEFAULT_ANNOT_FLAGS,
contents: str = None,
dest: Destination = None,
action: Action = None,
color: tuple = None,
modification_time: datetime = None,
title: str = None,
quad_points: tuple = None,
contents: Optional[str] = None,
dest: Optional[Destination] = None,
action: Optional[Action] = None,
color: Optional[tuple] = None,
modification_time: Optional[datetime] = None,
title: Optional[str] = None,
quad_points: Optional[tuple] = None,
border_width: int = 0, # PDF readers support: displayed by Acrobat but not Sumatra
name: Union[AnnotationName, FileAttachmentAnnotationName] = None,
ink_list: Tuple[int] = (), # for ink annotations
file_spec: str = None,
field_type: str = None,
name: Optional[Union[AnnotationName, FileAttachmentAnnotationName]] = None,
ink_list: Optional[Tuple[int]] = None, # for ink annotations
file_spec: Optional[str] = None,
field_type: Optional[str] = None,
value=None,
):
self.type = Name("Annot")
Expand Down Expand Up @@ -123,14 +123,14 @@ def __init__(
basename: str,
contents: bytes,
desc: str = "",
creation_date: datetime = None,
modification_date: datetime = None,
creation_date: Optional[datetime] = None,
modification_date: Optional[datetime] = None,
compress: bool = False,
checksum: bool = False,
):
super().__init__(contents=contents, compress=compress)
self.type = Name("EmbeddedFile")
params = {"/Size": len(contents)}
params: Dict[str, Union[int, str]] = {"/Size": len(contents)}
if creation_date:
params["/CreationDate"] = PDFDate(creation_date, with_tz=True).serialize()
if modification_date:
Expand Down
8 changes: 4 additions & 4 deletions fpdf/drawing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy, decimal, math, re
from collections import OrderedDict
from contextlib import contextmanager
from typing import Optional, NamedTuple, Union
from typing import Optional, NamedTuple, Union, Dict

from .enums import (
BlendMode,
Expand All @@ -15,7 +15,7 @@
from .syntax import Name, Raw
from .util import escape_parens

__pdoc__ = {"force_nodocument": False}
__pdoc__: Dict[str, Union[bool, str]] = {"force_nodocument": False}


def force_nodocument(item):
Expand Down Expand Up @@ -605,7 +605,7 @@ def __mul__(self, other):

return NotImplemented

__rmul__ = __mul__
__rmul__ = __mul__ # type: ignore[misc]

@force_document
def __truediv__(self, other):
Expand Down Expand Up @@ -983,7 +983,7 @@ def __mul__(self, other):
return NotImplemented

# scalar multiplication is commutative
__rmul__ = __mul__
__rmul__ = __mul__ # type: ignore[misc]

@force_document
def __matmul__(self, other):
Expand Down
Loading

0 comments on commit 7d18a9b

Please sign in to comment.