def _check_module_name_pattern(self) -> None: if logical.does_contain_consecutive_underscores(self.stem): self.add_violation( ConsecutiveUnderscoresInNameViolation(text=self.stem), ) if logical.does_contain_underscored_number(self.stem): self.add_violation(UnderscoredNumberNameViolation(text=self.stem))
def _check_module_name_pattern(self) -> None: if not constants.MODULE_NAME_PATTERN.match(self.stem): self.add_violation(WrongModuleNamePatternViolation()) if logical.does_contain_consecutive_underscores(self.stem): self.add_violation( ConsecutiveUnderscoresInNameViolation(text=self.stem), ) if logical.does_contain_underscored_number(self.stem): self.add_violation(UnderscoredNumberNameViolation(text=self.stem))
def _ensure_underscores(self, node: ast.AST, name: str): if access.is_private(name): self._error_callback(naming.PrivateNameViolation(node, text=name), ) if logical.does_contain_underscored_number(name): self._error_callback( naming.UnderscoredNumberNameViolation(node, text=name), ) if logical.does_contain_consecutive_underscores(name): self._error_callback( naming.ConsecutiveUnderscoresInNameViolation( node, text=name, ), )
def _check_name(self, node: ast.AST, name: str) -> None: if logical.is_wrong_name(name, VARIABLE_NAMES_BLACKLIST): self.add_violation(WrongVariableNameViolation(node, text=name)) min_length = self.options.min_name_length if logical.is_too_short_name(name, min_length=min_length): self.add_violation(TooShortNameViolation(node, text=name)) if access.is_private(name): self.add_violation(PrivateNameViolation(node, text=name)) if logical.does_contain_underscored_number(name): self.add_violation(UnderscoredNumberNameViolation(node, text=name)) if logical.does_contain_consecutive_underscores(name): self.add_violation( ConsecutiveUnderscoresInNameViolation(node, text=name), )