Repository: ipython/ipython

Issue #13479: r followed by quote auto-matches with closing quote regardless of context
Created: 2022-01-20T16:23:13Z
In 8.0.0 typing any of the following...
r'
r"
R'
R"

...seems to duplicate that quote character regardless of where it is typed. For example, type this...
In[1]: pqrst

...then move the cursor back between the r and s and type one double-quote, and it will add a second resulting in this:
In[1]: pqr""st

Behavior seems to be unaffected by turning on TerminalInteractiveShell.auto_match or setting TerminalInteractiveShell.autoformatter = None.
(edit) More generally, any quoted string ending in R has an extra quote character auto-inserted that then needs to be deleted.
I imagine this is driven by /terminal/shortcuts.py lines 183-191. When I comment out these lines, it behaves as I would expect, even when turning on auto_match. Why are raw strings considered a special case forcing auto-match rather than letting lines 142-150 dictate how it behaves based on the user's auto_match choice?

Duplicate issue #13482: Autocompletion inserting extra quotes for words ending in `r` and `R`
Created: 2022-01-21T21:29:57Z
Strings ending with "R" and "r" seem to be triggering an extra quote to be inserted at the end when being auto completed. This issue just started occurring in 8.0.0.  I ran in to it when attempting to do os.getenv("USER") gets turned in to os.getenv("USER")".
I wasn't able to find another string that triggers this behavior.
Here is a screenshot of the completion:

It is kind of hard to work around because the extra quote will be there even if you type directly over and do not accept the auto completion. Any thoughts on what might be causing this quote insertion appreciated.
Is there a way to turn off autocompletion? I could not find it in the docs.
I have tried tiknering with various formatting options such as
ipython --no-autoindent --Completer.use_jedi=True --TerminalInteractiveShell.autoformatter=None ipython --no-autoindent --Completer.use_jedi=False  --TerminalInteractiveShell.autoformatter=None
**Environment **
$ ipython --version
8.0.1
$ python --version
Python 3.9.9
Via Windows terminal
Results of dumping string.printable through an ipython terminal with formatting turned off in the details. Only r triggers this behavior.

In [1]: v = '0'

In [2]: v = "0"

In [3]: v = '1'

In [4]: v = "1"

In [5]: v = '2'

In [6]: v = "2"

In [7]: v = '3'

In [8]: v = "3"

In [9]: v = '4'

In [10]: v = "4"

In [11]: v = '5'

In [12]: v = "5"

In [13]: v = '6'

In [14]: v = "6"

In [15]: v = '7'

In [16]: v = "7"

In [17]: v = '8'

In [18]: v = "8"

In [19]: v = '9'

In [20]: v = "9"

In [21]: v = 'a'

In [22]: v = "a"

In [23]: v = 'b'

In [24]: v = "b"

In [25]: v = 'c'

In [26]: v = "c"

In [27]: v = 'd'

In [28]: v = "d"

In [29]: v = 'e'

In [30]: v = "e"

In [31]: v = 'f'

In [32]: v = "f"

In [33]: v = 'g'

In [34]: v = "g"

In [35]: v = 'h'

In [36]: v = "h"

In [37]: v = 'i'

In [38]: v = "i"

In [39]: v = 'j'

In [40]: v = "j"

In [41]: v = 'k'

In [42]: v = "k"

In [43]: v = 'l'

In [44]: v = "l"

In [45]: v = 'm'

In [46]: v = "m"

In [47]: v = 'n'

In [48]: v = "n"

In [49]: v = 'o'

In [50]: v = "o"

In [51]: v = 'p'

In [52]: v = "p"

In [53]: v = 'q'

In [54]: v = "q"

In [55]: v = 'r''
  Input In [55]
    v = 'r''
            ^
SyntaxError: EOL while scanning string literal


In [56]: v = "r""
  Input In [56]
    v = "r""
            ^
SyntaxError: EOL while scanning string literal


In [57]: v = 's'

In [58]: v = "s"

In [59]: v = 't'

In [60]: v = "t"

In [61]: v = 'u'

In [62]: v = "u"

In [63]: v = 'v'

In [64]: v = "v"

In [65]: v = 'w'

In [66]: v = "w"

In [67]: v = 'x'

In [68]: v = "x"

In [69]: v = 'y'

In [70]: v = "y"

In [71]: v = 'z'

In [72]: v = "z"

In [73]: v = 'A'

In [74]: v = "A"

In [75]: v = 'B'

In [76]: v = "B"

In [77]: v = 'C'

In [78]: v = "C"

In [79]: v = 'D'

In [80]: v = "D"

In [81]: v = 'E'

In [82]: v = "E"

In [83]: v = 'F'

In [84]: v = "F"

In [85]: v = 'G'

In [86]: v = "G"

In [87]: v = 'H'

In [88]: v = "H"

In [89]: v = 'I'

In [90]: v = "I"

In [91]: v = 'J'

In [92]: v = "J"

In [93]: v = 'K'

In [94]: v = "K"

In [95]: v = 'L'

In [96]: v = "L"

In [97]: v = 'M'

In [98]: v = "M"

In [99]: v = 'N'

In [100]: v = "N"

In [101]: v = 'O'

In [102]: v = "O"

In [103]: v = 'P'

In [104]: v = "P"

In [105]: v = 'Q'

In [106]: v = "Q"

In [107]: v = 'R''
  Input In [107]
    v = 'R''
            ^
SyntaxError: EOL while scanning string literal


In [108]: v = "R""
  Input In [108]
    v = "R""
            ^
SyntaxError: EOL while scanning string literal


