Commit e855f6c
authored
* Add type hints support (#355)
Adds PEP 561 type stubs for pyvips, enabling IDE autocomplete
and type checking with mypy.
- Add pyvips/__init__.pyi with type stubs for 300+ Image operations
- Add generate_type_stubs.py script using introspection (follows existing enum/doc pattern)
- Add test_type_hints.py with mypy validation
- Update README with type checking documentation
- Add mypy check to CI workflow
Type stubs are generated to handle libvips's 300+ operations
and frequent updates. Zero runtime overhead, full type coverage.
* Add comprehensive type hints for hand-written bindings and enhance operator overloads
- Add type hints for ifthenelse, composite, floor, ceil, rint, bandsplit, bandjoin, bandrank, hasalpha, get_page_height
- Enhance operator overloads to support List[float] and List[int] operands
- Move generate_type_stubs.py from pyvips/ to examples/ for better maintainability
- Add CI mypy checks for examples/affine.py and examples/convolve.py
- Update documentation references for type stub generation path
* Update CHANGELOG credit to JoshCLWren
* Add type hints for composite and ifthenelse hand-written bindings
* Expand mypy type checking to more example scripts
* Fix operation filtering in type stub generator to correctly filter deprecated operations
Changed hardcoded value 4 (NOCACHE) to use _OPERATION_DEPRECATED constant (8).
This fixes incorrect filtering that was excluding uncacheable operations instead
of deprecated ones.
* Clean up type stub generator: remove unused imports, extra blank line, add flake8 noqa
* Complete comprehensive type hints for pyvips
- Add SourceCustom class with on_read() and on_seek() methods
- Add Source.new_from_descriptor() and Target.new_to_descriptor() static methods
- Add pyvips.call() function for calling libvips operations
- Add erode() and dilate() methods to Image class stub
- Add explicit enum attributes for Direction and Align (HORIZONTAL, VERTICAL, LOW, CENTRE, HIGH)
- Fix try7.py to use .format instead of non-existent .bandfmt attribute
- Add type: ignore comments for Union type narrowing issues in 7 example files
- All 35 example files now pass mypy type checking
- Type stub file passes mypy with 0 errors
* Update version to 3.2.0 and update CI
- Update version.py to 3.2.0
- Update CHANGELOG.rst with version 3.2.0 entry
- Update doc/conf.py to version 3.2.0
- Expand CI mypy checks to include more example scripts
* Fix new_from_image type annotation to include int and List[int] support
Match operator overload signatures which already support int and List[int] types.
Ensures type consistency across the Image API.
* Revert linting changes in examples and doc/conf.py
- Revert examples/*.py to origin/master (remove type: ignore comments that caused flake8 E501 errors)
- Revert doc/conf.py quote-style changes back to single quotes
- Keep only version bump (3.1 -> 3.2, 3.1.1 -> 3.2.0)
- Fix remaining line-length issues in doc/conf.py
* Fix doc/conf.py syntax and line-length errors
* pin mypy to <1.19 for PyPy 3.9 compatibility
mypy 1.19+ introduced a dependency on the librt module which is not
available on PyPy 3.9, causing ModuleNotFoundError during type checking.
This pins mypy to version 1.18.x which works across all Python versions
in the CI matrix.
1 parent ae98cd3 commit e855f6c
File tree
14 files changed
+1358
-58
lines changed- .github/workflows
- doc
- examples
- pyvips
- tests
14 files changed
+1358
-58
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
35 | 45 | | |
36 | 46 | | |
37 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
1 | 8 | | |
2 | 9 | | |
3 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
231 | 255 | | |
232 | 256 | | |
233 | 257 | | |
| |||
246 | 270 | | |
247 | 271 | | |
248 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
249 | 283 | | |
250 | 284 | | |
251 | 285 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
| 68 | + | |
68 | 69 | | |
69 | | - | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
75 | | - | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
144 | | - | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
152 | | - | |
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
| |||
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
162 | | - | |
163 | | - | |
| 160 | + | |
164 | 161 | | |
165 | 162 | | |
166 | 163 | | |
167 | 164 | | |
168 | 165 | | |
169 | 166 | | |
170 | 167 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 168 | + | |
175 | 169 | | |
176 | 170 | | |
177 | 171 | | |
| |||
180 | 174 | | |
181 | 175 | | |
182 | 176 | | |
183 | | - | |
184 | | - | |
185 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
195 | | - | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
209 | | - | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
231 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
| |||
242 | 244 | | |
243 | 245 | | |
244 | 246 | | |
245 | | - | |
246 | | - | |
247 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
248 | 252 | | |
249 | 253 | | |
250 | | - | |
251 | | - | |
252 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
253 | 259 | | |
254 | 260 | | |
255 | 261 | | |
256 | | - | |
| 262 | + | |
257 | 263 | | |
258 | 264 | | |
0 commit comments