def check_protected_import(self, node: AnyImport) -> None: text = imports.get_error_text(node) import_names = [alias.name for alias in node.names] for name in chain(imports.get_import_parts(node), import_names): if access.is_protected_variable(name): self.error_callback(ProtectedModuleViolation(node, text=text), )
def check_local_import(self, node: ast.ImportFrom) -> None: text = get_error_text(node) if node.level != 0: self.error_callback(LocalFolderImportViolation(node, text=text), )
def check_nested_import(self, node: AnyImport) -> None: text = get_error_text(node) parent = getattr(node, 'parent', None) if parent is not None and not isinstance(parent, ast.Module): self.error_callback(NestedImportViolation(node, text=text))