flake8: F401 imported but unused

This commit is contained in:
Hugo 2018-10-18 19:46:20 +03:00
parent eb9aee7048
commit 91da8ff31d
2 changed files with 13 additions and 4 deletions

View File

@ -5,7 +5,7 @@ from __future__ import print_function
import sys import sys
import os import os
from PIL import Image, ImageDraw, ImageFilter, ImageMath from PIL import Image
from PIL import features from PIL import features
try: try:
@ -26,6 +26,7 @@ def testimage():
""" """
PIL lets you create in-memory images with various pixel types: PIL lets you create in-memory images with various pixel types:
>>> from PIL import Image, ImageDraw, ImageFilter, ImageMath
>>> im = Image.new("1", (128, 128)) # monochrome >>> im = Image.new("1", (128, 128)) # monochrome
>>> _info(im) >>> _info(im)
(None, '1', (128, 128)) (None, '1', (128, 128))

View File

@ -28,12 +28,15 @@
# PILLOW_VERSION is deprecated and will be removed after that. # PILLOW_VERSION is deprecated and will be removed after that.
# Use __version__ instead. # Use __version__ instead.
from . import VERSION, PILLOW_VERSION, __version__, _plugins from . import VERSION, PILLOW_VERSION, __version__, _plugins
assert VERSION
assert PILLOW_VERSION
from ._util import py3 from ._util import py3
import logging import logging
import warnings import warnings
import math import math
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -134,9 +137,8 @@ except ImportError:
USE_CFFI_ACCESS = hasattr(sys, 'pypy_version_info') USE_CFFI_ACCESS = hasattr(sys, 'pypy_version_info')
try: try:
import cffi import cffi
HAS_CFFI = True
except ImportError: except ImportError:
HAS_CFFI = False cffi = None
try: try:
from pathlib import Path from pathlib import Path
@ -376,26 +378,32 @@ def preinit():
try: try:
from . import BmpImagePlugin from . import BmpImagePlugin
assert BmpImagePlugin
except ImportError: except ImportError:
pass pass
try: try:
from . import GifImagePlugin from . import GifImagePlugin
assert GifImagePlugin
except ImportError: except ImportError:
pass pass
try: try:
from . import JpegImagePlugin from . import JpegImagePlugin
assert JpegImagePlugin
except ImportError: except ImportError:
pass pass
try: try:
from . import PpmImagePlugin from . import PpmImagePlugin
assert PpmImagePlugin
except ImportError: except ImportError:
pass pass
try: try:
from . import PngImagePlugin from . import PngImagePlugin
assert PngImagePlugin
except ImportError: except ImportError:
pass pass
# try: # try:
# import TiffImagePlugin # import TiffImagePlugin
# assert TiffImagePlugin
# except ImportError: # except ImportError:
# pass # pass
@ -833,7 +841,7 @@ class Image(object):
self.palette.mode = "RGBA" self.palette.mode = "RGBA"
if self.im: if self.im:
if HAS_CFFI and USE_CFFI_ACCESS: if cffi and USE_CFFI_ACCESS:
if self.pyaccess: if self.pyaccess:
return self.pyaccess return self.pyaccess
from . import PyAccess from . import PyAccess