Stewori / pytypes

Typing-toolbox for Python 3 _and_ 2.7 w.r.t. PEP 484.
Apache License 2.0
200 stars 20 forks source link

please improve error messages when functions decorated with @typechecked are called with incorrect types #112

Open sg-s opened 2 years ago

sg-s commented 2 years ago

this is what my function looks like:

@typechecked
def my_func(
    a: int,
    b: str,
):

I (deliberately) call the function with an incorrect type using:

my_func(1,1)

and I get this cryptic error message:

  called with incompatible types:
Expected: Tuple[int, str]
Received: Tuple[int, int]

this is not very helpful because it doesn't flag the variable that is causing the problem, that is failing the type check.