From 98f4ea0dfaeb3cba602f840f6786095fae82850e Mon Sep 17 00:00:00 2001 From: black-isort-bot Date: Sat, 28 Sep 2024 00:59:41 +0000 Subject: [PATCH] [skip ci]: black/isort --- PyPDFForm/patterns.py | 8 ++------ PyPDFForm/template.py | 7 ++++--- PyPDFForm/wrapper.py | 10 +++++++--- tests/test_functional.py | 8 ++------ 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/PyPDFForm/patterns.py b/PyPDFForm/patterns.py index 4b280c0c..3255a302 100644 --- a/PyPDFForm/patterns.py +++ b/PyPDFForm/patterns.py @@ -164,13 +164,9 @@ def update_annotation_name(annot: DictionaryObject, val: str) -> None: """Patterns to update the name of an annotation.""" if Parent in annot and T not in annot: - annot[NameObject(Parent)][NameObject(T)] = TextStringObject( # noqa - val - ) + annot[NameObject(Parent)][NameObject(T)] = TextStringObject(val) # noqa else: - annot[NameObject(T)] = TextStringObject( # noqa - val - ) + annot[NameObject(T)] = TextStringObject(val) # noqa def update_created_text_field_alignment(annot: DictionaryObject, val: int) -> None: diff --git a/PyPDFForm/template.py b/PyPDFForm/template.py index 44bf7d03..d1240b1d 100644 --- a/PyPDFForm/template.py +++ b/PyPDFForm/template.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- """Contains helpers for generic template related processing.""" -from io import BytesIO from functools import lru_cache +from io import BytesIO from sys import maxsize from typing import Dict, List, Tuple, Union, cast @@ -11,7 +11,7 @@ from reportlab.pdfbase.pdfmetrics import stringWidth from .constants import (COMB, DEFAULT_FONT_SIZE, MULTILINE, NEW_LINE_SYMBOL, - WIDGET_TYPES, MaxLen, Rect, Annots) + WIDGET_TYPES, Annots, MaxLen, Rect) from .font import (adjust_paragraph_font_size, adjust_text_field_font_size, auto_detect_font, get_text_field_font_color, get_text_field_font_size, text_field_font_size) @@ -21,7 +21,8 @@ from .middleware.text import Text from .patterns import (BUTTON_STYLE_PATTERNS, DROPDOWN_CHOICE_PATTERNS, TEXT_FIELD_FLAG_PATTERNS, WIDGET_ALIGNMENT_PATTERNS, - WIDGET_KEY_PATTERNS, WIDGET_TYPE_PATTERNS, update_annotation_name) + WIDGET_KEY_PATTERNS, WIDGET_TYPE_PATTERNS, + update_annotation_name) from .utils import find_pattern_match, stream_to_io, traverse_pattern from .watermark import create_watermarks_and_draw diff --git a/PyPDFForm/wrapper.py b/PyPDFForm/wrapper.py index 62636f8e..a1fcb72b 100644 --- a/PyPDFForm/wrapper.py +++ b/PyPDFForm/wrapper.py @@ -18,7 +18,7 @@ from .middleware.text import Text from .template import (build_widgets, dropdown_to_text, set_character_x_paddings, update_text_field_attributes, - widget_rect_watermarks, update_widget_key) + update_widget_key, widget_rect_watermarks) from .utils import (get_page_streams, merge_two_pdfs, preview_widget_to_draw, remove_all_widgets) from .watermark import create_watermarks_and_draw, merge_watermarks_with_pdf @@ -235,11 +235,15 @@ def create_widget( return self - def update_widget_key(self, old_key: str, new_key: str, index: int = 0) -> PdfWrapper: + def update_widget_key( + self, old_key: str, new_key: str, index: int = 0 + ) -> PdfWrapper: """Updates the key of an existed widget on a PDF form.""" self.__init__( - template=update_widget_key(self.read(), self.widgets, old_key, new_key, index), + template=update_widget_key( + self.read(), self.widgets, old_key, new_key, index + ), global_font=self.global_font, global_font_size=self.global_font_size, global_font_color=self.global_font_color, diff --git a/tests/test_functional.py b/tests/test_functional.py index 352fbe6e..68609bb9 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -628,9 +628,7 @@ def test_fill_image( assert obj.stream == expected -def test_update_radio_key( - template_with_radiobutton_stream, pdf_samples, request -): +def test_update_radio_key(template_with_radiobutton_stream, pdf_samples, request): expected_path = os.path.join(pdf_samples, "test_update_radio_key.pdf") with open(expected_path, "rb+") as f: obj = PdfWrapper(template_with_radiobutton_stream) @@ -645,9 +643,7 @@ def test_update_radio_key( assert obj.preview == expected -def test_update_sejda_key( - sejda_template, pdf_samples, request -): +def test_update_sejda_key(sejda_template, pdf_samples, request): expected_path = os.path.join(pdf_samples, "test_update_sejda_key.pdf") with open(expected_path, "rb+") as f: obj = PdfWrapper(sejda_template)