Comments (12)
Out of curiosity, I got the current
main
branch of Pillow and added[tool.mypy] disallow_untyped_defs = trueto
pyproject.toml
. There's quite a lot of untyped defs:Found 853 errors in 58 files (checked 102 source files)
As a progress update, that number is now halved - we're down to
Found 421 errors in 40 files (checked 102 source files)
from pillow.
We're now down to
Found 97 errors in 16 files (checked 283 source files)
from pillow.
Pillow 10.4.0 has now been released, with type hints for all of the methods explicitly mentioned in this issue.
from pillow.
@radarhere 10.4.0 allowed us to remove a lot of type: ignore
statements, thanks! ❤️
In our particular codebase, the only remaining untyped call we hit after upgrading to 10.4.0 is:
Line 99 in 8c26622
from pillow.
If you're happy with that, great! However, the OP wanted us to meet a different standard - not showing any errors when disallow_untyped_defs = true
was enabled.
With that setting, we're still at
Found 57 errors in 11 files (checked 283 source files)
from pillow.
While I don't feel comfortable making the decision to remove py.typed myself, I can help add further type hints. I've created #8030 to add verify()
, draft()
and _expand()
(I think you meant this, as ImageOps.expand()
is already typed in 10.3.0).
Edit: I've created #8042 for filter()
.
#8032 has been created to add type hints for load()
.
I know that to a certain extent, these were just examples you were mentioning, and there is plenty more work to go.
we call PIL.Image.Image.open() which (among many other function) is untyped
This should already be partially type hinted in 10.3.0.
Line 3225 in 5c89d88
Thanks to #7944, that has been improved in main.
Lines 3250 to 3254 in ddbf08f
One example of a function missing type hints is from PIL.Image.fromarray.
This has actually already been added to main in #7936
The next release of Pillow is scheduled for July 1st, so if there are any more specific methods you would like to see typed before then, feel free to request them.
from pillow.
#8191 has now typed that method.
from pillow.
We hit a large number of new Mypy issues when we upgraded to Pillow 10.3.0, to the point where we may pin to 10.2.0 until they are addressed and all the missing type hints added (or py.typed
is removed until this is done).
Some of the errors can be suppressed in the Mypy config:
[tool.mypy]
untyped_calls_exclude = [
"PIL",
]
One example of a function missing type hints is PIL.Image.fromarray
.
from pillow.
I'd like to propose a PR, but I'm afraid I don't have the time to work on such a large change. Even the
Image
class has quite a lot of untyped methods (load()
,verify()
,draft()
,expand()
,filter()
, and many others).
Smaller PRs are very welcome and also preferred, they're easier to review and quicker to merge.
from pillow.
Looks like
Success: no issues found in 283 source files
to me on 71876cf :)
from pillow.
Ah, I thought we were going with what make mypy
checks. My bad!
from pillow.
To avoid regressions, I'd recommend turning this on in this repo once the remaining missing types are fixed.
from pillow.
Related Issues (20)
- Possible to add an IFD to an image's EXIF data? HOT 2
- Having trouble installing libraqm HOT 23
- `Image.fromqimage()` raises `TypeError` HOT 2
- `alpha_composite` works poorly with transparency
- Windows Docker / nanoserver support HOT 8
- Save GIF without loss of quality HOT 23
- scientific-python-nightly-wheels-publish triggered in fork HOT 1
- `ImageFont` claims to load font sizes in pixels but seems to use points? HOT 6
- Problems HOT 1
- Emf file is not handled correctly HOT 2
- Bitmap missing for glyph HOT 4
- ImportError: cannot import name '_imagingft' from 'PIL' HOT 7
- Cannot install Tkdesigner HOT 2
- Cannot install Tkdesigner HOT 14
- Add XMP writing HOT 7
- Add SVG Support Using PlutoSVG HOT 3
- ImageDraw.rounded_rectangle: wrong ValueError HOT 2
- Crash when using `Draw.text` with invalid type HOT 2
- ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (python3.7, PILLOW vers < 9.0) HOT 8
- Scale factor for resizing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pillow.