mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge pull request #3467 from hugovk/lint-can-fail
CI: Allow lint job to fail
This commit is contained in:
commit
3ed5dcc928
|
@ -82,7 +82,9 @@ before_script:
|
|||
|
||||
script:
|
||||
- |
|
||||
if [ "$DOCKER" == "" ] && [ "$LINT" == "" ]; then
|
||||
if [ "$LINT" == "true" ]; then
|
||||
flake8 --statistics --count
|
||||
elif [ "$DOCKER" == "" ]; then
|
||||
.travis/script.sh
|
||||
elif [ "$DOCKER" ]; then
|
||||
# the Pillow user in the docker container is UID 1000
|
||||
|
@ -92,8 +94,6 @@ script:
|
|||
|
||||
after_success:
|
||||
- |
|
||||
if [ "$LINT" == "true" ]; then
|
||||
flake8 --statistics --count
|
||||
else
|
||||
if [ "$LINT" == "" ]; then
|
||||
.travis/after_success.sh
|
||||
fi
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
from __future__ import print_function
|
||||
import base64
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
# create font data chunk for embedding
|
||||
|
|
|
@ -84,7 +84,7 @@ class PillowTestCase(unittest.TestCase):
|
|||
self.assertTrue(
|
||||
all(x == y for x, y in zip(a, b)),
|
||||
msg or "got %s, expected %s" % (a, b))
|
||||
except:
|
||||
except Exception:
|
||||
self.assertEqual(a, b, msg)
|
||||
|
||||
def assert_image(self, im, mode, size, msg=None):
|
||||
|
@ -149,7 +149,7 @@ class PillowTestCase(unittest.TestCase):
|
|||
try:
|
||||
url = test_image_results.upload(a, b)
|
||||
logger.error("Url for test images: %s" % url)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
raise e
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ A = Image.new("L", (1, 1), 1)
|
|||
B = Image.new("L", (1, 1), 2)
|
||||
Z = Image.new("L", (1, 1), 0) # Z for zero
|
||||
F = Image.new("F", (1, 1), 3)
|
||||
I = Image.new("I", (1, 1), 4)
|
||||
I = Image.new("I", (1, 1), 4) # noqa: E741
|
||||
|
||||
A2 = A.resize((2, 2))
|
||||
B2 = B.resize((2, 2))
|
||||
|
|
|
@ -43,7 +43,7 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
|
|||
pool = Pool(MAX_PROCS)
|
||||
try:
|
||||
print("Building using %d processes" % pool._processes)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
arr = [(self, obj, build, cc_args, extra_postargs, pp_opts)
|
||||
for obj in objects]
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
[aliases]
|
||||
test=pytest
|
||||
|
||||
[metadata]
|
||||
license_file = LICENSE
|
||||
|
||||
[tool:pytest]
|
||||
addopts = -vx Tests
|
||||
|
||||
[flake8]
|
||||
max-line-length = 88
|
||||
|
|
|
@ -975,7 +975,7 @@ class Image(object):
|
|||
if isinstance(t, tuple):
|
||||
try:
|
||||
t = trns_im.palette.getcolor(t)
|
||||
except:
|
||||
except Exception:
|
||||
raise ValueError("Couldn't allocate a palette "
|
||||
"color for transparency")
|
||||
trns_im.putpixel((0, 0), t)
|
||||
|
@ -1012,7 +1012,7 @@ class Image(object):
|
|||
if trns is not None:
|
||||
try:
|
||||
new.info['transparency'] = new.palette.getcolor(trns)
|
||||
except:
|
||||
except Exception:
|
||||
# if we can't make a transparent color, don't leave the old
|
||||
# transparency hanging around to mess us up.
|
||||
del(new.info['transparency'])
|
||||
|
@ -1042,7 +1042,7 @@ class Image(object):
|
|||
if new_im.mode == 'P':
|
||||
try:
|
||||
new_im.info['transparency'] = new_im.palette.getcolor(trns)
|
||||
except:
|
||||
except Exception:
|
||||
del(new_im.info['transparency'])
|
||||
warnings.warn("Couldn't allocate palette entry " +
|
||||
"for transparency")
|
||||
|
|
|
@ -197,7 +197,7 @@ class UnsharpMask(MultibandFilter):
|
|||
|
||||
.. _digital unsharp masking: https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking
|
||||
|
||||
"""
|
||||
""" # noqa: E501
|
||||
name = "UnsharpMask"
|
||||
|
||||
def __init__(self, radius=2, percent=150, threshold=3):
|
||||
|
|
|
@ -72,7 +72,7 @@ class ImageFont(object):
|
|||
try:
|
||||
fullname = os.path.splitext(filename)[0] + ext
|
||||
image = Image.open(fullname)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
if image and image.mode in ("1", "L"):
|
||||
|
|
|
@ -140,7 +140,7 @@ def _toqclass_helper(im):
|
|||
if py3:
|
||||
im = str(im.toUtf8(), "utf-8")
|
||||
else:
|
||||
im = unicode(im.toUtf8(), "utf-8")
|
||||
im = unicode(im.toUtf8(), "utf-8") # noqa: F821
|
||||
if isPath(im):
|
||||
im = Image.open(im)
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ class PhotoImage(object):
|
|||
self.__photo.name = None
|
||||
try:
|
||||
self.__photo.tk.call("image", "delete", name)
|
||||
except:
|
||||
except Exception:
|
||||
pass # ignore internal errors
|
||||
|
||||
def __str__(self):
|
||||
|
@ -244,7 +244,7 @@ class BitmapImage(object):
|
|||
self.__photo.name = None
|
||||
try:
|
||||
self.__photo.tk.call("image", "delete", name)
|
||||
except:
|
||||
except Exception:
|
||||
pass # ignore internal errors
|
||||
|
||||
def width(self):
|
||||
|
|
|
@ -181,14 +181,14 @@ class Jpeg2KImageFile(ImageFile.ImageFile):
|
|||
try:
|
||||
fd = self.fp.fileno()
|
||||
length = os.fstat(fd).st_size
|
||||
except:
|
||||
except Exception:
|
||||
fd = -1
|
||||
try:
|
||||
pos = self.fp.tell()
|
||||
self.fp.seek(0, 2)
|
||||
length = self.fp.tell()
|
||||
self.fp.seek(pos, 0)
|
||||
except:
|
||||
except Exception:
|
||||
length = -1
|
||||
|
||||
self.tile = [('jpeg2k', (0, 0) + self.size, 0,
|
||||
|
@ -250,7 +250,7 @@ def _save(im, fp, filename):
|
|||
if hasattr(fp, "fileno"):
|
||||
try:
|
||||
fd = fp.fileno()
|
||||
except:
|
||||
except Exception:
|
||||
fd = -1
|
||||
|
||||
im.encoderconfig = (
|
||||
|
|
|
@ -75,7 +75,7 @@ def APP(self, marker):
|
|||
try:
|
||||
jfif_unit = i8(s[7])
|
||||
jfif_density = i16(s, 8), i16(s, 10)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
if jfif_unit == 1:
|
||||
|
@ -107,7 +107,7 @@ def APP(self, marker):
|
|||
# extract Adobe custom properties
|
||||
try:
|
||||
adobe_transform = i8(s[1])
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
self.info["adobe_transform"] = adobe_transform
|
||||
|
@ -441,7 +441,7 @@ def _fixup_dict(src_dict):
|
|||
try:
|
||||
if len(value) == 1 and not isinstance(value, dict):
|
||||
return value[0]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return value
|
||||
|
||||
|
@ -512,7 +512,7 @@ def _getmp(self):
|
|||
info = TiffImagePlugin.ImageFileDirectory_v2(head)
|
||||
info.load(file_contents)
|
||||
mp = dict(info)
|
||||
except:
|
||||
except Exception:
|
||||
raise SyntaxError("malformed MP Index (unreadable directory)")
|
||||
# it's an error not to have a number of images
|
||||
try:
|
||||
|
|
|
@ -373,7 +373,7 @@ def pdf_repr(x):
|
|||
elif isinstance(x, list):
|
||||
return bytes(PdfArray(x))
|
||||
elif ((py3 and isinstance(x, str)) or
|
||||
(not py3 and isinstance(x, unicode))):
|
||||
(not py3 and isinstance(x, unicode))): # noqa: F821
|
||||
return pdf_repr(encode_text(x))
|
||||
elif isinstance(x, bytes):
|
||||
# XXX escape more chars? handle binary garbage
|
||||
|
|
|
@ -340,7 +340,7 @@ class PngStream(ChunkStream):
|
|||
self.im_size = i32(s), i32(s[4:])
|
||||
try:
|
||||
self.im_mode, self.im_rawmode = _MODES[(i8(s[8]), i8(s[9]))]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if i8(s[12]):
|
||||
self.im_info["interlace"] = 1
|
||||
|
|
|
@ -214,7 +214,7 @@ class _PyAccessI16_L(PyAccess):
|
|||
except TypeError:
|
||||
color = min(color[0], 65535)
|
||||
|
||||
pixel.l = color & 0xFF
|
||||
pixel.l = color & 0xFF # noqa: E741
|
||||
pixel.r = color >> 8
|
||||
|
||||
|
||||
|
@ -231,10 +231,10 @@ class _PyAccessI16_B(PyAccess):
|
|||
pixel = self.pixels[y][x]
|
||||
try:
|
||||
color = min(color, 65535)
|
||||
except:
|
||||
except Exception:
|
||||
color = min(color[0], 65535)
|
||||
|
||||
pixel.l = color >> 8
|
||||
pixel.l = color >> 8 # noqa: E741
|
||||
pixel.r = color & 0xFF
|
||||
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ def loadImageSeries(filelist=None):
|
|||
continue
|
||||
try:
|
||||
im = Image.open(img).convert2byte()
|
||||
except:
|
||||
except Exception:
|
||||
if not isSpiderImage(img):
|
||||
print(img + " is not a Spider image file")
|
||||
continue
|
||||
|
|
|
@ -541,7 +541,7 @@ class ImageFileDirectory_v2(MutableMapping):
|
|||
def _setitem(self, tag, value, legacy_api):
|
||||
basetypes = (Number, bytes, str)
|
||||
if not py3:
|
||||
basetypes += unicode,
|
||||
basetypes += unicode, # noqa: F821
|
||||
|
||||
info = TiffTags.lookup(tag)
|
||||
values = [value] if isinstance(value, basetypes) else value
|
||||
|
@ -594,7 +594,8 @@ class ImageFileDirectory_v2(MutableMapping):
|
|||
except ValueError:
|
||||
# We've got a builtin tag with 1 expected entry
|
||||
warnings.warn(
|
||||
"Metadata Warning, tag %s had too many entries: %s, expected 1" % (
|
||||
"Metadata Warning, tag %s had too many entries: "
|
||||
"%s, expected 1" % (
|
||||
tag, len(values)))
|
||||
dest[tag] = values[0]
|
||||
|
||||
|
@ -622,13 +623,13 @@ class ImageFileDirectory_v2(MutableMapping):
|
|||
from .TiffTags import TYPES
|
||||
if func.__name__.startswith("load_"):
|
||||
TYPES[idx] = func.__name__[5:].replace("_", " ")
|
||||
_load_dispatch[idx] = size, func
|
||||
_load_dispatch[idx] = size, func # noqa: F821
|
||||
return func
|
||||
return decorator
|
||||
|
||||
def _register_writer(idx):
|
||||
def decorator(func):
|
||||
_write_dispatch[idx] = func
|
||||
_write_dispatch[idx] = func # noqa: F821
|
||||
return func
|
||||
return decorator
|
||||
|
||||
|
@ -637,9 +638,9 @@ class ImageFileDirectory_v2(MutableMapping):
|
|||
idx, fmt, name = idx_fmt_name
|
||||
TYPES[idx] = name
|
||||
size = struct.calcsize("=" + fmt)
|
||||
_load_dispatch[idx] = size, lambda self, data, legacy_api=True: (
|
||||
_load_dispatch[idx] = size, lambda self, data, legacy_api=True: ( # noqa: F821
|
||||
self._unpack("{}{}".format(len(data) // size, fmt), data))
|
||||
_write_dispatch[idx] = lambda self, *values: (
|
||||
_write_dispatch[idx] = lambda self, *values: ( # noqa: F821
|
||||
b"".join(self._pack(fmt, value) for value in values))
|
||||
|
||||
list(map(_register_basic,
|
||||
|
@ -1420,7 +1421,7 @@ def _save(im, fp, filename):
|
|||
ifd[key] = info.get(key)
|
||||
try:
|
||||
ifd.tagtype[key] = info.tagtype[key]
|
||||
except:
|
||||
except Exception:
|
||||
pass # might not be an IFD, Might not have populated type
|
||||
|
||||
# additions written by Greg Couch, gregc@cgl.ucsf.edu
|
||||
|
@ -1514,7 +1515,7 @@ def _save(im, fp, filename):
|
|||
if tag not in TiffTags.LIBTIFF_CORE:
|
||||
continue
|
||||
if tag not in atts and tag not in blocklist:
|
||||
if isinstance(value, str if py3 else unicode):
|
||||
if isinstance(value, str if py3 else unicode): # noqa: F821
|
||||
atts[tag] = value.encode('ascii', 'replace') + b"\0"
|
||||
elif isinstance(value, IFDRational):
|
||||
atts[tag] = float(value)
|
||||
|
|
|
@ -11,10 +11,10 @@ if py3:
|
|||
return isinstance(f, (bytes, str))
|
||||
else:
|
||||
def isStringType(t):
|
||||
return isinstance(t, basestring)
|
||||
return isinstance(t, basestring) # noqa: F821
|
||||
|
||||
def isPath(f):
|
||||
return isinstance(f, basestring)
|
||||
return isinstance(f, basestring) # noqa: F821
|
||||
|
||||
|
||||
# Checks if an object is a string, and that it points to a directory.
|
||||
|
|
|
@ -112,14 +112,14 @@ call %(python_path)s\%(executable)s setup.py %(imaging_libs)s %%BLDOPT%%
|
|||
endlocal
|
||||
|
||||
endlocal
|
||||
"""
|
||||
""" # noqa: E501
|
||||
return script % args
|
||||
|
||||
|
||||
def clean():
|
||||
try:
|
||||
shutil.rmtree('../build')
|
||||
except:
|
||||
except Exception:
|
||||
# could already be removed
|
||||
pass
|
||||
run_script(('virtualenvs', setup_vms()))
|
||||
|
|
|
@ -104,7 +104,7 @@ def setup_compiler(compiler):
|
|||
return r"""setlocal EnableDelayedExpansion
|
||||
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
|
||||
set INCLIB=%%INCLIB%%\%(inc_dir)s
|
||||
""" % compiler
|
||||
""" % compiler # noqa: E501
|
||||
|
||||
|
||||
def end_compiler():
|
||||
|
@ -202,7 +202,7 @@ rd /S /Q %%FREETYPE%%\objs
|
|||
xcopy /Y /E /Q %%FREETYPE%%\include %%INCLIB%%
|
||||
copy /Y /B %%FREETYPE%%\objs\vc%(vc_version)s\%(platform)s\*.lib %%INCLIB%%\freetype.lib
|
||||
endlocal
|
||||
""" % compiler
|
||||
""" % compiler # noqa: E501
|
||||
|
||||
|
||||
def msbuild_freetype_70(compiler):
|
||||
|
@ -217,7 +217,7 @@ xcopy /Y /E /Q %%FREETYPE%%\include %%INCLIB%%
|
|||
xcopy /Y /E /Q %%FREETYPE%%\objs\win32\vc%(vc_version)s %%INCLIB%%
|
||||
copy /Y /B %%FREETYPE%%\objs\win32\vc%(vc_version)s\*.lib %%INCLIB%%\freetype.lib
|
||||
endlocal
|
||||
""" % compiler
|
||||
""" % compiler # noqa: E501
|
||||
|
||||
|
||||
def build_lcms2(compiler):
|
||||
|
@ -237,12 +237,12 @@ rem Build lcms2
|
|||
setlocal
|
||||
rd /S /Q %%LCMS%%\Lib
|
||||
rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=Win32 /m
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=Win32 /m
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:lcms2_static /p:Configuration="Release" /p:Platform=Win32 /m
|
||||
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
|
||||
copy /Y /B %%LCMS%%\Projects\VC%(vc_version)s\Release\*.lib %%INCLIB%%
|
||||
endlocal
|
||||
""" % compiler
|
||||
""" % compiler # noqa: E501
|
||||
|
||||
|
||||
def build_lcms_71(compiler):
|
||||
|
@ -251,12 +251,12 @@ rem Build lcms2
|
|||
setlocal
|
||||
rd /S /Q %%LCMS%%\Lib
|
||||
rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=%(platform)s /m
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:lcms2_static /p:Configuration="Release" /p:Platform=%(platform)s /m
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=%(platform)s /m
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:lcms2_static /p:Configuration="Release" /p:Platform=%(platform)s /m
|
||||
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
|
||||
copy /Y /B %%LCMS%%\Lib\MS\*.lib %%INCLIB%%
|
||||
endlocal
|
||||
""" % compiler
|
||||
""" % compiler # noqa: E501
|
||||
|
||||
|
||||
def add_compiler(compiler, bit):
|
||||
|
|
|
@ -34,7 +34,7 @@ libs = {
|
|||
'dir': 'tiff-4.0.10',
|
||||
},
|
||||
'freetype': {
|
||||
'url': 'https://download.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz',
|
||||
'url': 'https://download.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz', # noqa: E501
|
||||
'filename': PILLOW_DEPENDS_DIR + 'freetype-2.9.1.tar.gz',
|
||||
'dir': 'freetype-2.9.1',
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user