def _check_typed_ast(self, token: tokenize.TokenInfo) -> None: comment_text = self._get_comment_text(token) match = self.type_check.match(comment_text) if not match: return declared_type = match.groups()[0].strip() if declared_type != 'ignore': self.add_violation( WrongMagicCommentViolation(token, text=comment_text), )
def _check_noqa(self, token: tokenize.TokenInfo) -> None: comment_text = self._get_comment_text(token) match = self.noqa_check.match(comment_text) if not match: return excludes = match.groups()[0].strip() if not excludes: # We can not pass the actual line here, # since it will be ignored due to `# noqa` comment: self.add_violation(WrongMagicCommentViolation(text=comment_text))
def _check_noqa(self, token: tokenize.TokenInfo) -> None: comment_text = get_comment_text(token) match = self._noqa_check.match(comment_text) if not match: return self._noqa_count += 1 excludes = match.groups()[1].strip() prefix = match.groups()[0].strip() if not excludes or prefix[-1] != ':': # We cannot pass the actual line here, # since it will be ignored due to `# noqa` comment: self.add_violation(WrongMagicCommentViolation(text=comment_text)) return self._check_forbidden_noqa(excludes)