diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-05-01 18:18:11 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-05-02 07:38:19 -0400 |
commit | 4c4ba2e0bc9ec663fa3772d2b088f736345a65a1 (patch) | |
tree | a03a2672bfe64141b46243274243377d86c73bb8 /coverage/annotate.py | |
parent | 236bc9317d208b24b418c9c167f22410613f4ade (diff) | |
download | python-coveragepy-git-4c4ba2e0bc9ec663fa3772d2b088f736345a65a1.tar.gz |
refactor: pyupgrade --py36-plus coverage/*.py
Diffstat (limited to 'coverage/annotate.py')
-rw-r--r-- | coverage/annotate.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/coverage/annotate.py b/coverage/annotate.py index 999ab6e5..a6ee4636 100644 --- a/coverage/annotate.py +++ b/coverage/annotate.py @@ -3,7 +3,6 @@ """Source file annotation for coverage.py.""" -import io import os import re @@ -14,7 +13,7 @@ from coverage.report import get_analysis_to_report os = isolate_module(os) -class AnnotateReporter(object): +class AnnotateReporter: """Generate annotated source files showing line coverage. This reporter creates annotated copies of the measured source files. Each @@ -74,7 +73,7 @@ class AnnotateReporter(object): else: dest_file = fr.filename + ",cover" - with io.open(dest_file, 'w', encoding='utf8') as dest: + with open(dest_file, 'w', encoding='utf8') as dest: i = 0 j = 0 covered = True @@ -87,22 +86,22 @@ class AnnotateReporter(object): if i < len(statements) and statements[i] == lineno: covered = j >= len(missing) or missing[j] > lineno if self.blank_re.match(line): - dest.write(u' ') + dest.write(' ') elif self.else_re.match(line): # Special logic for lines containing only 'else:'. if i >= len(statements) and j >= len(missing): - dest.write(u'! ') + dest.write('! ') elif i >= len(statements) or j >= len(missing): - dest.write(u'> ') + dest.write('> ') elif statements[i] == missing[j]: - dest.write(u'! ') + dest.write('! ') else: - dest.write(u'> ') + dest.write('> ') elif lineno in excluded: - dest.write(u'- ') + dest.write('- ') elif covered: - dest.write(u'> ') + dest.write('> ') else: - dest.write(u'! ') + dest.write('! ') dest.write(line) |