In [109]: v = 'S'

In [110]: v = "S"

In [111]: v = 'T'

In [112]: v = "T"

In [113]: v = 'U'

In [114]: v = "U"

In [115]: v = 'V'

In [116]: v = "V"

In [117]: v = 'W'

In [118]: v = "W"

In [119]: v = 'X'

In [120]: v = "X"

In [121]: v = 'Y'

In [122]: v = "Y"

In [123]: v = 'Z'

In [124]: v = "Z"

In [125]: v = '!'

In [126]: v = "!"

In [127]: v = '"'

In [128]: v = "'"

In [129]: v = '#'

In [130]: v = "#"

In [131]: v = '$'

In [132]: v = "$"

In [133]: v = '%'

In [134]: v = "%"

In [135]: v = '&'

In [136]: v = "&"

In [137]: v = '"'

In [138]: v = "'"

In [139]: v = '('

In [140]: v = "("

In [141]: v = ')'

In [142]: v = ")"

In [143]: v = '*'

In [144]: v = "*"

In [145]: v = '+'

In [146]: v = "+"

In [147]: v = ','

In [148]: v = ","

In [149]: v = '-'

In [150]: v = "-"

In [151]: v = '.'

In [152]: v = "."

In [153]: v = '/'

In [154]: v = "/"

In [155]: v = ':'

In [156]: v = ":"

In [157]: v = ';'

In [158]: v = ";"

In [159]: v = '<'

In [160]: v = "<"

In [161]: v = '='

In [162]: v = "="

In [163]: v = '>'

In [164]: v = ">"

In [165]: v = '?'

In [166]: v = "?"

In [167]: v = '@'

In [168]: v = "@"

In [169]: v = '['

In [170]: v = "["

In [171]: v = ']'

In [172]: v = "]"

In [173]: v = '^'

In [174]: v = "^"

In [175]: v = '_'

In [176]: v = "_"

In [177]: v = '`'

In [178]: v = "`"

In [179]: v = '{'

In [180]: v = "{"

In [181]: v = '|'

In [182]: v = "|"

In [183]: v = '}'

In [184]: v = "}"

In [185]: v = '~'

In [186]: v = "~"

In [187]: v = ' '

In [188]: v = " "

In [189]: v = '   '

In [190]: v = "   "

In [191]: v = ''

In [192]: v = ""

In [193]: v = ''

In [194]: v = ""
Strings in python so you can easily reproduce.
v = '0'
v = "0"
v = '1'
v = "1"
v = '2'
v = "2"
v = '3'
v = "3"
v = '4'
v = "4"
v = '5'
v = "5"
v = '6'
v = "6"
v = '7'
v = "7"
v = '8'
v = "8"
v = '9'
v = "9"
v = 'a'
v = "a"
v = 'b'
v = "b"
v = 'c'
v = "c"
v = 'd'
v = "d"
v = 'e'
v = "e"
v = 'f'
v = "f"
v = 'g'
v = "g"
v = 'h'
v = "h"
v = 'i'
v = "i"
v = 'j'
v = "j"
v = 'k'
v = "k"
v = 'l'
v = "l"
v = 'm'
v = "m"
v = 'n'
v = "n"
v = 'o'
v = "o"
v = 'p'
v = "p"
v = 'q'
v = "q"
v = 'r'
v = "r"
v = 's'
v = "s"
v = 't'
v = "t"
v = 'u'
v = "u"
v = 'v'
v = "v"
v = 'w'
v = "w"
v = 'x'
v = "x"
v = 'y'
v = "y"
v = 'z'
v = "z"
v = 'A'
v = "A"
v = 'B'
v = "B"
v = 'C'
v = "C"
v = 'D'
v = "D"
v = 'E'
v = "E"
v = 'F'
v = "F"
v = 'G'
v = "G"
v = 'H'
v = "H"
v = 'I'
v = "I"
v = 'J'
v = "J"
v = 'K'
v = "K"
v = 'L'
v = "L"
v = 'M'
v = "M"
v = 'N'
v = "N"
v = 'O'
v = "O"
v = 'P'
v = "P"
v = 'Q'
v = "Q"
v = 'R'
v = "R"
v = 'S'
v = "S"
v = 'T'
v = "T"
v = 'U'
v = "U"
v = 'V'
v = "V"
v = 'W'
v = "W"
v = 'X'
v = "X"
v = 'Y'
v = "Y"
v = 'Z'
v = "Z"
v = '!'
v = "!"
v = '"'
v = "'"
v = '#'
v = "#"
v = '$'
v = "$"
v = '%'
v = "%"
v = '&'
v = "&"
v = '"'
v = "'"
v = '('
v = "("
v = ')'
v = ")"
v = '*'
v = "*"
v = '+'
v = "+"
v = ','
v = ","
v = '-'
v = "-"
v = '.'
v = "."
v = '/'
v = "/"
v = ':'
v = ":"
v = ';'
v = ";"
v = '<'
v = "<"
v = '='
v = "="
v = '>'
v = ">"
v = '?'
v = "?"
v = '@'
v = "@"
v = '['
v = "["
v = ']'
v = "]"
v = '^'
v = "^"
v = '_'
v = "_"
v = '`'
v = "`"
v = '{'
v = "{"
v = '|'
v = "|"
v = '}'
v = "}"
v = '~'
v = "~"
v = ' '
v = " "
v = '   '
v = "   "
v = '♂'
v = "♂"
v = '♀'
v = "♀"

Closing comment (2022-01-24T14:12:31Z): Related to:
#13479
#13465