Skip to content

Commit

Permalink
Pleasing black (#1354)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C authored Jan 29, 2025
1 parent e20cc78 commit bc5189b
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 20 deletions.
1 change: 1 addition & 0 deletions fpdf/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(self, *args, **kwargs):

class AnnotationDict(AnnotationMixin):
"A PDF annotation that get serialized as an inline <<dictionnary>>"

__slots__ = ( # RAM usage optimization
"type",
"subtype",
Expand Down
4 changes: 4 additions & 0 deletions fpdf/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def coerce(cls, value):

class WrapMode(CoerciveEnum):
"Defines how to break and wrap lines in multi-line text."

WORD = intern("WORD")
"Wrap by word"

Expand All @@ -158,6 +159,7 @@ class WrapMode(CoerciveEnum):

class CharVPos(CoerciveEnum):
"Defines the vertical position of text relative to the line."

SUP = intern("SUP")
"Superscript"

Expand Down Expand Up @@ -493,6 +495,7 @@ def coerce(cls, value):

class TextMode(CoerciveIntEnum):
"Values described in PDF spec section 'Text Rendering Mode'"

FILL = 0
STROKE = 1
FILL_STROKE = 2
Expand Down Expand Up @@ -552,6 +555,7 @@ class YPos(CoerciveEnum):

class Angle(CoerciveIntEnum):
"Direction values used for mirror transformations specifying the angle of mirror line"

NORTH = 90
EAST = 0
SOUTH = 270
Expand Down
1 change: 1 addition & 0 deletions fpdf/fpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def wrapper(self, *args, **kwargs):

class FPDF(GraphicsStateMixin, TextRegionMixin):
"PDF Generation class"

MARKDOWN_BOLD_MARKER = "**"
MARKDOWN_ITALICS_MARKER = "__"
MARKDOWN_UNDERLINE_MARKER = "--"
Expand Down
1 change: 1 addition & 0 deletions fpdf/image_datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def size_in_document_units(self, w, h, scale=1):

class VectorImageInfo(ImageInfo):
"Information about a vector image used in the PDF document"

# pass


Expand Down
4 changes: 2 additions & 2 deletions fpdf/line_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"\u2006", # | SIX-PER-EM SPACE
"\u2008", # | PUNCTUATION SPACE
"\u2009", # | THIN SPACE
"\u200A", # | HAIR SPACE
"\u205F", # | MEDIUM MATHEMATICAL SPACE
"\u200a", # | HAIR SPACE
"\u205f", # | MEDIUM MATHEMATICAL SPACE
"\u3000", # | IDEOGRAPHIC SPACE
"\u0009", # | TAB
]
Expand Down
1 change: 1 addition & 0 deletions fpdf/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ def cell(
@dataclass(frozen=True)
class Cell:
"Internal representation of a table cell"

__slots__ = ( # RAM usage optimization
"text",
"align",
Expand Down
2 changes: 1 addition & 1 deletion scripts/benchmark_borb_vs_fpdf2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""Speed benchmark: how much time each lib takes to generate a 10 thousands pages PDF with ~180 distinct images?
(disclaimer: the author of this benchmark is fpdf2 current maintainer)"""
(disclaimer: the author of this benchmark is fpdf2 current maintainer)"""
# Script used in this article: https://chezsoi.org/lucas/blog/fpdf2-5-2-svg-support-and-borb.html
import resource
from decimal import Decimal
Expand Down
18 changes: 9 additions & 9 deletions test/fonts/test_wraps_zerowidthspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def test_wraps_zerowidthspace(tmp_path):
pdf.write(
8,
"Thai (ideally wouldn't wrap after the space after '1000'): "
+ "นโยบาย\u200Bสาธารณะ\u200Bมี\u200Bความ\u200Bสำคัญ\u200Bต่อ\u200B"
+ "การ\u200Bสนับสนุน\u200Bการ\u200Bออก\u200Bแบบ\u200Bและ\u200Bการ"
+ "\u200Bสร้าง\u200Bชุมชน\u200Bและ\u200Bเมือง\u200Bสุขภาพ\u200Bดี\u200B"
+ "และ\u200Bยั่งยืน รายการ\u200Bตรวจ\u200Bสอบนโยบาย\u200Bความ\u200B"
+ "ท้าทาย 1,000 เมือง\u200Bสำหรับ\u200Bใช้\u200Bเพื่อ\u200Bประเมิน\u200Bการ"
+ "\u200Bมี\u200Bอยู่\u200Bและ\u200Bคุณภาพ\u200Bของ\u200Bนโยบาย\u200Bที่"
+ "\u200Bสอด\u200Bคล้อง\u200Bกับ\u200Bหลัก\u200Bฐาน\u200Bและ\u200Bหลัก"
+ "\u200Bการ\u200Bสำหรับ\u200Bเมือง\u200Bที่\u200Bมี\u200Bสุขภาพ\u200Bดี"
+ "\u200Bและ\u200Bยั่งยืน",
+ "นโยบาย\u200bสาธารณะ\u200bมี\u200bความ\u200bสำคัญ\u200bต่อ\u200b"
+ "การ\u200bสนับสนุน\u200bการ\u200bออก\u200bแบบ\u200bและ\u200bการ"
+ "\u200bสร้าง\u200bชุมชน\u200bและ\u200bเมือง\u200bสุขภาพ\u200bดี\u200b"
+ "และ\u200bยั่งยืน รายการ\u200bตรวจ\u200bสอบนโยบาย\u200bความ\u200b"
+ "ท้าทาย 1,000 เมือง\u200bสำหรับ\u200bใช้\u200bเพื่อ\u200bประเมิน\u200bการ"
+ "\u200bมี\u200bอยู่\u200bและ\u200bคุณภาพ\u200bของ\u200bนโยบาย\u200bที่"
+ "\u200bสอด\u200bคล้อง\u200bกับ\u200bหลัก\u200bฐาน\u200bและ\u200bหลัก"
+ "\u200bการ\u200bสำหรับ\u200bเมือง\u200bที่\u200bมี\u200bสุขภาพ\u200bดี"
+ "\u200bและ\u200bยั่งยืน",
)
assert_pdf_equal(pdf, HERE / "thai_wraps_zerowidthspace.pdf", tmp_path)
14 changes: 7 additions & 7 deletions test/test_positioning.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
""" Tests related to positioning self.x and self.y on the page.
implemented:
* ln()
to be implemented:
* set_x()
* set_y()
* set_xy()
"""Tests related to positioning self.x and self.y on the page.
implemented:
* ln()
to be implemented:
* set_x()
* set_y()
* set_xy()
"""

from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion test/text/test_varied_fragments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Test that _render_styled_text_line() correctly handles sequences of
"""Test that _render_styled_text_line() correctly handles sequences of
Fragments with varying font/size/style and other characteristics.
"""

Expand Down

0 comments on commit bc5189b

Please sign in to comment.