Merge pull request #2551 from jdufresne/keys

Remove unnecessary calls to dict.keys()
This commit is contained in:
wiredfool 2017-06-13 13:12:48 +01:00 committed by GitHub
commit c16ba722f2
8 changed files with 9 additions and 9 deletions

View File

@ -176,8 +176,8 @@ class IcoFile(object):
# figure out where AND mask image starts
mode = a[0]
bpp = 8
for k in BmpImagePlugin.BIT2MODE.keys():
if mode == BmpImagePlugin.BIT2MODE[k][1]:
for k, v in BmpImagePlugin.BIT2MODE.items():
if mode == v[1]:
bpp = k
break

View File

@ -274,7 +274,7 @@ def _conv_type_shape(im):
return shape+(extra,), typ
MODES = sorted(_MODEINFO.keys())
MODES = sorted(_MODEINFO)
# raw modes that may be memory mapped. NOTE: if you change this, you
# may have to modify the stride calculation in map.c too!

View File

@ -95,7 +95,7 @@ class IptcImageFile(ImageFile.ImageFile):
tagdata = self.fp.read(size)
else:
tagdata = None
if tag in list(self.info.keys()):
if tag in self.info:
if isinstance(self.info[tag], list):
self.info[tag].append(tagdata)
else:

View File

@ -439,7 +439,7 @@ class TestFileJpeg(PillowTestCase):
def test_no_duplicate_0x1001_tag(self):
# Arrange
from PIL import ExifTags
tag_ids = dict(zip(ExifTags.TAGS.values(), ExifTags.TAGS.keys()))
tag_ids = {v: k for k, v in ExifTags.TAGS.items()}
# Assert
self.assertEqual(tag_ids['RelatedImageWidth'], 0x1001)

View File

@ -189,7 +189,7 @@ class TestFileLibTiff(LibTiffTestCase):
# Exclude ones that have special meaning
# that we're already testing them
im = Image.open('Tests/images/hopper_g4.tif')
for tag in im.tag_v2.keys():
for tag in im.tag_v2:
try:
del(core_items[tag])
except:

View File

@ -119,7 +119,7 @@ class TestImageColor(PillowTestCase):
# look for rounding errors (based on code by Tim Hatch)
def test_rounding_errors(self):
for color in list(ImageColor.colormap.keys()):
for color in ImageColor.colormap:
expected = Image.new(
"RGB", (1, 1), color).convert("L").getpixel((0, 0))
actual = ImageColor.getcolor(color, 'L')

View File

@ -12,7 +12,7 @@ from config import (compilers, compiler_from_env, pythons, pyversion_from_env,
def setup_vms():
ret = []
for py in pythons.keys():
for py in pythons:
for arch in ('', X64_EXT):
ret.append("virtualenv -p c:/Python%s%s/python.exe --clear %s%s%s"
% (py, arch, VIRT_BASE, py, arch))

View File

@ -116,7 +116,7 @@ def pyversion_from_env():
py = os.environ['PYTHON']
py_version = '27'
for k in pythons.keys():
for k in pythons:
if k in py:
py_version = k
break