1717from django .template .base import Lexer , NodeList , Template , TextNode
1818from django .template .defaulttags import VerbatimNode
1919from django .templatetags .i18n import BlockTranslateNode
20- from six .moves import range
2120
2221try :
2322 from django .template .base import TokenType
@@ -165,7 +164,7 @@ def sys_info(self):
165164 return [
166165 ("django_template_dir" , self .django_template_dir ),
167166 ("environment" , sorted (
168- ("%s = %s" % (k , v ))
167+ ("{} = {}" . format (k , v ))
169168 for k , v in os .environ .items ()
170169 if "DJANGO" in k
171170 )),
@@ -239,7 +238,7 @@ def line_number_range(self, frame):
239238 return - 1 , - 1
240239
241240 if SHOW_TRACING :
242- print ("{ !r}: {}" . format ( render_self , position ) )
241+ print (f" { render_self !r} : { position } " )
243242 s_start , s_end = position
244243 if isinstance (render_self , TextNode ):
245244 first_line = render_self .s .splitlines (True )[0 ]
@@ -294,7 +293,7 @@ def get_line_map(self, filename):
294293
295294class FileReporter (coverage .plugin .FileReporter ):
296295 def __init__ (self , filename ):
297- super (FileReporter , self ).__init__ (filename )
296+ super ().__init__ (filename )
298297 # TODO: html filenames are absolute.
299298
300299 self ._source = None
@@ -303,15 +302,15 @@ def source(self):
303302 if self ._source is None :
304303 try :
305304 self ._source = read_template_source (self .filename )
306- except (IOError , UnicodeError ) as exc :
307- raise NoSource ("Couldn't read {}: {}" . format ( self . filename , exc ) )
305+ except (OSError , UnicodeError ) as exc :
306+ raise NoSource (f "Couldn't read { self . filename } : { exc } " )
308307 return self ._source
309308
310309 def lines (self ):
311310 source_lines = set ()
312311
313312 if SHOW_PARSING :
314- print ("-------------- {}" . format ( self .filename ) )
313+ print (f "-------------- { self .filename } " )
315314
316315 if django .VERSION >= (1 , 9 ):
317316 lexer = Lexer (self .source ())
@@ -389,7 +388,7 @@ def lines(self):
389388 source_lines .update (range (lineno , lineno + num_lines ))
390389
391390 if SHOW_PARSING :
392- print ("\t \t \t Now source_lines is: {!r}" . format ( source_lines ) )
391+ print (f "\t \t \t Now source_lines is: { source_lines !r} " )
393392
394393 return source_lines
395394
0 commit comments