Skip to content

Pillow deprecation warning causing downstream tests to fail #129

@rosteen

Description

@rosteen

Serialization is now hitting a deprecation warning since the most recent Pillow release:

 ../../.tox/py312-test/lib/python3.12/site-packages/bqplot_image_gl/serialize.py:10: in array_to_image_or_array
    return array_to_image(array, widget.compression)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../.tox/py312-test/lib/python3.12/site-packages/bqplot_image_gl/serialize.py:59: in array_to_image
    image = Image.fromarray(array_bytes, mode="RGBA")

../../.tox/py312-test/lib/python3.12/site-packages/PIL/Image.py:3314: in fromarray
    deprecate("'mode' parameter", 13)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

deprecated = "'mode' parameter", when = 13, replacement = None

    def deprecate(
        deprecated: str,
        when: int | None,
        replacement: str | None = None,
        *,
        action: str | None = None,
        plural: bool = False,
        stacklevel: int = 3,
    ) -> None:
        """
        Deprecations helper.
    
        :param deprecated: Name of thing to be deprecated.
        :param when: Pillow major version to be removed in.
        :param replacement: Name of replacement.
        :param action: Instead of "replacement", give a custom call to action
            e.g. "Upgrade to new thing".
        :param plural: if the deprecated thing is plural, needing "are" instead of "is".
    
        Usually of the form:
    
            "[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd).
            Use [replacement] instead."
    
        You can leave out the replacement sentence:
    
            "[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd)"
    
        Or with another call to action:
    
            "[deprecated] is deprecated and will be removed in Pillow [when] (yyyy-mm-dd).
            [action]."
        """
    
        is_ = "are" if plural else "is"
    
        if when is None:
            removed = "a future version"
        elif when <= int(__version__.split(".")[0]):
            msg = f"{deprecated} {is_} deprecated and should be removed."
            raise RuntimeError(msg)
        elif when == 12:
            removed = "Pillow 12 (2025-10-15)"
        elif when == 13:
            removed = "Pillow 13 (2026-10-15)"
        else:
            msg = f"Unknown removal version: {when}. Update {__name__}?"
            raise ValueError(msg)
    
        if replacement and action:
            msg = "Use only one of 'replacement' and 'action'"
            raise ValueError(msg)
    
        if replacement:
            action = f". Use {replacement} instead."
        elif action:
            action = f". {action.rstrip('.')}."
        else:
            action = ""
    
>       warnings.warn(
            f"{deprecated} {is_} deprecated and will be removed in {removed}{action}",
            DeprecationWarning,
            stacklevel=stacklevel,
        )
E       DeprecationWarning: 'mode' parameter is deprecated and will be removed in Pillow 13 (2026-10-15)

../../.tox/py312-test/lib/python3.12/site-packages/PIL/_deprecate.py:68: DeprecationWarning

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions