Skip to content

(🐞) reveal_type on a lambda parameter from an overloaded higher order function shows two results #11953

@KotlinIsland

Description

@KotlinIsland

Here the type of value is an non-inferred int, and there is only one usage of reveal_type, yet mypy is outputting two results (one of which is incorrect)

reveal_locals() shows two entries for value, but one being None not Any.

from typing import overload, Callable

@overload
def bar() -> None: ...
@overload
def bar(fn: Callable[[int], object]) -> None: ...

def bar(fn: object=1) -> None: ...
    

bar(lambda value: reveal_type(value))
bar(lambda value: reveal_locals())
main.py:11: note: Revealed type is "Any"
main.py:11: note: Revealed type is "builtins.int"
main.py:12: note: Revealed local types are:
main.py:12: note:     value: None
main.py:12: note:     value: builtins.int
Success: no issues found in 1 source file

Without removing duplicate messages you get this:

test.py:12: note: Revealed local types are:
test.py:12: note:     value: None
test.py:12: note: Revealed local types are:
test.py:12: note:     value: builtings.int

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions