Skip to content

error: Overloaded function signatures 1 and 2 overlap with incompatible return types #4020

Closed
@czhang03

Description

@czhang03

I am trying to implement currying in python, it passes Pycharm type checks (which is not as comprehensive as mypy), but my py gives me tons of error like this:

pythonz\basic.py:54: error: Overloaded function signatures 1 and 2 overlap with incompatible return types

Here is a sample of my code

@overload
def curry(f: Callable[[A1], R]) -> PZFunc[A1, R]:
    """curry a function with 1 parameter"""
    ...


@overload
def curry(f: Callable[[A1, A2], R]) -> PZFunc[A1, PZFunc[A2, R]]:
    """curry a function with 2 parameters"""
    ...

def curry(f: Callable) -> PZFunc:
    """To curry a function, only support less than 7 parameters

    :param f: the normal un-curried python function
    :return: A curried PythonZ function
    """
    return PZFunc(lambda x: curry(lambda *args: f(x, *args)))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions