def _check_reversed(self, node):
    'check that the argument to `reversed` is a sequence'
    try:
        argument = utils.safe_infer(utils.get_argument_from_call(node, position=0))
    except utils.NoSuchArgumentError:
        pass
    else:
        if (argument is astroid.Uninferable):
            return
        if (argument is None):
            if isinstance(node.args[0], astroid.Call):
                try:
                    func = next(node.args[0].func.infer())
                except astroid.InferenceError:
                    return
                if ((getattr(func, 'name', None) == 'iter') and utils.is_builtin_object(func)):
                    self.add_message('bad-reversed-sequence', node=node)
            return
        if isinstance(argument, (astroid.List, astroid.Tuple)):
            return
        if isinstance(argument, astroid.Instance):
            if any((((ancestor.name == 'dict') and utils.is_builtin_object(ancestor)) for ancestor in itertools.chain((argument._proxied,), argument._proxied.ancestors()))):
                try:
                    argument.locals[REVERSED_PROTOCOL_METHOD]
                except KeyError:
                    self.add_message('bad-reversed-sequence', node=node)
                return
        if hasattr(argument, 'getattr'):
            for methods in REVERSED_METHODS:
                for meth in methods:
                    try:
                        argument.getattr(meth)
                    except astroid.NotFoundError:
                        break
                else:
                    break
            else:
                self.add_message('bad-reversed-sequence', node=node)
        else:
            self.add_message('bad-reversed-sequence', node=node)
check that the argument to `reversed` is a sequence
def _check_reversed(self, node):
    
    try:
        argument = utils.safe_infer(utils.get_argument_from_call(node, position=0))
    except utils.NoSuchArgumentError:
        pass
    else:
        if (argument is astroid.Uninferable):
            return
        if (argument is None):
            if isinstance(node.args[0], astroid.Call):
                try:
                    func = next(node.args[0].func.infer())
                except astroid.InferenceError:
                    return
                if ((getattr(func, 'name', None) == 'iter') and utils.is_builtin_object(func)):
                    self.add_message('bad-reversed-sequence', node=node)
            return
        if isinstance(argument, (astroid.List, astroid.Tuple)):
            return
        if isinstance(argument, astroid.Instance):
            if any((((ancestor.name == 'dict') and utils.is_builtin_object(ancestor)) for ancestor in itertools.chain((argument._proxied,), argument._proxied.ancestors()))):
                try:
                    argument.locals[REVERSED_PROTOCOL_METHOD]
                except KeyError:
                    self.add_message('bad-reversed-sequence', node=node)
                return
        if hasattr(argument, 'getattr'):
            for methods in REVERSED_METHODS:
                for meth in methods:
                    try:
                        argument.getattr(meth)
                    except astroid.NotFoundError:
                        break
                else:
                    break
            else:
                self.add_message('bad-reversed-sequence', node=node)
        else:
            self.add_message('bad-reversed-sequence', node=node)