Skip to content

Commit

Permalink
mypy fixes after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nulano committed Jun 12, 2024
1 parent 31a8da4 commit 87f51d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,10 @@ def convert_transparency(m, v):
del new_im.info["transparency"]
if trns is not None:
try:
new_im.info["transparency"] = new_im.palette.getcolor(trns, new_im)
new_im.info["transparency"] = new_im.palette.getcolor(
cast(tuple[int, int, int], trns), # trns was converted to RGB
new_im,
)
except Exception:
# if we can't make a transparent color, don't leave the old
# transparency hanging around to mess us up.
Expand Down Expand Up @@ -1178,7 +1181,10 @@ def convert_transparency(m, v):
if trns is not None:
if new_im.mode == "P":
try:
new_im.info["transparency"] = new_im.palette.getcolor(trns, new_im)
new_im.info["transparency"] = new_im.palette.getcolor(
cast(tuple[int, int, int], trns), # trns was converted to RGB
new_im,
)
except ValueError as e:
del new_im.info["transparency"]
if str(e) != "cannot allocate more than 256 colors":
Expand Down

0 comments on commit 87f51d5

Please sign in to comment.