pylint/checkers/format.py
def check_indent_level(self, string, expected, line_num):
        """return the indent level of the string
        """
        indent = self.config.indent_string
        if indent == "\\t":  # \t is not interpreted in the configuration file
            indent = "\t"
        level = 0
        unit_size = len(indent)
        while string[:unit_size] == indent:
            string = string[unit_size:]
            level += 1
        suppl = ""
        while string and string[0] in " \t":
            if string[0] != indent[0]:
                if string[0] == "\t":
                    args = ("tab", "space")
                else:
                    args = ("space", "tab")
                self.add_message("mixed-indentation", args=args, line=line_num)
                return level
            suppl += string[0]
            string = string[1:]
        if level != expected or suppl:
            i_type = "spaces"
            if indent[0] == "\t":
                i_type = "tabs"
            self.add_message(
                "bad-indentation",
                line=line_num,
                args=(level * unit_size + len(suppl), i_type, expected * unit_size),
            )
        return None
def check_indent_level(self, string, expected, line_num):
        indent = self.config.indent_string
        if indent == "\\t":  # \t is not interpreted in the configuration file
            indent = "\t"
        level = 0
        unit_size = len(indent)
        while string[:unit_size] == indent:
            string = string[unit_size:]
            level += 1
        suppl = ""
        while string and string[0] in " \t":
            if string[0] != indent[0]:
                if string[0] == "\t":
                    args = ("tab", "space")
                else:
                    args = ("space", "tab")
                self.add_message("mixed-indentation", args=args, line=line_num)
                return level
            suppl += string[0]
            string = string[1:]
        if level != expected or suppl:
            i_type = "spaces"
            if indent[0] == "\t":
                i_type = "tabs"
            self.add_message(
                "bad-indentation",
                line=line_num,
                args=(level * unit_size + len(suppl), i_type, expected * unit_size),
            )
        return None
def check_indent_level ( self , string , expected , line_num ) : indent = self . config . indent_string if indent == "\\t" : # \t is not interpreted in the configuration file indent = "\t" level = 0 unit_size = len ( indent ) while string [ : unit_size ] == indent : string = string [ unit_size : ] level += 1 suppl = "" while string and string [ 0 ] in " \t" : if string [ 0 ] != indent [ 0 ] : if string [ 0 ] == "\t" : args = ( "tab" , "space" ) else : args = ( "space" , "tab" ) self . add_message ( "mixed-indentation" , args = args , line = line_num ) return level suppl += string [ 0 ] string = string [ 1 : ] if level != expected or suppl : i_type = "spaces" if indent [ 0 ] == "\t" : i_type = "tabs" self . add_message ( "bad-indentation" , line = line_num , args = ( level * unit_size + len ( suppl ) , i_type , expected * unit_size ) , ) return None
return the indent level of the string
return the indent level of the string