From d0ee9c6e94843b75376706e44eefb24e6346a036 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 17 Mar 2025 18:29:15 +0100 Subject: [PATCH 1/3] [fpdf2] Make fpdf.fonts.Glyph a dataclass --- stubs/fpdf2/fpdf/fonts.pyi | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/stubs/fpdf2/fpdf/fonts.pyi b/stubs/fpdf2/fpdf/fonts.pyi index f498efd2395a..dc793aaed1af 100644 --- a/stubs/fpdf2/fpdf/fonts.pyi +++ b/stubs/fpdf2/fpdf/fonts.pyi @@ -118,19 +118,13 @@ class PDFFontDescriptor(PDFObject): font_name: Incomplete def __init__(self, ascent, descent, cap_height, flags, font_b_box, italic_angle, stem_v, missing_width) -> None: ... +@dataclass(order=True) class Glyph: glyph_id: int unicode: tuple[Incomplete, ...] glyph_name: str glyph_width: int - def __hash__(self): ... - def __init__(self, glyph_id, unicode, glyph_name, glyph_width) -> None: ... - def __lt__(self, other): ... - def __gt__(self, other): ... - def __le__(self, other): ... - def __ge__(self, other): ... - - __match_args__ = ("glyph_id", "unicode", "glyph_name", "glyph_width") + def __hash__(self) -> int: ... class SubsetMap: font: TTFFont From d816ab5d05354056eee150b51852797e7f55ed8d Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 17 Mar 2025 18:34:14 +0100 Subject: [PATCH 2/3] Ignore stubtest weirdness --- stubs/fpdf2/@tests/stubtest_allowlist.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/fpdf2/@tests/stubtest_allowlist.txt b/stubs/fpdf2/@tests/stubtest_allowlist.txt index 3453af1c7378..bc840cfaa9da 100644 --- a/stubs/fpdf2/@tests/stubtest_allowlist.txt +++ b/stubs/fpdf2/@tests/stubtest_allowlist.txt @@ -10,3 +10,6 @@ fpdf.fonts.HarfBuzzFont # Stubtest wants us to use Literals, but that is unreasonable. fpdf.unicode_script.UNICODE_RANGE_TO_SCRIPT + +# Ignore stubtest weirdness "fpdf.fonts.Glyph._DT is not present at runtime" +fpdf.fonts.Glyph._DT From d3ce49e9f54ec43c32eab328aca4f22ae6447395 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 17 Mar 2025 19:15:16 +0100 Subject: [PATCH 3/3] Add mypy issues --- stubs/fpdf2/@tests/stubtest_allowlist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/fpdf2/@tests/stubtest_allowlist.txt b/stubs/fpdf2/@tests/stubtest_allowlist.txt index bc840cfaa9da..4ceb15988f18 100644 --- a/stubs/fpdf2/@tests/stubtest_allowlist.txt +++ b/stubs/fpdf2/@tests/stubtest_allowlist.txt @@ -12,4 +12,5 @@ fpdf.fonts.HarfBuzzFont fpdf.unicode_script.UNICODE_RANGE_TO_SCRIPT # Ignore stubtest weirdness "fpdf.fonts.Glyph._DT is not present at runtime" +# https://github.com/python/mypy/issues/18811 fpdf.fonts.Glyph._DT