Skip to content

Commit 5cd606b

Browse files
authored
[fpdf2] Make fpdf.fonts.Glyph a dataclass (#13645)
1 parent 205e993 commit 5cd606b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

stubs/fpdf2/@tests/stubtest_allowlist.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ fpdf.fonts.HarfBuzzFont
1010

1111
# Stubtest wants us to use Literals, but that is unreasonable.
1212
fpdf.unicode_script.UNICODE_RANGE_TO_SCRIPT
13+
14+
# Ignore stubtest weirdness "fpdf.fonts.Glyph._DT is not present at runtime"
15+
# https://github.com/python/mypy/issues/18811
16+
fpdf.fonts.Glyph._DT

stubs/fpdf2/fpdf/fonts.pyi

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,13 @@ class PDFFontDescriptor(PDFObject):
118118
font_name: Incomplete
119119
def __init__(self, ascent, descent, cap_height, flags, font_b_box, italic_angle, stem_v, missing_width) -> None: ...
120120

121+
@dataclass(order=True)
121122
class Glyph:
122123
glyph_id: int
123124
unicode: tuple[Incomplete, ...]
124125
glyph_name: str
125126
glyph_width: int
126-
def __hash__(self): ...
127-
def __init__(self, glyph_id, unicode, glyph_name, glyph_width) -> None: ...
128-
def __lt__(self, other): ...
129-
def __gt__(self, other): ...
130-
def __le__(self, other): ...
131-
def __ge__(self, other): ...
132-
133-
__match_args__ = ("glyph_id", "unicode", "glyph_name", "glyph_width")
127+
def __hash__(self) -> int: ...
134128

135129
class SubsetMap:
136130
font: TTFFont

0 commit comments

Comments
 (0)