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):
1059
1059
# on that in Tools/unicode/makeunicodedata.py
1060
1060
c not in (' ' , '\n ' , '\t ' ) and unicodedata .category (c )[0 ] in ("C" , "Z" )
1061
1061
)
1062
+ use_repr = any (map (should_use_repr , value ))
1063
+
1064
+ if not use_repr :
1065
+ quote_types = ["'" , '"' , '"""' , "'''" ]
1062
1066
1063
- if not any (should_use_repr (c ) for c in value ):
1064
1067
if "\n " in value :
1065
- quote_types = ["'''" , '"""' ]
1066
- else :
1067
- quote_types = ["'" , '"' , '"""' , "'''" ]
1068
+ quote_types = quote_types [2 :]
1068
1069
1069
1070
for quote_type in quote_types :
1070
1071
if quote_type not in value :
1071
1072
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 ))
1074
1079
1075
1080
def visit_JoinedStr (self , node ):
1076
1081
self .write ("f" )
You can’t perform that action at this time.
0 commit comments