Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Decoders and encoders subclass PyDecoder and PyEncoder

Open radarhere opened this issue 1 year ago • 0 comments

register_decoder() and register_encoder() state that decoder/encoder are callables that return an object. https://github.com/python-pillow/Pillow/blob/912a33f5e9815735d994c856fa241856e13c694c/src/PIL/Image.py#L3527-L3534 https://github.com/python-pillow/Pillow/blob/912a33f5e9815735d994c856fa241856e13c694c/src/PIL/Image.py#L3541-L3548

However, if you look at Pillow's source code, it is not a callable, it is just an object.

https://github.com/python-pillow/Pillow/blob/912a33f5e9815735d994c856fa241856e13c694c/src/PIL/BlpImagePlugin.py#L472-L476 https://github.com/python-pillow/Pillow/blob/912a33f5e9815735d994c856fa241856e13c694c/src/PIL/PpmImagePlugin.py#L362-L363 https://github.com/python-pillow/Pillow/blob/912a33f5e9815735d994c856fa241856e13c694c/src/PIL/DdsImagePlugin.py#L569 https://github.com/python-pillow/Pillow/blob/912a33f5e9815735d994c856fa241856e13c694c/src/PIL/SgiImagePlugin.py#L230

This PR updates the docstrings, clarifies this by adding type hints, and updates the tests (which did treat the arguments as callables).

radarhere avatar Feb 15 '24 09:02 radarhere