File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1059,18 +1059,23 @@ def should_use_repr(c):
10591059 # on that in Tools/unicode/makeunicodedata.py
10601060 c not in (' ' , '\n ' , '\t ' ) and unicodedata .category (c )[0 ] in ("C" , "Z" )
10611061 )
1062+ use_repr = any (map (should_use_repr , value ))
1063+
1064+ if not use_repr :
1065+ quote_types = ["'" , '"' , '"""' , "'''" ]
10621066
1063- if not any (should_use_repr (c ) for c in value ):
10641067 if "\n " in value :
1065- quote_types = ["'''" , '"""' ]
1066- else :
1067- quote_types = ["'" , '"' , '"""' , "'''" ]
1068+ quote_types = quote_types [2 :]
10681069
10691070 for quote_type in quote_types :
10701071 if quote_type not in value :
10711072 self .write (f"{ quote_type } { value } { quote_type } " )
1072- return
1073- self .write (repr (value ))
1073+ break
1074+ else :
1075+ use_repr = True
1076+
1077+ if use_repr :
1078+ self .write (repr (value ))
10741079
10751080 def visit_JoinedStr (self , node ):
10761081 self .write ("f" )
You can’t perform that action at this time.
0 commit comments