INNER CODE UNIT · Python

_is_comment_or_string_start

PyCQA/isort · isort/core.py:51

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.
    """
    return _strip_string_prefix(line.lstrip()).startswith(COMMENT_INDICATORS)


def _has_skip_comment(import_statement: str) -> bool:
    """Return whether an import statement carries a per-line ``isort: skip`` directive."""
    return any(comment in import_statement for comment in SKIP_IMPORT_COMMENTS)


class _FloatToTopResult(NamedTuple):
    input_stream: TextIO
    verbose_output: list[str]
    made_changes: bool

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…