8000 fix some flake8 complaints · libvips/pyvips@7564572 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7564572

Browse files
committed
fix some flake8 complaints
1 parent c146025 commit 7564572

File tree

10 files changed

+46
-37
lines changed

10 files changed

+46
-37
lines changed

examples/try1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22

33
import logging
4-
logging.basicConfig(level = logging.DEBUG)
5-
64
import pyvips
75

6+
logging.basicConfig(level=logging.DEBUG)
7+
88
print('test Image')
99
image = pyvips.Image.new_from_file('/data/john/pics/k2.jpg')
1010
print('image =', image)

pyvips/decls.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# we keep these together to make switching between ABI and API modes simpler
44

55
# we have to pass in the libvips version, since it can come from either
6-
# pkg-config in compile.py (in API mode) or libvips itself in __init__.py
6+
# pkg-config in compile.py (in API mode) or libvips itself in __init__.py
77
# (in ABI mode)
88

99
import sys
@@ -16,9 +16,9 @@ def _enabled(features, name):
1616
def cdefs(features):
1717
"""Return the C API declarations for libvips.
1818
19-
features is a dict with the features we want. Some featrures were only added
20-
in later libvipsm for example, and some need to be disabled in some FFI
21-
modes.
19+
features is a dict with the features we want. Some featrures were only
20+
added in later libvipsm for example, and some need to be disabled in
21+
some FFI modes.
2222
"""
2323

2424
code = ''
@@ -148,7 +148,7 @@ def cdefs(features):
148148
char* _blurb;
149149
GData* qdata;
150150
unsigned int ref_count;
151-
unsigned int param_id;
151+
unsigned int param_id;
152152
} GParamSpec;
153153
154154
void g_object_ref (void* object);
@@ -213,7 +213,7 @@ def cdefs(features):
213213
214214
void vips_object_print_all (void);
215215
216-
int vips_object_set_from_string (VipsObject* object,
216+
int vips_object_set_from_string (VipsObject* object,
217217
const char* options);
218218
219219
const char* vips_object_get_description (VipsObject* object);
@@ -227,7 +227,8 @@ def cdefs(features):
227227
} VipsImage;
228228
229229
const char* vips_foreign_find_load (const char* name);
230-
const char* vips_foreign_find_load_buffer (const void* data, size_t size);
230+
const char* vips_foreign_find_load_buffer (const void* data,
231+
size_t size);
231232
const char* vips_foreign_find_save (const char* name);
232233
const char* vips_foreign_find_save_buffer (const char* suffix);
233234
@@ -242,7 +243,8 @@ def cdefs(features):
242243
const char* name);
243244
int vips_image_get (const VipsImage* image,
244245
const char* name, GValue* value_copy);
245-
void vips_image_set (VipsImage* image, const char* name, GValue* value);
246+
void vips_image_set (VipsImage* image,
247+
const char* name, GValue* value);
246248
int vips_image_remove (VipsImage* image, const char* name);
247249
char** vips_image_get_fields (VipsImage* image);
248250
@@ -295,12 +297,12 @@ def cdefs(features):
295297
if _enabled(features, '8.6+'):
296298
code += '''
297299
GType vips_blend_mode_get_type (void);
298-
void vips_value_set_blob_free (GValue* value,
300+
void vips_value_set_blob_free (GValue* value,
299301
void* data, size_t length);
300302
301303
'''
302304

