Skip to content

Commit ac563ed

Browse files
authored
Replace 'counter' function with 'collection.Counter'
Closes #813
1 parent c68ed1b commit ac563ed

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

pyflakes/checker.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,6 @@ def __missing__(self, node_class):
165165
return fields
166166

167167

168-
def counter(items):
169-
"""
170-
Simplest required implementation of collections.Counter. Required as 2.6
171-
does not have Counter in collections.
172-
"""
173-
results = {}
174-
for item in items:
175-
results[item] = results.get(item, 0) + 1
176-
return results
177-
178-
179168
def iter_child_nodes(node, omit=None, _fields_order=_FieldsOrder()):
180169
"""
181170
Yield all direct child nodes of *node*, that is, all fields that
@@ -1777,7 +1766,7 @@ def DICT(self, node):
17771766
convert_to_value(key) for key in node.keys
17781767
]
17791768

1780-
key_counts = counter(keys)
1769+
key_counts = collections.Counter(keys)
17811770
duplicate_keys = [
17821771
key for key, count in key_counts.items()
17831772
if count > 1
@@ -1786,7 +1775,7 @@ def DICT(self, node):
17861775
for key in duplicate_keys:
17871776
key_indices = [i for i, i_key in enumerate(keys) if i_key == key]
17881777

1789-
values = counter(
1778+
values = collections.Counter(
17901779
convert_to_value(node.values[index])
17911780
for index in key_indices
17921781
)

0 commit comments

Comments
 (0)