mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
some pylint warnings
Fixed some pylint issues
This commit is contained in:
parent
f63cc582b7
commit
69baeccf2e
|
@ -208,7 +208,6 @@ class PillowLeakTestCase:
|
||||||
# ru_maxrss
|
# ru_maxrss
|
||||||
# This is the maximum resident set size utilized (in bytes).
|
# This is the maximum resident set size utilized (in bytes).
|
||||||
return mem / 1024 # Kb
|
return mem / 1024 # Kb
|
||||||
else:
|
|
||||||
# linux
|
# linux
|
||||||
# man 2 getrusage
|
# man 2 getrusage
|
||||||
# ru_maxrss (since Linux 2.6.32)
|
# ru_maxrss (since Linux 2.6.32)
|
||||||
|
@ -285,7 +284,7 @@ def magick_command():
|
||||||
|
|
||||||
if imagemagick and shutil.which(imagemagick[0]):
|
if imagemagick and shutil.which(imagemagick[0]):
|
||||||
return imagemagick
|
return imagemagick
|
||||||
elif graphicsmagick and shutil.which(graphicsmagick[0]):
|
if graphicsmagick and shutil.which(graphicsmagick[0]):
|
||||||
return graphicsmagick
|
return graphicsmagick
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ from .helper import (
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import defusedxml.ElementTree as ElementTree
|
from defusedxml import ElementTree
|
||||||
except ImportError:
|
except ImportError:
|
||||||
ElementTree = None
|
ElementTree = None
|
||||||
|
|
||||||
|
|
|
@ -934,7 +934,7 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
im.save(out, exif=tags, compression=compression)
|
im.save(out, exif=tags, compression=compression)
|
||||||
|
|
||||||
with Image.open(out) as reloaded:
|
with Image.open(out) as reloaded:
|
||||||
for tag in tags.keys():
|
for tag in tags:
|
||||||
assert tag not in reloaded.getexif()
|
assert tag not in reloaded.getexif()
|
||||||
|
|
||||||
def test_old_style_jpeg(self):
|
def test_old_style_jpeg(self):
|
||||||
|
|
|
@ -20,7 +20,7 @@ from .helper import (
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import defusedxml.ElementTree as ElementTree
|
from defusedxml import ElementTree
|
||||||
except ImportError:
|
except ImportError:
|
||||||
ElementTree = None
|
ElementTree = None
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ def test_header_token_too_long(tmp_path):
|
||||||
def test_truncated_file(tmp_path):
|
def test_truncated_file(tmp_path):
|
||||||
# Test EOF in header
|
# Test EOF in header
|
||||||
path = str(tmp_path / "temp.pgm")
|
path = str(tmp_path / "temp.pgm")
|
||||||
with open(path, "w") as f:
|
with open(path, "w", encoding='utf-8') as f:
|
||||||
f.write("P6")
|
f.write("P6")
|
||||||
|
|
||||||
with pytest.raises(ValueError) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
|
@ -259,7 +259,7 @@ def test_truncated_file(tmp_path):
|
||||||
@pytest.mark.parametrize("maxval", (0, 65536))
|
@pytest.mark.parametrize("maxval", (0, 65536))
|
||||||
def test_invalid_maxval(maxval, tmp_path):
|
def test_invalid_maxval(maxval, tmp_path):
|
||||||
path = str(tmp_path / "temp.ppm")
|
path = str(tmp_path / "temp.ppm")
|
||||||
with open(path, "w") as f:
|
with open(path, "w", encoding='utf-8') as f:
|
||||||
f.write("P6\n3 1 " + str(maxval))
|
f.write("P6\n3 1 " + str(maxval))
|
||||||
|
|
||||||
with pytest.raises(ValueError) as e:
|
with pytest.raises(ValueError) as e:
|
||||||
|
@ -283,12 +283,12 @@ def test_neg_ppm():
|
||||||
def test_mimetypes(tmp_path):
|
def test_mimetypes(tmp_path):
|
||||||
path = str(tmp_path / "temp.pgm")
|
path = str(tmp_path / "temp.pgm")
|
||||||
|
|
||||||
with open(path, "w") as f:
|
with open(path, "w", encoding='utf-8') as f:
|
||||||
f.write("P4\n128 128\n255")
|
f.write("P4\n128 128\n255")
|
||||||
with Image.open(path) as im:
|
with Image.open(path) as im:
|
||||||
assert im.get_format_mimetype() == "image/x-portable-bitmap"
|
assert im.get_format_mimetype() == "image/x-portable-bitmap"
|
||||||
|
|
||||||
with open(path, "w") as f:
|
with open(path, "w", encoding='utf-8') as f:
|
||||||
f.write("PyCMYK\n128 128\n255")
|
f.write("PyCMYK\n128 128\n255")
|
||||||
with Image.open(path) as im:
|
with Image.open(path) as im:
|
||||||
assert im.get_format_mimetype() == "image/x-portable-anymap"
|
assert im.get_format_mimetype() == "image/x-portable-anymap"
|
||||||
|
|
|
@ -18,7 +18,7 @@ from .helper import (
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import defusedxml.ElementTree as ElementTree
|
from defusedxml import ElementTree
|
||||||
except ImportError:
|
except ImportError:
|
||||||
ElementTree = None
|
ElementTree = None
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,6 @@ class TestImage:
|
||||||
im.size = (3, 4)
|
im.size = (3, 4)
|
||||||
|
|
||||||
def test_invalid_image(self):
|
def test_invalid_image(self):
|
||||||
import io
|
|
||||||
|
|
||||||
im = io.BytesIO(b"")
|
im = io.BytesIO(b"")
|
||||||
with pytest.raises(UnidentifiedImageError):
|
with pytest.raises(UnidentifiedImageError):
|
||||||
|
@ -699,15 +698,15 @@ class TestImage:
|
||||||
def test_empty_exif(self):
|
def test_empty_exif(self):
|
||||||
with Image.open("Tests/images/exif.png") as im:
|
with Image.open("Tests/images/exif.png") as im:
|
||||||
exif = im.getexif()
|
exif = im.getexif()
|
||||||
assert dict(exif) != {}
|
assert dict(exif)
|
||||||
|
|
||||||
# Test that exif data is cleared after another load
|
# Test that exif data is cleared after another load
|
||||||
exif.load(None)
|
exif.load(None)
|
||||||
assert dict(exif) == {}
|
assert not dict(exif)
|
||||||
|
|
||||||
# Test loading just the EXIF header
|
# Test loading just the EXIF header
|
||||||
exif.load(b"Exif\x00\x00")
|
exif.load(b"Exif\x00\x00")
|
||||||
assert dict(exif) == {}
|
assert not dict(exif)
|
||||||
|
|
||||||
@mark_if_feature_version(
|
@mark_if_feature_version(
|
||||||
pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
|
pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
|
||||||
|
|
|
@ -131,7 +131,6 @@ class TestImageGetPixel(AccessTest):
|
||||||
bands = Image.getmodebands(mode)
|
bands = Image.getmodebands(mode)
|
||||||
if bands == 1:
|
if bands == 1:
|
||||||
return 1
|
return 1
|
||||||
else:
|
|
||||||
return tuple(range(1, bands + 1))
|
return tuple(range(1, bands + 1))
|
||||||
|
|
||||||
def check(self, mode, c=None):
|
def check(self, mode, c=None):
|
||||||
|
@ -415,7 +414,7 @@ class TestEmbeddable:
|
||||||
def test_embeddable(self):
|
def test_embeddable(self):
|
||||||
import ctypes
|
import ctypes
|
||||||
|
|
||||||
with open("embed_pil.c", "w") as fh:
|
with open("embed_pil.c", "w", encoding='utf-8') as fh:
|
||||||
fh.write(
|
fh.write(
|
||||||
"""
|
"""
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
|
@ -6,7 +6,6 @@ from PIL import Image, ImageMath
|
||||||
def pixel(im):
|
def pixel(im):
|
||||||
if hasattr(im, "im"):
|
if hasattr(im, "im"):
|
||||||
return f"{im.mode} {repr(im.getpixel((0, 0)))}"
|
return f"{im.mode} {repr(im.getpixel((0, 0)))}"
|
||||||
else:
|
|
||||||
if isinstance(im, int):
|
if isinstance(im, int):
|
||||||
return int(im) # hack to deal with booleans
|
return int(im) # hack to deal with booleans
|
||||||
print(im)
|
print(im)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -23,7 +23,7 @@ from setuptools.command.build_ext import build_ext
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
version_file = "src/PIL/_version.py"
|
version_file = "src/PIL/_version.py"
|
||||||
with open(version_file) as f:
|
with open(version_file, encoding="utf-8") as f:
|
||||||
exec(compile(f.read(), version_file, "exec"))
|
exec(compile(f.read(), version_file, "exec"))
|
||||||
return locals()["__version__"]
|
return locals()["__version__"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user