diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-20 07:38:41 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-20 07:38:41 -0400 |
commit | 0a3a4218d1555d33f7c0e5b3db2ed561ba9e29b3 (patch) | |
tree | 352f243dbd0c8e6888835b00e46e20c7f19cceba /coverage/parser.py | |
parent | 5aa8f70d4ee8b3d40d5caf69c42c67d4fd4f0118 (diff) | |
download | python-coveragepy-0a3a4218d1555d33f7c0e5b3db2ed561ba9e29b3.tar.gz |
Now I can use collections.defaultdict
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index 010cd73..6332f63 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -1,6 +1,6 @@ """Code parsing for Coverage.""" -import dis, re, sys, token, tokenize +import collections, dis, re, sys, token, tokenize from coverage.backward import StringIO from coverage.backward import open_source, range # pylint: disable=W0622 @@ -242,7 +242,7 @@ class CodeParser(object): """ excluded_lines = self.first_lines(self.excluded) - exit_counts = {} + exit_counts = collections.defaultdict(int) for l1, l2 in self.arcs(): if l1 < 0: # Don't ever report -1 as a line number @@ -253,8 +253,6 @@ class CodeParser(object): if l2 in excluded_lines: # Arcs to excluded lines shouldn't count. continue - if l1 not in exit_counts: - exit_counts[l1] = 0 exit_counts[l1] += 1 # Class definitions have one extra exit, so remove one for each: |