Skip to content

[Pillow] Module has no attribute "Resampling" #8366

@owocado

Description

@owocado

Hi,

Since Pillow version >9.1.0, the Pillow library has switched the PIL.Image filters to Resampling enum class and deprecated the old method of using typing.Literal for defining filters. Due to this reason, mypy shows the error stated in this issue title if anyone is using types-Pillow package and is using PIL.Image.Resampling approach in our project. The reason for me to switch to Resampling enum method is to avoid DeprecationWarning and safeguard my code ahead of time.

[WARNING] py.warnings: DeprecationWarning: LANCZOS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.

Pillow docs for reference: https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=lanczos#resampling-filters
Pillow 9.1.0 release notes: https://pillow.readthedocs.io/en/stable/releasenotes/9.1.0.html#constants
the same is documented in https://pillow.readthedocs.io/en/stable/deprecations.html#constants

It would be grateful if this can be accounted for in the pillow typeshed package if possible. I would like to submit a PR to fix but unsure how should I go about this so I decided to open an issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions