Skip to content

Real error location not shown #107

Open
@skogsbaer

Description

@skogsbaer

Here is testcase test-data/testTypesDict4.py:

from wypp import *

def foo(d: dict[str, Callable[[], str]]) -> list[str]:
    d['x'] = lambda: 'x' # ok
    res = []
    for k, f in d.items():
        res.append(f())
    return res

def bar(d: dict[str, Callable[[], str]]) -> list[str]:
    return foo(d)

func = lambda: 42
bar({'y': func})  # error

The real error location is not shown. The output is:

Traceback (most recent call last):
  File "test-data/testTypesDict4.py", line 14, in <module>
    bar({'y': func})  # error
  File "test-data/testTypesDict4.py", line 11, in bar
    return foo(d)
  File "test-data/testTypesDict4.py", line 7, in foo
    res.append(f())
WyppTypeError: dict is not a dict[str, Callable[[], str]]
given:    {'y': <function <lambda> at 0x10b94d090>, 'x': <untypy.impl.callable.TypedCallable object at 0x10b9a2dd0>}
expected: value of type dict[str, Callable[[], str]]

context: foo(d: dict[str, Callable[[], str]]) -> list[str]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
declared at: test-data/testTypesDict4.py:3
caused by: test-data/testTypesDict4.py:11
  |     return foo(d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions