summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
Diffstat (limited to 'coverage')
-rw-r--r--coverage/backward.py2
-rw-r--r--coverage/config.py2
-rw-r--r--coverage/data.py4
-rw-r--r--coverage/debug.py2
-rw-r--r--coverage/html.py2
-rw-r--r--coverage/misc.py4
-rw-r--r--coverage/parser.py10
-rw-r--r--coverage/results.py16
-rw-r--r--coverage/xmlreport.py4
9 files changed, 23 insertions, 23 deletions
diff --git a/coverage/backward.py b/coverage/backward.py
index 124d0253..8237d01b 100644
--- a/coverage/backward.py
+++ b/coverage/backward.py
@@ -123,7 +123,7 @@ else:
def binary_bytes(byte_values):
"""Produce a byte string with the ints from `byte_values`."""
- return "".join([chr(b) for b in byte_values])
+ return "".join(chr(b) for b in byte_values)
def byte_to_int(byte_value):
"""Turn an element of a bytes object into an int."""
diff --git a/coverage/config.py b/coverage/config.py
index 87318ff1..6223afda 100644
--- a/coverage/config.py
+++ b/coverage/config.py
@@ -25,7 +25,7 @@ class HandyConfigParser(configparser.RawConfigParser):
def dollar_replace(m):
"""Called for each $replacement."""
# Only one of the groups will have matched, just get its text.
- word = [w for w in m.groups() if w is not None][0]
+ word = next(w for w in m.groups() if w is not None)
if word == "$":
return "$"
else:
diff --git a/coverage/data.py b/coverage/data.py
index a32e20a4..61b3554f 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -101,13 +101,13 @@ class CoverageData(object):
def line_data(self):
"""Return the map from filenames to lists of line numbers executed."""
return dict(
- [(f, sorted(lmap.keys())) for f, lmap in iitems(self.lines)]
+ (f, sorted(lmap.keys())) for f, lmap in iitems(self.lines)
)
def arc_data(self):
"""Return the map from filenames to lists of line number pairs."""
return dict(
- [(f, sorted(amap.keys())) for f, amap in iitems(self.arcs)]
+ (f, sorted(amap.keys())) for f, amap in iitems(self.arcs)
)
def write_file(self, filename):
diff --git a/coverage/debug.py b/coverage/debug.py
index 104f3b1d..6908383d 100644
--- a/coverage/debug.py
+++ b/coverage/debug.py
@@ -41,7 +41,7 @@ def info_formatter(info):
nicely formatted, ready to print.
"""
- label_len = max([len(l) for l, _d in info])
+ label_len = max(len(l) for l, _d in info)
for label, data in info:
if data == []:
data = "-none-"
diff --git a/coverage/html.py b/coverage/html.py
index 956f070e..e0262998 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -270,7 +270,7 @@ class HtmlReporter(Reporter):
data("index.html"), self.template_globals
)
- self.totals = sum([f['nums'] for f in self.files])
+ self.totals = sum(f['nums'] for f in self.files)
html = index_tmpl.render({
'arcs': self.arcs,
diff --git a/coverage/misc.py b/coverage/misc.py
index 70606287..2a36d5c1 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -57,7 +57,7 @@ def format_lines(statements, lines):
def short_stack():
"""Return a string summarizing the call stack."""
stack = inspect.stack()[:0:-1]
- return "\n".join(["%30s : %s @%d" % (t[3],t[1],t[2]) for t in stack])
+ return "\n".join("%30s : %s @%d" % (t[3],t[1],t[2]) for t in stack)
def expensive(fn):
@@ -86,7 +86,7 @@ def bool_or_none(b):
def join_regex(regexes):
"""Combine a list of regexes into one that matches any of them."""
if len(regexes) > 1:
- return "|".join(["(%s)" % r for r in regexes])
+ return "|".join("(%s)" % r for r in regexes)
elif regexes:
return regexes[0]
else:
diff --git a/coverage/parser.py b/coverage/parser.py
index 0873e7af..010cd73a 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -365,7 +365,7 @@ class ByteParser(object):
"""
children = CodeObjects(self.code)
- return [ByteParser(code=c, text=self.text) for c in children]
+ return (ByteParser(code=c, text=self.text) for c in children)
def _bytes_lines(self):
"""Map byte offsets to line numbers in `code`.
@@ -409,7 +409,7 @@ class ByteParser(object):
def _block_stack_repr(self, block_stack):
"""Get a string version of `block_stack`, for debugging."""
blocks = ", ".join(
- ["(%s, %r)" % (dis.opname[b[0]], b[1]) for b in block_stack]
+ "(%s, %r)" % (dis.opname[b[0]], b[1]) for b in block_stack
)
return "[" + blocks + "]"
@@ -547,9 +547,9 @@ class ByteParser(object):
def validate_chunks(self, chunks):
"""Validate the rule that chunks have a single entrance."""
# starts is the entrances to the chunks
- starts = set([ch.byte for ch in chunks])
+ starts = set(ch.byte for ch in chunks)
for ch in chunks:
- assert all([(ex in starts or ex < 0) for ex in ch.exits])
+ assert all((ex in starts or ex < 0) for ex in ch.exits)
def _arcs(self):
"""Find the executable arcs in the code.
@@ -562,7 +562,7 @@ class ByteParser(object):
chunks = self._split_into_chunks()
# A map from byte offsets to chunks jumped into.
- byte_chunks = dict([(c.byte, c) for c in chunks])
+ byte_chunks = dict((c.byte, c) for c in chunks)
# There's always an entrance at the first chunk.
yield (-1, byte_chunks[0].line)
diff --git a/coverage/results.py b/coverage/results.py
index 7ffd66bf..bfd9e52e 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -36,9 +36,9 @@ class Analysis(object):
n_branches = self.total_branches()
mba = self.missing_branch_arcs()
n_partial_branches = sum(
- [len(v) for k,v in iitems(mba) if k not in self.missing]
+ len(v) for k,v in iitems(mba) if k not in self.missing
)
- n_missing_branches = sum([len(v) for k,v in iitems(mba)])
+ n_missing_branches = sum(len(v) for k,v in iitems(mba))
else:
n_branches = n_partial_branches = n_missing_branches = 0
self.no_branch = set()
@@ -112,18 +112,18 @@ class Analysis(object):
"""Returns a sorted list of the arcs actually executed in the code."""
executed = self.coverage.data.executed_arcs(self.filename)
m2fl = self.parser.first_line
- executed = [(m2fl(l1), m2fl(l2)) for (l1,l2) in executed]
+ executed = ((m2fl(l1), m2fl(l2)) for (l1,l2) in executed)
return sorted(executed)
def arcs_missing(self):
"""Returns a sorted list of the arcs in the code not executed."""
possible = self.arc_possibilities()
executed = self.arcs_executed()
- missing = [
+ missing = (
p for p in possible
if p not in executed
and p[0] not in self.no_branch
- ]
+ )
return sorted(missing)
def arcs_unpredicted(self):
@@ -133,11 +133,11 @@ class Analysis(object):
# Exclude arcs here which connect a line to itself. They can occur
# in executed data in some cases. This is where they can cause
# trouble, and here is where it's the least burden to remove them.
- unpredicted = [
+ unpredicted = (
e for e in executed
if e not in possible
and e[0] != e[1]
- ]
+ )
return sorted(unpredicted)
def branch_lines(self):
@@ -148,7 +148,7 @@ class Analysis(object):
def total_branches(self):
"""How many total branches are there?"""
exit_counts = self.parser.exit_counts()
- return sum([count for count in exit_counts.values() if count > 1])
+ return sum(count for count in exit_counts.values() if count > 1)
def missing_branch_arcs(self):
"""Return arcs that weren't executed from branch lines.
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py
index 1abfdefb..d4b102fa 100644
--- a/coverage/xmlreport.py
+++ b/coverage/xmlreport.py
@@ -137,8 +137,8 @@ class XmlReporter(Reporter):
class_hits = class_lines - len(analysis.missing)
if self.arcs:
- class_branches = sum([t for t,k in branch_stats.values()])
- missing_branches = sum([t-k for t,k in branch_stats.values()])
+ class_branches = sum(t for t, k in branch_stats.values())
+ missing_branches = sum(t - k for t, k in branch_stats.values())
class_br_hits = class_branches - missing_branches
else:
class_branches = 0.0