INNER CODE UNIT · Python
_scan_quotes
PyCQA/isort · isort/core.py:131
def _scan_quotes(
line: str,
stripped_line: str,
in_quote: str,
) -> str:
"""Return the active quote state after scanning a source line."""
if ((not stripped_line.startswith("#") or in_quote) and '"' in line) or "'" in line:
char_index = 0
while char_index < len(line):
if line[char_index] == "\\":
char_index += 1
elif in_quote:
if line[char_index : char_index + len(in_quote)] == in_quote:
in_quote = ""
elif line[char_index] in ("'", '"'):
long_quote = line[char_index : char_index + 3]
if long_quote in ('"""', "'''"):