diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-24 12:20:24 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-24 12:20:24 -0400 |
commit | a76d63809c96078c49d4858073aeaf5a7bd63fd5 (patch) | |
tree | 8ea2c38ef64412bdb0a27b2ac22ab75d19e627d2 | |
parent | 0662e384a3911f84a09b92029446f6722f9340d5 (diff) | |
download | python-coveragepy-git-a76d63809c96078c49d4858073aeaf5a7bd63fd5.tar.gz |
Tidy up long lines
-rw-r--r-- | coverage/collector.py | 2 | ||||
-rw-r--r-- | coverage/control.py | 28 | ||||
-rw-r--r-- | coverage/html.py | 3 | ||||
-rw-r--r-- | coverage/parser.py | 28 |
4 files changed, 41 insertions, 20 deletions
diff --git a/coverage/collector.py b/coverage/collector.py index 4fc58107..4fd0044a 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -133,7 +133,7 @@ class Collector: self.should_trace = should_trace self.branch = branch self.reset() - if branch: # For now use PyTracer for branch, so we can wait to update the C code. + if branch: # TODO: For now use PyTracer for branch, so we can wait to update the C code. self._trace_class = PyTracer elif timid: # Being timid: use the simple Python trace function. diff --git a/coverage/control.py b/coverage/control.py index 2de4474b..d2f9337c 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -3,7 +3,8 @@ import os, socket from coverage.annotate import AnnotateReporter -from coverage.backward import set, string_class, sorted # pylint: disable-msg=W0622 +from coverage.backward import set, string_class # pylint: disable-msg=W0622 +from coverage.backward import sorted # pylint: disable-msg=W0622 from coverage.codeunit import code_unit_factory, CodeUnit from coverage.collector import Collector from coverage.data import CoverageData @@ -50,6 +51,8 @@ class coverage: tracing functions make the faster more sophisticated trace function not operate properly. + TODO: `branch`. + """ from coverage import __version__ @@ -65,7 +68,9 @@ class coverage: # cheap hack, since the rest of the command line arguments aren't # recognized, but it solves some users' problems. timid = timid or ('--timid' in os.environ.get('COVERAGE_OPTIONS', '')) - self.collector = Collector(self._should_trace, timid=timid, branch=branch) + self.collector = Collector( + self._should_trace, timid=timid, branch=branch + ) # Create the data file. if data_suffix: @@ -242,7 +247,10 @@ class coverage: """ analysis = self._analyze(morf) - return analysis.filename, analysis.statements, analysis.excluded, analysis.missing, analysis.missing_formatted() + return ( + analysis.filename, analysis.statements, analysis.excluded, + analysis.missing, analysis.missing_formatted() + ) def _analyze(self, it): """Analyze a single morf or code unit. @@ -347,9 +355,10 @@ class Analysis: ) self.parser = CodeParser( - text=source, filename=self.filename, exclude=self.coverage.exclude_re + text=source, filename=self.filename, + exclude=self.coverage.exclude_re ) - self.statements, self.excluded, line_map = self.parser.parse_source() + self.statements, self.excluded = self.parser.parse_source() # Identify missing statements. self.missing = [] @@ -379,7 +388,10 @@ class Analysis: possible = self.arc_possibilities() executed = self.arcs_executed() # 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 = [e for e in executed if e not in possible and e[0] != e[1]] + # 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 = [ + e for e in executed + if e not in possible and e[0] != e[1] + ] return sorted(unpredicted) diff --git a/coverage/html.py b/coverage/html.py index d5811317..9a68b2c1 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -116,7 +116,8 @@ class HtmlReporter(Reporter): line_class = "" if lineno in analysis.statements: line_class += " stm" - if lineno not in analysis.missing and lineno not in analysis.excluded: + if lineno not in analysis.missing and \ + lineno not in analysis.excluded: line_class += c_run if lineno in analysis.excluded: line_class += c_exc diff --git a/coverage/parser.py b/coverage/parser.py index 18106e07..ec13a379 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -51,7 +51,8 @@ class CodeParser: def _get_byte_parser(self): """Create a ByteParser on demand.""" if not self._byte_parser: - self._byte_parser = ByteParser(text=self.text, filename=self.filename) + self._byte_parser = \ + ByteParser(text=self.text, filename=self.filename) return self._byte_parser byte_parser = property(_get_byte_parser) @@ -156,9 +157,8 @@ class CodeParser: def parse_source(self): """Parse source text to find executable lines, excluded lines, etc. - Return values are 1) a sorted list of executable line numbers, - 2) a sorted list of excluded line numbers, and 3) a dict mapping line - numbers to pairs (lo,hi) for multi-line statements. + Return values are 1) a sorted list of executable line numbers, and + 2) a sorted list of excluded line numbers. Reported line numbers are normalized to the first line of multi-line statements. @@ -170,7 +170,7 @@ class CodeParser: ignore = excluded_lines + list(self.docstrings) lines = self._map_to_first_lines(self.statement_starts, ignore) - return lines, excluded_lines, self.multiline + return lines, excluded_lines def arc_info(self): """Get information about the arcs available in the code.""" @@ -241,7 +241,11 @@ class ByteParser: ) def child_parsers(self): - """Iterate over all the code objects nested within this one, starting with self.""" + """Iterate over all the code objects nested within this one. + + The iteration includes `self` as its first value. + + """ return map(lambda c: ByteParser(code=c), CodeObjects(self.code)) # Getting numbers from the lnotab value changed in Py3.0. @@ -331,7 +335,9 @@ class ByteParser: self.exits = set() def __repr__(self): - return "<%d:%d(%d) %r>" % (self.byte, self.line, self.length, list(self.exits)) + return "<%d:%d(%d) %r>" % ( + self.byte, self.line, self.length, list(self.exits) + ) # The list of chunks so far, and the one we're working on. chunks = [] @@ -435,7 +441,7 @@ class ByteParser: break else: # No chunk for this byte! - raise Exception("Couldn't find a chunk for byte %d" % byte) + raise Exception("Couldn't find chunk @ %d" % byte) byte_chunks[byte] = ch if ch.line: @@ -500,10 +506,12 @@ class AdHocMain(object): "-d", action="store_true", dest="dis", help="Disassemble" ) parser.add_option( - "-R", action="store_true", dest="recursive", help="Recurse to find source files" + "-R", action="store_true", dest="recursive", + help="Recurse to find source files" ) parser.add_option( - "-s", action="store_true", dest="source", help="Show analyzed source" + "-s", action="store_true", dest="source", + help="Show analyzed source" ) parser.add_option( "-t", action="store_true", dest="tokens", help="Show tokens" |