From b10514fc48d5dfd4ce8ff8496890a7be1b1f1e91 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 20 Sep 2024 07:58:35 +0200 Subject: [PATCH] Move function to bottom for type annotations --- pypdf/generic/_base.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pypdf/generic/_base.py b/pypdf/generic/_base.py index 4eb059e75..e05e00b39 100644 --- a/pypdf/generic/_base.py +++ b/pypdf/generic/_base.py @@ -220,16 +220,6 @@ def __repr__(self) -> str: return "NullObject" -def is_null_or_none(x: Any) -> TypeGuard[None|NullObject|IndirectObject]: - """ - Returns: - True if x is None or NullObject. - """ - return x is None or ( - isinstance(x, PdfObject) and isinstance(x.get_object(), NullObject) - ) - - class BooleanObject(PdfObject): def __init__(self, value: Any) -> None: self.value = value @@ -859,3 +849,13 @@ def encode_pdfdocencoding(unicode_string: str) -> bytes: -1, "does not exist in translation table", ) + + +def is_null_or_none(x: Any) -> TypeGuard[Union[None, NullObject, IndirectObject]]: + """ + Returns: + True if x is None or NullObject. + """ + return x is None or ( + isinstance(x, PdfObject) and isinstance(x.get_object(), NullObject) + )