def __call__()

in python/sedona/spark/utils/meta.py [0:0]


    def __call__(self, *args, **kwargs):
        """
        Call a method based on type signature of the arguments
        :param args:
        :param kwargs:
        :return:
        """
        if self._is_static:
            types_from_args = tuple(type(arg) for arg in args)
        else:
            types_from_args = tuple(type(arg) for arg in args[1:])

        number_of_arguments = len(types_from_args)
        number_of_kwargs = len(kwargs)

        methods_shortened_to_args = [
            [tuple(tp[1] for tp in types[:number_of_arguments]), types, method]
            for types, method in self._methods.items()
        ]
        methods_which_are_correct = []

        for function_methods in methods_shortened_to_args:
            is_instances = all(
                [
                    is_subclass_with_typing(from_args, from_definition)
                    for from_args, from_definition in zip(
                        types_from_args, function_methods[0]
                    )
                ]
            )

            if is_instances:
                methods_which_are_correct.append(function_methods[1:])

        if methods_which_are_correct:
            for correct_params, method in methods_which_are_correct:
                if len(correct_params) != number_of_arguments + number_of_kwargs:
                    continue
                else:
                    for name, param in correct_params[number_of_arguments:]:
                        try:
                            value = type(kwargs[name])
                        except KeyError:
                            break
                        if is_subclass_with_typing(value, param):
                            pass
                        else:
                            break
                    else:
                        if self._is_static:
                            return method.__get__(self).__call__(*args, **kwargs)
                        return method(*args, **kwargs)

            raise InvalidParametersException("No matching method for given types found")

        else:
            raise InvalidParametersException("No matching method for given types found")