Skip to content

refactor: modernize typing annotations and simplify checks - #505

Merged
deeplook merged 2 commits into
mainfrom
refactor/typing-modernization
Aug 14, 2026
Merged

refactor: modernize typing annotations and simplify checks#505
deeplook merged 2 commits into
mainfrom
refactor/typing-modernization

Conversation

@deeplook

Copy link
Copy Markdown
Owner

Summary

Applies the same changes as #496 (originally opened by @inquilabee's ShipGate tool, closed after the source fork was deleted before it could be merged): switch typing.List/Dict/Tuple/Set to PEP 585 builtin generics now that the project targets Python 3.9+, and simplify a couple of emptiness/membership checks. No behavior change.

Rebased onto current main — the original diff predated the font-size PX_TO_PT fix (#503) and the removal of the deprecated gradient-shape aliases, so those spots were re-resolved by hand.

Also includes an unrelated small fix: silences a UserWarning from test_convert_pdf_png that traces to ReportLab's own renderPM.drawImage (it reopens a palette+tRNS PNG referenced by file path and converts it without normalizing first). The rendered PNG is correct; nothing to fix on svglib's side, so the warning is filtered with an explanatory docstring rather than changing image-handling behavior.

Test plan

  • uv run pytest -q — 190 passed, 2 skipped, 1 xfailed, no warnings
  • uv run ruff check . / uv run ruff format --check . — clean
  • uv run mypy src tests — clean

Applies the same changes as PR #496 (originally opened by inquilabee's
ShipGate tool, closed after its fork was deleted before it could be
merged): switch typing.List/Dict/Tuple/Set to PEP 585 builtin generics
now that the project targets Python 3.9+, and simplify a couple of
emptiness/membership checks. Rebased onto the current 2.1.0+ code
(the PR predated the font-size PX_TO_PT fix and the removal of the
deprecated gradient-shape aliases).
…df_png

Traced to reportlab.graphics.renderPM._PMRenderer.drawImage, which reopens
a file-path <image> reference and calls PIL's Image.convert('RGB')
directly, without normalizing a palette+tRNS PNG to RGBA first like
svglib does for base64-embedded images. The rendered PNG is correct;
the warning is purely a reportlab-internal code path, so scope the
filter to this one test rather than changing image-handling behavior.
@deeplook
deeplook merged commit 79066c5 into main Aug 14, 2026
29 checks passed
@deeplook
deeplook deleted the refactor/typing-modernization branch August 14, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant