def _check_empty_line_wrap( self, token: tokenize.TokenInfo, *, delta: int, ) -> None: tokens = self._lines.get(token.start[0] + delta) if tokens is not None and only_contains(tokens, NEWLINES): self.add_violation(BracketBlankLineViolation(token))
def _check_closing( self, token: tokenize.TokenInfo, index: int, tokens: List[tokenize.TokenInfo], ) -> None: tokens_before = tokens[:index] annotated = self._annotate_brackets(tokens_before) if annotated[get_reverse_bracket(token)] == 0: if not only_contains(tokens_before, ALLOWED_EMPTY_LINE_TOKENS): self.add_violation(WrongBracketPositionViolation(token))
def last_bracket(tokens: List[tokenize.TokenInfo], index: int) -> bool: """Tells whether the given index is the last bracket token in line.""" return only_contains( tokens[index + 1:], NEWLINES.union({tokenize.COMMENT}), )