question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autoCloseBrackets misbehaves with Python string prefixes

See original GitHub issue

Entering ' in a Python editor will automatically insert the closing ', as it does for brackets. Entering u', r', ur' or b' (case-insensitive) may also indicate the start of a string, but is misinterpreted as closing a string, so ' is not auto-inserted. Entering an empty byte-string (in Python 3), b'' will automatically append a third apostrophe!

Similarly, the heredoc-like string syntax in Python is not supported: ''' should be closed by ''' (instead, a fourth apostrophe is inserted); """ should be closed by """.

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
haraldschillycommented, Jan 30, 2019

another case a python 3.6 “format strings”, i.e. they start with f" or f' or for raw strings, e.g. rf'a b \n {x} d' is a prefix of rf is possible.

0reactions
jasongroutcommented, Mar 20, 2020

For completeness, checking for word characters prevents don't from turning into don''t, for example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

autoCloseBrackets misbehaves with Python string prefixes
Entering ' in a Python editor will automatically insert the closing ', as it does for brackets. Entering u', r', ur' or b'...
Read more >
python f-string auto close (match bracket) - v6 - CodeMirror
I noticed that this commit removed auto-closing of brackets inside string literals. What if this is was my preference (in python)?
Read more >
2. Lexical analysis — Python 3.11.1 documentation
Bytes literals are always prefixed with 'b' or 'B' ; they produce an instance of the bytes type instead of the str type....
Read more >
python - What exactly do "u" and "r" string prefixes do, and ...
Raw string literals, with an "r" prefix, escape any escape sequences within them, so len(r"\n") is 2. Because they escape escape sequences, you...
Read more >
How to Remove a Prefix or Suffix from a String in Python
Using the str.removeprefix() method, we were able to pass in the string prefix that we wanted to remove. Keep in mind that Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found