def _check_chained_comparison(self, node):
if node.op != "<STR_LIT>" or len(node.values) < <NUM_LIT:2>:<EOL><INDENT>return<EOL><DEDENT>def _find_lower_upper_bounds(comparison_node, uses):<EOL><INDENT>left_operand = comparison_node.left<EOL>for operator, right_operand in comparison_node.ops:<EOL><INDENT>for operand in (left_operand, right_operand):<EOL><INDENT>value = None<EOL>if isinstance(operand, astroid.Name):<EOL><INDENT>value = operand.name<EOL><DEDENT>elif isinstance(operand, astroid.Const):<EOL><INDENT>value = operand.value<EOL><DEDENT>if value is None:<EOL><INDENT>continue<EOL><DEDENT>if operator in ("<STR_LIT:<>", "<STR_LIT>"):<EOL><INDENT>if operand is left_operand:<EOL><INDENT>uses[value]["<STR_LIT>"].add(comparison_node)<EOL><DEDENT>elif operand is right_operand:<EOL><INDENT>uses[value]["<STR_LIT>"].add(comparison_node)<EOL><DEDENT><DEDENT>elif operator in ("<STR_LIT:>>", "<STR_LIT>"):<EOL><INDENT>if operand is left_operand:<EOL><INDENT>uses[value]["<STR_LIT>"].add(comparison_node)<EOL><DEDENT>elif operand is right_operand:<EOL><INDENT>uses[value]["<STR_LIT>"].add(comparison_node)<EOL><DEDENT><DEDENT><DEDENT>left_operand = right_operand<EOL><DEDENT><DEDENT>uses = collections.defaultdict(<EOL>lambda: {"<STR_LIT>": set(), "<STR_LIT>": set()}<EOL>)<EOL>for comparison_node in node.values:<EOL><INDENT>if isinstance(comparison_node, astroid.Compare):<EOL><INDENT>_find_lower_upper_bounds(comparison_node, uses)<EOL><DEDENT><DEDENT>for _, bounds in uses.items():<EOL><INDENT>num_shared = len(bounds["<STR_LIT>"].intersection(bounds["<STR_LIT>"]))<EOL>num_lower_bounds = len(bounds["<STR_LIT>"])<EOL>num_upper_bounds = len(bounds["<STR_LIT>"])<EOL>if num_shared < num_lower_bounds and num_shared < num_upper_bounds:<EOL><INDENT>self.add_message("<STR_LIT>", node=node)<EOL>break<EOL><DEDENT><DEDENT>
Check if there is any chained comparison in the expression.

        Add a refactoring message if a boolOp contains comparison like a < b and b < c,
        which can be chained as a < b < c.

        Care is taken to avoid simplifying a < b < c and b < d.