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(name): self.error_callback( ProtectedModuleViolation(node, text=text), )
def _check_used_variables( self, local_variables: Dict[str, List[LocalVariable]], ) -> None: for varname, usages in local_variables.items(): for node in usages: if access.is_protected(varname) or varname == UNUSED_VARIABLE: self.add_violation( UnusedVariableIsUsedViolation(node, text=varname), )
def _check_protected_attribute(self, node: ast.Attribute) -> None: if access.is_protected(node.attr): if isinstance(node.value, ast.Name): if node.value.id in self._allowed_to_use_protected: return if isinstance(node.value, ast.Call): if self._is_super_called(node.value): return self.add_violation( ProtectedAttributeViolation(node, text=node.attr), )
def _check_protected_attribute(self, node: ast.Attribute) -> None: if access.is_protected(node.attr): self._ensure_attribute_type(node, ProtectedAttributeViolation)