File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 24
24
from array import array
25
25
from collections import namedtuple
26
26
from types import ModuleType
27
- from typing import Optional , Tuple , Union
27
+ from typing import Optional , Union
28
28
29
29
import xdis
30
30
from xdis import (
@@ -654,9 +654,9 @@ def prefer_double_quote(string: str) -> str:
654
654
Prefer a double quoted string over a
655
655
single quoted string when possible
656
656
"""
657
- if string .find ("'" ) == - 1 :
658
- return f'"{ string } "'
659
- return repr ( string )
657
+ if string .find ("'" ) == - 1 and not string . startswith ( "'''" ) :
658
+ return f'"{ string [ 1 : - 2 ] } "'
659
+ return string
660
660
661
661
662
662
if __name__ == "__main__" :
Original file line number Diff line number Diff line change @@ -612,7 +612,7 @@ def ingest(
612
612
pattr = "<code_object " + co_name + ">"
613
613
elif isinstance (const , str ):
614
614
opname = "LOAD_STR"
615
- pattr = prefer_double_quote (inst .argval )
615
+ pattr = prefer_double_quote (inst .argrepr )
616
616
else :
617
617
if isinstance (inst .arg , int ) and inst .arg < len (co .co_consts ):
618
618
argval , _ = _get_const_info (inst .arg , co .co_consts )
Original file line number Diff line number Diff line change @@ -386,7 +386,7 @@ def tokens_append(j, token):
386
386
pattr = "<code_object " + const .co_name + ">"
387
387
elif isinstance (const , str ):
388
388
opname = "LOAD_STR"
389
- pattr = prefer_double_quote (inst .argval )
389
+ pattr = prefer_double_quote (inst .argrepr )
390
390
else :
391
391
if isinstance (inst .arg , int ) and inst .arg < len (co .co_consts ):
392
392
argval , _ = _get_const_info (inst .arg , co .co_consts )
You can’t perform that action at this time.
0 commit comments