Pillow
Pillow copied to clipboard
Continuation of WIP: Type Annotations
Fixes #2687
- make typecheck, i.e.
mypy -2 --ignore-missing-imports src/PIL/Image.pyworks
Just to make the link, the starting issue for this topic is #2625
I'll look at updating these, but the big question is now -- Should we merge this?
@python-pillow/pillow-team ?
With all the work done by you and @neiljp (and others?) and at least one other comment indicating this is something people want, I'd say merge-away for April 1 release.
I've not used typing in Python before, but no objections.
Of course, in the future we'll need to make sure new/changed code updates the types. Some instructions in CONTRIBUTING.md would be helpful, and we'll need to make sure contributors' PRs keep things updated, or update them ourselves.
I think it would be useful to check the typing on the CI. I'd suggest a new Travis job that just does the type checking, and no other tests. That way it would run and pass or fail quickly, and wouldn't muddy the waters of whether the actual unit tests pass or fail.
One thing I am really intrigued by, is the experience of anyone involved of the process - have you identified any latent issues in doing this? is this primarily good for documentation? pushing you towards simpler/better implementations? ...or just an interesting experiment that may as well get merged at this point?
I wouldn't say that it's pushing things to be a simpler implementation, because in many cases we're stuck with the interface we have, and that interface was not designed to be type safe. There are a few idioms, like a single type static assignment that work, and are at least one way to do things. But they aren't simple, they don't seem pythonic, and they obscure the flow of what's going on.
I could see where this might guide IDEs to make better suggestions. I can't recall if this process actually uncovered any bugs in Pillow, but my feeling at the end of it was more that this was an interesting exercise than a leap forward in code quality.
What's the status on this? Type annotations for Pillow would be great!
This has conflicts and a lot has changed in typing since this was opened. Let's close in favour of a more incremental approach along the lines of https://github.com/python-pillow/Pillow/issues/2625#issuecomment-1765150919. Thanks anyway for all your work here.