Skip to content

Blamed location is wrong when return type annotation is violated #15

@skogsbaer

Description

@skogsbaer

Given the following example:

def foo(flag: bool) -> int:
    print('Hello World')
    if flag:
        return 1
    else:
        return 'you stupid'

foo(False)

we get this error:

untypy.error.UntypyTypeError
given:    'you stupid'
expected: value of type int

context: foo(flag: bool) -> int
                            ^^^
declared at: test.py:1
  1 | def foo(flag: bool) -> int:
  2 |     print('Hello World')
  3 |     if flag:
  4 |         return 1
  5 |     else:    | ...

caused by: test.py:1
  1 | def foo(flag: bool) -> int:
  2 |     print('Hello World')
  3 |     if flag:
  4 |         return 1
  5 |     else:    | ...

I would expect that the line with return 'you stupid' is blamed for the error and therefor mentioned in the "caused by" part.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions