mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Flake8 fixes
This commit is contained in:
parent
b9a05b8516
commit
72d5218080
|
@ -883,7 +883,7 @@ class Image(object):
|
|||
try:
|
||||
t = trns_im.palette.getcolor(t)
|
||||
except:
|
||||
raise ValueError("Couldn't allocate a palette "+
|
||||
raise ValueError("Couldn't allocate a palette " +
|
||||
"color for transparency")
|
||||
trns_im.putpixel((0, 0), t)
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ class ImageFile(Image.Image):
|
|||
if n < 0:
|
||||
break
|
||||
b = b[n:]
|
||||
|
||||
|
||||
# Need to cleanup here to prevent leaks in PyPy
|
||||
decoder.cleanup()
|
||||
|
||||
|
@ -473,7 +473,7 @@ def _save(im, fp, tile, bufsize=0):
|
|||
e.setimage(im.im, b)
|
||||
if e.pushes_fd:
|
||||
e.setfd(fp)
|
||||
l,s = e.encode_to_pyfd()
|
||||
l, s = e.encode_to_pyfd()
|
||||
else:
|
||||
while True:
|
||||
l, s, d = e.encode(bufsize)
|
||||
|
@ -492,7 +492,7 @@ def _save(im, fp, tile, bufsize=0):
|
|||
e.setimage(im.im, b)
|
||||
if e.pushes_fd:
|
||||
e.setfd(fp)
|
||||
l,s = e.encode_to_pyfd()
|
||||
l, s = e.encode_to_pyfd()
|
||||
else:
|
||||
s = e.encode_to_file(fh, bufsize)
|
||||
if s < 0:
|
||||
|
|
|
@ -169,7 +169,7 @@ TAGS_V2 = {
|
|||
45056: ("MPFVersion", UNDEFINED, 1),
|
||||
45057: ("NumberOfImages", LONG, 1),
|
||||
45058: ("MPEntry", UNDEFINED, 1),
|
||||
45059: ("ImageUIDList", UNDEFINED, 0), # UNDONE, check
|
||||
45059: ("ImageUIDList", UNDEFINED, 0), # UNDONE, check
|
||||
45060: ("TotalFrames", LONG, 1),
|
||||
45313: ("MPIndividualNum", LONG, 1),
|
||||
45569: ("PanOrientation", LONG, 1),
|
||||
|
|
|
@ -32,6 +32,7 @@ for r in range(8):
|
|||
for b in range(4):
|
||||
PALETTE = PALETTE + (o8((r*255)//7)+o8((g*255)//7)+o8((b*255)//3))
|
||||
|
||||
|
||||
def _accept(prefix):
|
||||
return prefix[:6] == _MAGIC
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ if hasattr(sys, 'pypy_find_executable'):
|
|||
# Tested with packages at https://bitbucket.org/pypy/pypy/downloads.
|
||||
# PyPies 1.6, 2.0 do not have tkinter built in. PyPy3-2.3.1 gives an
|
||||
# OSError trying to import tkinter. Otherwise:
|
||||
try: # PyPy 5.1, 4.0.0, 2.6.1, 2.6.0
|
||||
try: # PyPy 5.1, 4.0.0, 2.6.1, 2.6.0
|
||||
TKINTER_LIB = tk.tklib_cffi.__file__
|
||||
except AttributeError:
|
||||
# PyPy3 2.4, 2.1-beta1; PyPy 2.5.1, 2.5.0, 2.4.0, 2.3, 2.2, 2.1
|
||||
|
|
|
@ -71,7 +71,6 @@ class TestFileEps(PillowTestCase):
|
|||
target = Image.open('Tests/images/pil_sample_rgb.jpg')
|
||||
self.assert_image_similar(cmyk_image, target, 10)
|
||||
|
||||
|
||||
def test_file_object(self):
|
||||
# issue 479
|
||||
image1 = Image.open(file1)
|
||||
|
|
|
@ -35,7 +35,7 @@ class TestFileJpeg2k(PillowTestCase):
|
|||
|
||||
im = Image.open('Tests/images/test-card-lossless.jp2')
|
||||
px = im.load()
|
||||
self.assertEqual(px[0,0], (0, 0, 0))
|
||||
self.assertEqual(px[0, 0], (0, 0, 0))
|
||||
self.assertEqual(im.mode, 'RGB')
|
||||
self.assertEqual(im.size, (640, 480))
|
||||
self.assertEqual(im.format, 'JPEG2000')
|
||||
|
|
|
@ -48,7 +48,7 @@ class TestImagingCoreResampleAccuracy(PillowTestCase):
|
|||
rectangle((0, 0, size[0] // 2 - 1, size[1] // 2 - 1), color)
|
||||
rectangle((size[0] // 2, size[1] // 2, size[0], size[1]), color)
|
||||
|
||||
return Image.merge(mode, [case] * len(mode))
|
||||
return Image.merge(mode, [case] * len(mode))
|
||||
|
||||
def make_sample(self, data, size):
|
||||
"""Restores a sample image from given data string which contains
|
||||
|
|
|
@ -264,6 +264,7 @@ class TestImageCms(PillowTestCase):
|
|||
# Helper function to reduce precision of tuples of floats
|
||||
# recursively and then check equality.
|
||||
power = 10 ** digits
|
||||
|
||||
def truncate_tuple(tuple_or_float):
|
||||
return tuple(
|
||||
truncate_tuple(val) if isinstance(val, tuple)
|
||||
|
|
|
@ -20,7 +20,8 @@ TEST_IMAGE_SIZE = (10, 10)
|
|||
# the repr is that of a PIL.Image. Size and shape are 1 and (), not the
|
||||
# size and shape of the array. This causes failures in several tests.
|
||||
SKIP_NUMPY_ON_PYPY = hasattr(sys, 'pypy_version_info') and (
|
||||
sys.pypy_version_info <= (5,3,1,'final',0))
|
||||
sys.pypy_version_info <= (5, 3, 1, 'final', 0))
|
||||
|
||||
|
||||
class TestNumpy(PillowTestCase):
|
||||
|
||||
|
@ -137,14 +138,14 @@ class TestNumpy(PillowTestCase):
|
|||
numpy.testing.assert_array_equal(arr, arr_back)
|
||||
|
||||
def test_save_tiff_uint16(self):
|
||||
# Tests that we're getting the pixel value in the right byte order.
|
||||
# Tests that we're getting the pixel value in the right byte order.
|
||||
pixel_value = 0x1234
|
||||
a = numpy.array([pixel_value] * TEST_IMAGE_SIZE[0] * TEST_IMAGE_SIZE[1], dtype=numpy.uint16)
|
||||
a.shape = TEST_IMAGE_SIZE
|
||||
img = Image.fromarray(a)
|
||||
|
||||
img_px = img.load()
|
||||
self.assertEqual(img_px[0,0], pixel_value)
|
||||
self.assertEqual(img_px[0, 0], pixel_value)
|
||||
|
||||
@unittest.skipIf(SKIP_NUMPY_ON_PYPY, "numpy.array(Image) is flaky on PyPy")
|
||||
def test_to_array(self):
|
||||
|
|
|
@ -64,7 +64,7 @@ def install():
|
|||
return
|
||||
|
||||
if fl_win or fl_cygwin:
|
||||
#windows barfs on multiprocessing installs
|
||||
# windows barfs on multiprocessing installs
|
||||
print("Single threaded build for windows")
|
||||
return
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user