Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Helps #2625.
There are two tricky parts in adding type hints to
PIL._binary
:The
i16*
andi32*
give a "Returning Any from function declared to return int" in--strict
mode due to the use ofstruct.unpack_from
. This can be properly silenced with#type: ignore[no-any-return]
, but that gives a "Unused type ignore comment" when running without--strict
, so I have left it out for now.The
i8
function distinguishes betweenint
andbytes
inputs in a way that mypy doesn't recognize. Sincei8
is called with anint
input only fromIptcImagePlugin
, I have removed those calls there and removedint
support as input toi8
.Although the values in
self.info[(3, 60)]
andself.info[(3, 65)]
can be lists if the tags are duplicated, these tags are marked as "non-repeatable" in the specification (pg. 13-14). The specification recommends using the first entry if the tags are duplicated (sec. 1.5-d), but this recommendation was already ignored inIptcImagePlugin
and I was unable to find any images to test this with.In doing so, I found that
IptcImagePlugin.dump
,IptcImagePlugin.i
, andIptcImagePlugin.PAD
are simple helpers that should probably be deprecated (edit: #7664).