#NEWLINE# def check_dict_formatting_in_string( logical_line , tokens ) : #NEWLINE# #INDENT# 'Check that strings do not use dict-formatting with a single replacement\n\n    N352\n    ' #NEWLINE# if ( ( not logical_line ) or logical_line . startswith ( '#' ) or logical_line . endswith ( '# noqa' ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# current_string = '' #NEWLINE# in_string = False #NEWLINE# for ( token_type , text , start , end , line ) in tokens : #NEWLINE# #INDENT# if ( token_type == tokenize . STRING ) : #NEWLINE# #INDENT# if ( not in_string ) : #NEWLINE# #INDENT# current_string = '' #NEWLINE# in_string = True #NEWLINE# #UNINDENT# current_string += text . strip ( '"' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( token_type == tokenize . OP ) : #NEWLINE# #INDENT# if ( not current_string ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# in_string = False #NEWLINE# if ( text == '%' ) : #NEWLINE# #INDENT# format_keys = set ( ) #NEWLINE# for match in re_str_format . finditer ( current_string ) : #NEWLINE# #INDENT# format_keys . add ( match . group ( 1 ) ) #NEWLINE# #UNINDENT# if ( len ( format_keys ) == 1 ) : #NEWLINE# #INDENT# ( yield ( 0 , 'N353 Do not use mapping key string formatting with a single key' ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( text != ')' ) : #NEWLINE# #INDENT# current_string = '' #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( token_type in ( tokenize . NL , tokenize . COMMENT ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# in_string = False #NEWLINE# if ( token_type == tokenize . NEWLINE ) : #NEWLINE# #INDENT# current_string = ''