Module rulebook-pylint.rulebook_pylint.internals.files
Functions
def get_fromlineno_before(lines: list[bytes],
current: astroid.nodes.node_ng.NodeNG,
previous: astroid.nodes.node_ng.NodeNG) ‑> int-
Expand source code
def get_fromlineno_before(lines: list[bytes], current: NodeNG, previous: NodeNG) -> int: index = current.fromlineno - 1 while index > 0: if lines[index].strip() == b'' or index == previous.tolineno - 1: return index + 1 index -= 1 return current.fromlineno - 1
def has_comment_above(lines: list[bytes], current: astroid.nodes.node_ng.NodeNG) ‑> bool
-
Expand source code
def has_comment_above(lines: list[bytes], current: NodeNG) -> bool: index = current.fromlineno - 1 while index > 0: line = lines[index].strip() if line == b'': return False if line.startswith(b'#') or \ line.startswith(b'"""') or \ line.startswith(b"'''"): return True index -= 1 return False
def strip_comment(lines: list[bytes], current: astroid.nodes.node_ng.NodeNG) ‑> bytes
-
Expand source code
def strip_comment(lines: list[bytes], current: NodeNG) -> bytes: return lines[current.lineno - 1].split(b'#', 1)[0].rstrip()