diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-05-17 22:53:02 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-05-17 22:53:02 -0400 |
commit | 9ac51b10e92e5faee2e0677887dcc536e3924a7f (patch) | |
tree | 79215b6d0e81c070e5670025f83677f899872284 | |
parent | 5291dd2839d5adfe64106501e7f9fe4984cf53ac (diff) | |
download | python-coveragepy-git-9ac51b10e92e5faee2e0677887dcc536e3924a7f.tar.gz |
Use more @contract, less assert
-rw-r--r-- | coverage/phystokens.py | 3 | ||||
-rw-r--r-- | coverage/python.py | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/coverage/phystokens.py b/coverage/phystokens.py index 587ec1c6..1bc6330d 100644 --- a/coverage/phystokens.py +++ b/coverage/phystokens.py @@ -151,6 +151,7 @@ generate_tokens = CachedTokenizer().generate_tokens COOKIE_RE = re.compile(r"^\s*#.*coding[:=]\s*([-\w.]+)", flags=re.MULTILINE) +@contract(source='bytes') def _source_encoding_py2(source): """Determine the encoding for `source`, according to PEP 263. @@ -247,6 +248,7 @@ def _source_encoding_py2(source): return default +@contract(source='bytes') def _source_encoding_py3(source): """Determine the encoding for `source`, according to PEP 263. @@ -257,7 +259,6 @@ def _source_encoding_py3(source): string: the name of the encoding. """ - assert isinstance(source, bytes) readline = iternext(source.splitlines(True)) return tokenize.detect_encoding(readline)[0] diff --git a/coverage/python.py b/coverage/python.py index 3e8e9f39..faa26ffc 100644 --- a/coverage/python.py +++ b/coverage/python.py @@ -77,7 +77,6 @@ def get_zip_bytes(filename): data = zi.get_data(parts[1]) except IOError: continue - assert isinstance(data, bytes) return data return None @@ -160,7 +159,6 @@ class PythonFileReporter(FileReporter): def source(self): if self._source is None: self._source = get_python_source(self.filename) - assert isinstance(self._source, unicode_class) return self._source def should_be_python(self): |