Пример #1
0
 def _ensure_used_variables(
     self,
     local_variables: Mapping[str, List[_LocalVariable]],
 ) -> None:
     for varname, usages in local_variables.items():
         for node in usages:
             if access.is_protected(varname):
                 self.add_violation(
                     naming.UnusedVariableIsUsedViolation(
                         node,
                         text=varname,
                     ), )
Пример #2
0
    def _check_variable_used(
        self,
        node: ast.AST,
        assigned_name: Optional[str],
        *,
        is_created: bool,
    ) -> None:
        if not assigned_name or not access.is_unused(assigned_name):
            return

        if not is_created:
            self.add_violation(
                naming.UnusedVariableIsUsedViolation(node,
                                                     text=assigned_name), )
Пример #3
0
    def _check_variable_used(
        self,
        node: ast.AST,
        assigned_name: Optional[str],
        *,
        is_created: bool,
    ) -> None:
        if not assigned_name or not access.is_unused(assigned_name):
            return

        if assigned_name == '_':  # This is a special case for django's
            return  # gettext and similar tools.

        if not is_created:
            self.add_violation(
                naming.UnusedVariableIsUsedViolation(node,
                                                     text=assigned_name), )
Пример #4
0
    def _check_variable_used(
        self,
        node: ast.AST,
        assigned_name: str,
        *,
        is_created: bool,
    ) -> None:
        if not access.is_unused(assigned_name):
            return

        if assigned_name == UNUSED_PLACEHOLDER:
            # This is a special case for django's
            # gettext and similar tools.
            return

        if not is_created:
            self.add_violation(
                naming.UnusedVariableIsUsedViolation(node,
                                                     text=assigned_name), )