eric7/DebugClients/Python/coverage/annotate.py

branch
eric7
changeset 8775
0802ae193343
parent 8312
800c432b34c8
--- a/eric7/DebugClients/Python/coverage/annotate.py	Fri Nov 19 19:28:47 2021 +0100
+++ b/eric7/DebugClients/Python/coverage/annotate.py	Sat Nov 20 16:47:38 2021 +0100
@@ -3,7 +3,6 @@
 
 """Source file annotation for coverage.py."""
 
-import io
 import os
 import re
 
@@ -14,7 +13,7 @@
 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,9 +73,8 @@
         else:
             dest_file = fr.filename + ",cover"
 
-        with io.open(dest_file, 'w', encoding='utf8') as dest:
-            i = 0
-            j = 0
+        with open(dest_file, 'w', encoding='utf-8') as dest:
+            i = j = 0
             covered = True
             source = fr.source()
             for lineno, line in enumerate(source.splitlines(True), start=1):
@@ -87,22 +85,20 @@
                 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'! ')
-                    elif i >= len(statements) or j >= len(missing):
-                        dest.write(u'> ')
+                    if j >= len(missing):
+                        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)

eric ide

mercurial