Skip to content

Commit

Permalink
[skip ci]: black/isort
Browse files Browse the repository at this point in the history
  • Loading branch information
black-isort-bot committed Dec 23, 2024
1 parent 32e19f2 commit f0ac392
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
7 changes: 5 additions & 2 deletions PyPDFForm/middleware/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ def __init__(
def schema_definition(self) -> dict:
"""Json schema definition of the radiobutton."""

return {"maximum": self.number_of_options - 1,
**super().schema_definition, "type": "integer"}
return {
"maximum": self.number_of_options - 1,
**super().schema_definition,
"type": "integer",
}

@property
def sample_value(self) -> int:
Expand Down
9 changes: 3 additions & 6 deletions PyPDFForm/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
TextStringObject)

from .constants import (AP, AS, CA, DA, DV, FT, IMAGE_FIELD_IDENTIFIER, JS, MK,
MULTILINE, READ_ONLY, A, Btn, Ch, Ff, N, Off, Opt,
Parent, Q, Sig, T, Tx, TU, V, Yes)
MULTILINE, READ_ONLY, TU, A, Btn, Ch, Ff, N, Off, Opt,
Parent, Q, Sig, T, Tx, V, Yes)
from .middleware.checkbox import Checkbox
from .middleware.dropdown import Dropdown
from .middleware.image import Image
Expand Down Expand Up @@ -68,10 +68,7 @@
{Parent: {T: True}},
]

WIDGET_DESCRIPTION_PATTERNS = [
{TU: True},
{Parent: {TU: True}}
]
WIDGET_DESCRIPTION_PATTERNS = [{TU: True}, {Parent: {TU: True}}]

DROPDOWN_CHOICE_PATTERNS = [
{Opt: True},
Expand Down
4 changes: 2 additions & 2 deletions PyPDFForm/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +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, WIDGET_DESCRIPTION_PATTERNS,
update_annotation_name)
WIDGET_DESCRIPTION_PATTERNS, 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

Expand Down
12 changes: 7 additions & 5 deletions tests/scenario/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import os

from PyPDFForm import PdfWrapper
from PyPDFForm.constants import TU, Parent
from PyPDFForm.middleware.radio import Radio
from PyPDFForm.template import get_widgets_by_page, get_widget_key
from PyPDFForm.constants import Parent, TU
from PyPDFForm.template import get_widget_key, get_widgets_by_page


def test_pdf_form_with_pages_without_widgets(issue_pdf_directory, request):
Expand Down Expand Up @@ -308,11 +308,11 @@ def test_get_desc_in_schema(issue_pdf_directory):

assert (
obj.schema["properties"]["P1_checkbox4[0]"]["description"]
== "Part 1. Information About You. Your Full Name. 4. Has your name legally changed since the issuance of your Permanent Resident Card? Select Yes. (Proceed to Item Numbers 5. A. through 5. C.)." # noqa
== "Part 1. Information About You. Your Full Name. 4. Has your name legally changed since the issuance of your Permanent Resident Card? Select Yes. (Proceed to Item Numbers 5. A. through 5. C.)." # noqa
)
assert (
obj.schema["properties"]["P1_checkbox4[1]"]["description"]
== "Part 1. Information About You. Your Full Name. 4. Has your name legally changed since the issuance of your Permanent Resident Card? Select No (Proceed to Item Numbers 6. A. through 6. I.)." # noqa
== "Part 1. Information About You. Your Full Name. 4. Has your name legally changed since the issuance of your Permanent Resident Card? Select No (Proceed to Item Numbers 6. A. through 6. I.)." # noqa
)
assert (
obj.schema["properties"]["P1_checkbox4[2]"]["description"]
Expand All @@ -333,4 +333,6 @@ def test_get_desc_in_schema_radio(issue_pdf_directory):
key = get_widget_key(widget)

if key in keys_to_check:
assert widget[Parent][TU] == obj.schema["properties"][key]["description"]
assert (
widget[Parent][TU] == obj.schema["properties"][key]["description"]
)

0 comments on commit f0ac392

Please sign in to comment.