Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Continuation of WIP: Type Annotations

Open wiredfool opened this issue 7 years ago • 6 comments

Fixes #2687

  • make typecheck, i.e. mypy -2 --ignore-missing-imports src/PIL/Image.py works

wiredfool avatar Jan 08 '18 11:01 wiredfool

Just to make the link, the starting issue for this topic is #2625

radarhere avatar Mar 19 '18 08:03 radarhere

I'll look at updating these, but the big question is now -- Should we merge this?

@python-pillow/pillow-team ?

wiredfool avatar Mar 21 '18 08:03 wiredfool

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.

aclark4life avatar Mar 21 '18 14:03 aclark4life

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.

hugovk avatar Mar 24 '18 14:03 hugovk

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.

wiredfool avatar Apr 01 '18 16:04 wiredfool

What's the status on this? Type annotations for Pillow would be great!

Stadly avatar Oct 03 '20 10:10 Stadly

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.

hugovk avatar Oct 16 '23 20:10 hugovk