303-
# we must only define these in API mode ... in ABI mode we need to call
305+
# we must only define these in API mode ... in ABI mode we need to call
304306
# these things earlier
305307
if _enabled(features, 'api'):
306308
code += '''
@@ -314,4 +316,3 @@ def cdefs(features):
314316
__all__ = [
315317
'cdefs'
316318
]
317-

pyvips/gvalue.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414

1515
_is_PY2 = sys.version_info.major == 2
1616

17+
1718
# g_free() as something we can use for a VipsCallbackFn
1819
def _g_free_cb_function(a, b):
19-
vips_lib.vips_free(a)
20+
vips_lib.vips_free(a)
21+
22+
2023
_g_free_cb = ffi.callback('VipsCallbackFn', _g_free_cb_function)
2124

25+
2226
class GValue(object):
2327

2428
"""Wrap GValue in a Python class.
@@ -195,30 +199,31 @@ def set(self, value):
195199
ffi.memmove(memory, value, len(value))
196200

197201
# this is horrible!
198-
#
199-
# * in API mode, we must have 8.6+ and use set_blob_free to
200-
# attach the metadata to avoid leaks
201-
# * pre-8.6, we just pass a NULL free pointer and live with the leak
202-
#
202+
#
203+
# * in API mode, we must have 8.6+ and use set_blob_free to
204+
# attach the metadata to avoid leaks
205+
# * pre-8.6, we just pass a NULL free pointer and live with the
206+
# leak
207+
#
203208
# this is because in API mode you can't pass a builtin (what
204209
# vips_lib.g_free() becomes) as a parameter to ffi.callback(), and
205210
# vips_value_set_blob() needs a callback for arg 2
206-
#
211+
#
207212
# additionally, you can't make a py def which calls g_free() and
208-
# thhen use the py def in the callback, since libvips will trigger
209-
# these functions during cleanup, and py will have shut down by then
210-
# and you'll get a segv
213+
# then use the py def in the callback, since libvips will trigger
214+
# these functions during cleanup, and py will have shut down by
215+
# then and you'll get a segv
211216

212217
if at_least_libvips(8, 6):
213-
vips_lib.vips_value_set_blob_free(self.gvalue,
218+
vips_lib.vips_value_set_blob_free(self.gvalue,
214219
memory, len(value))
215220
else:
216221
if pyvips.API_mode:
217222
vips_lib.vips_value_set_blob(self.gvalue,
218223
ffi.NULL, memory, len(value))
219224
else:
220225
vips_lib.vips_value_set_blob(self.gvalue,
221-
glib_lib.g_free,
226+
glib_lib.g_free,
222227
memory, len(value))
223228
else:
224229
raise Error('unsupported gtype for set {0}, fundamental {1}'.

pyvips/pyvips_build.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
# flake8: noqa
2+
13
import pkgconfig
4+
from cffi import FFI
25

36
# we must have the vips package to be able to do anything
47
if not pkgconfig.exists('vips'):
58
raise Exception('unable to find pkg-config package "vips"')
69
if pkgconfig.installed('vips', '< 8.2'):
710
raise Exception('pkg-config "vips" is too old -- need libvips 8.2 or later')
811

9-
from cffi import FFI
10-
1112
ffibuilder = FFI()
1213

1314
ffibuilder.set_source("_libvips",

pyvips/vimage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,8 @@ def composite(self, other, mode, **kwargs):
10481048
# we need to map str->int by hand
10491049
mode = [GValue.to_enum(GValue.blend_mode_type, x) for x in mode]
10501050

1051-
return pyvips.Operation.call('composite', [self] + other, mode, **kwargs)
1051+
return pyvips.Operation.call('composite',
1052+
[self] + other, mode, **kwargs)
10521053

10531054
def bandrank(self, other, **kwargs):
10541055
"""Band-wise rank filter a set of images."""

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
https://github.com/jcupitt/pyvips
55
"""
66

7+
# flake8: noqa
8+
79
from codecs import open
810
from os import path
911

tests/test_arithmetic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,9 @@ def test_find_trim(self):
566566
self.assertEqual(height, 60)
567567

568568
test_rgb = test.bandjoin([test, test])
569-
left, top, width, height = test_rgb.find_trim(background = [255,
570-
255,
571-
255])
569+
left, top, width, height = test_rgb.find_trim(background=[255,
570+
255,
571+
255])
572572
self.assertEqual(left, 10)
573573
self.assertEqual(top, 20)
574574
self.assertEqual(width, 50)

tests/test_conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def test_composite(self):
373373
base = self.colour + 100
374374
comp = base.composite(overlay, "over")
375375

376-
self.assertAlmostEqualObjects(comp(0, 0), [51.8, 52.8, 53.8, 255],
376+
self.assertAlmostEqualObjects(comp(0, 0), [51.8, 52.8, 53.8, 255],
377377
places=1)
378378

379379
def test_unpremultiply(self):

tests/test_foreign.py

Lines changed: 2 additions & 2 deletions
< 2851 /tr>
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,8 @@ def test_dzsave(self):
778778
root, ext = os.path.splitext(base)
779779

780780
self.colour.dzsave(filename)
781-
# before 8.5.8, you needed a gc on pypy to flush small zip output to
782-
# disc
781+
# before 8.5.8, you needed a gc on pypy to flush small zip
782+
# output to disc
783783
gc.collect()
784784
with open(filename, 'rb') as f:
785785
buf1 = f.read()

tests/test_resample.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ def test_reduce(self):
7979
# cast down to 0-127, the smallest range, so we aren't messed up by
8080
# clipping
8181
im = im.cast(pyvips.BandFormat.CHAR)
82-
bicubic = pyvips.Interpolate.new("bicubic")
83-
bilinear = pyvips.Interpolate.new("bilinear")
8482

8583
for fac in [1, 1.1, 1.5, 1.999]:
8684
for fmt in all_formats:
87-
for kernel in ["nearest", "linear", "cubic", "lanczos2", "lanczos3"]:
85+
for kernel in ["nearest", "linear",
86+
"cubic", "lanczos2", "lanczos3"]:
8887
x = im.cast(fmt)
8988
r = x.reduce(fac, fac, kernel=kernel)
9089
d = abs(r.avg() - im.avg())

0 commit comments

Comments
 (0)
0