Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Add various type annotations

Open srittau opened this issue 1 year ago • 5 comments

Changes proposed in this pull request:

  • This PR add various type annotations, especially for the Image, ImageFont, ImageDraw, and _imagingft modules.

srittau avatar May 07 '24 12:05 srittau

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

nulano avatar May 07 '24 17:05 nulano

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

srittau avatar May 08 '24 10:05 srittau

Also, the pypy3.10 failure seems unrelated?

srittau avatar May 08 '24 10:05 srittau

Yeah, the PyPy one is a bit flaky.

hugovk avatar May 08 '24 10:05 hugovk

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 avatar May 09 '24 09:05 radarhere

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

radarhere avatar May 29 '24 02:05 radarhere