Skip to content

reveal_type() may affect inferred type / overload resolution #6328

@JukkaL

Description

@JukkaL

The first filter call below generates an error when using --py2, but the same call without reveal_type(...) is fine:

from typing import Any, List

a = 0  # type: Any

x = filter(None, reveal_type(a))  # type: List[str]  # Error
x2 = filter(None, a)  # type: List[str]  # No error

The error message is Incompatible types in assignment (expression has type "Tuple[<nothing>, ...]", variable has type "List[str]").

reveal_type should have no effect on inferred types, since it's often used to diagnose issues with type inference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions