Skip to content

Commit

Permalink
Remove PageObject protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Jan 4, 2023
1 parent 6541677 commit f562ea5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pypdf/_page.py
Expand Up @@ -46,7 +46,7 @@
)

from ._cmap import build_char_map, unknown_char_map
from ._protocols import PageObjectProtocol, PdfReaderProtocol
from ._protocols import PdfReaderProtocol
from ._utils import (
CompressedTransformationMatrix,
File,
Expand Down Expand Up @@ -331,7 +331,7 @@ def apply_on(
return list(pt1) if isinstance(pt, list) else pt1


class PageObject(DictionaryObject, PageObjectProtocol):
class PageObject(DictionaryObject):
"""
PageObject represents a single page within a PDF file.
Expand Down
4 changes: 0 additions & 4 deletions pypdf/_protocols.py
Expand Up @@ -64,7 +64,3 @@ def get_object(self, indirect_reference: Any) -> Optional[PdfObjectProtocol]:

def write(self, stream: Union[Path, StrByteType]) -> Tuple[bool, IO]:
...


class PageObjectProtocol(Protocol): # pragma: no cover
indirect_reference: Any
12 changes: 4 additions & 8 deletions pypdf/generic/_base.py
Expand Up @@ -33,11 +33,7 @@
from typing import Any, Callable, List, Optional, Tuple, Union, cast

from .._codecs import _pdfdoc_encoding_rev
from .._protocols import (
PageObjectProtocol,
PdfObjectProtocol,
PdfWriterProtocol,
)
from .._protocols import PdfObjectProtocol, PdfWriterProtocol
from .._utils import (
StreamType,
b_,
Expand Down Expand Up @@ -250,14 +246,14 @@ def clone(
pdf_dest._id_translated[id(self.pdf)] = {}

if not force_duplicate and self.idnum in pdf_dest._id_translated[id(self.pdf)]:
dup: PageObjectProtocol = pdf_dest.get_object(pdf_dest._id_translated[id(self.pdf)][self.idnum]) # type: ignore
dup = pdf_dest.get_object(pdf_dest._id_translated[id(self.pdf)][self.idnum])
else:
obj = self.get_object()
assert obj is not None
dup = obj.clone(pdf_dest, force_duplicate, ignore_fields)
assert dup is not None
assert dup.indirect_reference is not None
return dup.indirect_reference
assert dup.indirect_reference is not None # type: ignore
return dup.indirect_reference # type: ignore

@property
def indirect_reference(self) -> "IndirectObject": # type: ignore[override]
Expand Down

0 comments on commit f562ea5

Please sign in to comment.