python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
11.8k stars 2.13k forks source link

Add various type annotations #8046

Open srittau opened 3 weeks ago

srittau commented 3 weeks ago

Changes proposed in this pull request:

nulano commented 3 weeks ago

FWIW I have some WIP type annotations for ImageFont and _imagingft here: https://github.com/python-pillow/Pillow/compare/main...nulano:Pillow:types-imagefont

srittau commented 3 weeks ago

I think this is ready for review. The docs build might still fail, but I'd need help with that.

srittau commented 3 weeks ago

Also, the pypy3.10 failure seems unrelated?

hugovk commented 3 weeks ago

Yeah, the PyPy one is a bit flaky.

radarhere commented 3 weeks ago

The docs build might still fail, but I'd need help with that.

The error

docstring of PIL.Image.Image.transform:1: WARNING: py:class reference target not found: PIL.Image.GetDataTransform

is saying that the GetDataTransform doesn't appear in the documentation, so transform()'s description can't link to it.

The way to solve this is by updating docs/reference/Image.rst to include it, by adding

.. autoclass:: GetDataTransform
    :show-inheritance:

But given that our other protocols so far are SupportsGetMesh and SupportsArrayInterface, maybe this new protocol could be renamed SupportsGetData?

radarhere commented 4 days ago

I've created https://github.com/srittau/Pillow/pull/2 with various suggestions.