def _ensure_length(self, node: ast.AST, name: str) -> None: min_length = self._options.min_name_length if logical.is_too_short_name(name, min_length=min_length): self._error_callback(naming.TooShortNameViolation(node, text=name)) max_length = self._options.max_name_length if logical.is_too_long_name(name, max_length=max_length): self._error_callback(naming.TooLongNameViolation(node, text=name))
def _check_module_name_length(self) -> None: min_length = self.options.min_name_length if logical.is_too_short_name(self.stem, min_length=min_length): self.add_violation(naming.TooShortNameViolation(text=self.stem)) elif not constants.MODULE_NAME_PATTERN.match(self.stem): self.add_violation(naming.WrongModuleNamePatternViolation()) max_length = self.options.max_name_length if logical.is_too_long_name(self.stem, max_length=max_length): self.add_violation(naming.TooLongNameViolation(text=self.stem))