Skip to content

Commit 4a04655

Browse files
committed
Update the dict_six fixer to support dict.view*() properly thanks to six 1.9.
1 parent f3b656a commit 4a04655

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Unreleased
2+
==========
3+
4+
Changes since 0.4:
5+
* Updated the ``dict_six`` fixer to support ``six.viewitems()`` and friends.
6+
17
Version 0.4
28
===========
39

docs/fixers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ version of ``six`` is installed.
6565
6666
list(x.values())
6767
six.itervalues(x)
68-
six.itervalues(x)
68+
six.viewvalues(x)
6969
7070
Care is taken to only call ``list()`` when not in an iterating context
7171
(e.g. not the iterable for a ``for`` loop).
@@ -168,7 +168,7 @@ version of ``six`` is installed.
168168
import six
169169
class Foo(six.with_metaclass(Meta)):
170170
pass
171-
171+
172172
.. seealso::
173173
:func:`six.with_metaclass`
174174

libmodernize/fixes/fix_dict_six.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
class FixDictSix(fix_dict.FixDict):
1111

1212
def transform_iter(self, method_name, node, base):
13-
"""Call six.iteritems() and friends."""
14-
if method_name.startswith(u'view'):
15-
method_name = u'iter' + method_name[4:]
13+
"""Call six.(iter|view)items() and friends."""
1614
libmodernize.touch_import(None, u'six', node)
1715
new_node = [n.clone() for n in base]
1816
new_node[0].prefix = u''

tests/test_fix_dict_six.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
""", """\
1919
from __future__ import absolute_import
2020
import six
21-
six.iter{type}(x)
21+
six.view{type}(x)
2222
""")
2323

2424
DICT_PLAIN = ("""\

0 commit comments

Comments
 (0)