INNER CODE UNIT · Python
_strip_string_prefix
PyCQA/isort · isort/core.py:39
def _strip_string_prefix(line: str) -> str:
"""Return `line` without a leading Python string prefix (`r`, `b`, `f`, `u`
or a legal combination of them), so quote-based heuristics see the quote itself.
"""
for prefix_length in (2, 1):
if line[:prefix_length].lower() in STRING_PREFIXES and line[
prefix_length : prefix_length + 1
] in ("'", '"'):
return line[prefix_length:]
return line
def _is_comment_or_string_start(line: str) -> bool:
"""Return whether `line` opens a comment, a docstring or any other string literal.
A string prefix (`r`, `b`, `f`, `u` or a legal combination of them) is skipped
first, so a prefixed docstring is recognised exactly as an unprefixed one is.
"""