pylint/checkers/refactoring.py
def _check_consider_using_join(self, aug_assign):
        """
        We start with the augmented assignment and work our way upwards.
        Names of variables for nodes if match successful:
        result = ''  # assign
        for number in ['1', '2', '3']  # for_loop
            result += number  # aug_assign
        """
        for_loop = aug_assign.parent
        if not isinstance(for_loop, astroid.For) or len(for_loop.body) > 1:
            return
        assign = for_loop.previous_sibling()
        if not isinstance(assign, astroid.Assign):
            return
        result_assign_names = {
            target.name
            for target in assign.targets
            if isinstance(target, astroid.AssignName)
        }

        is_concat_loop = (
            aug_assign.op == "+="
            and isinstance(aug_assign.target, astroid.AssignName)
            and len(for_loop.body) == 1
            and aug_assign.target.name in result_assign_names
            and isinstance(assign.value, astroid.Const)
            and isinstance(assign.value.value, str)
            and isinstance(aug_assign.value, astroid.Name)
            and aug_assign.value.name == for_loop.target.name
        )
        if is_concat_loop:
            self.add_message("consider-using-join", node=aug_assign)
def _check_consider_using_join(self, aug_assign):
        """
        We start with the augmented assignment and work our way upwards.
        Names of variables for nodes if match successful:
        result = ''  # assign
        for number in ['1', '2', '3']  # for_loop
            result += number  # aug_assign
        """
        for_loop = aug_assign.parent
        if not isinstance(for_loop, astroid.For) or len(for_loop.body) > 1:
            return
        assign = for_loop.previous_sibling()
        if not isinstance(assign, astroid.Assign):
            return
        result_assign_names = {
            target.name
            for target in assign.targets
            if isinstance(target, astroid.AssignName)
        }

        is_concat_loop = (
            aug_assign.op == "+="
            and isinstance(aug_assign.target, astroid.AssignName)
            and len(for_loop.body) == 1
            and aug_assign.target.name in result_assign_names
            and isinstance(assign.value, astroid.Const)
            and isinstance(assign.value.value, str)
            and isinstance(aug_assign.value, astroid.Name)
            and aug_assign.value.name == for_loop.target.name
        )
        if is_concat_loop:
            self.add_message("consider-using-join", node=aug_assign)
def _check_consider_using_join ( self , aug_assign ) : for_loop = aug_assign . parent if not isinstance ( for_loop , astroid . For ) or len ( for_loop . body ) > 1 : return assign = for_loop . previous_sibling ( ) if not isinstance ( assign , astroid . Assign ) : return result_assign_names = { target . name for target in assign . targets if isinstance ( target , astroid . AssignName ) } is_concat_loop = ( aug_assign . op == "+=" and isinstance ( aug_assign . target , astroid . AssignName ) and len ( for_loop . body ) == 1 and aug_assign . target . name in result_assign_names and isinstance ( assign . value , astroid . Const ) and isinstance ( assign . value . value , str ) and isinstance ( aug_assign . value , astroid . Name ) and aug_assign . value . name == for_loop . target . name ) if is_concat_loop : self . add_message ( "consider-using-join" , node = aug_assign )
We start with the augmented assignment and work our way upwards.
        Names of variables for nodes if match successful:
        result = ''  # assign
        for number in ['1', '2', '3']  # for_loop
            result += number  # aug_assign
We start with the augmented assignment and work our way upwards . Names of variables for nodes if match successful : result = # assign for number in [ 1 2 3 ] # for_loop result + = number # aug_assign