Skip to content

Unions that include Any should probably not just become Any #1642

Closed
@ddfisher

Description

@ddfisher

Currently, UnionType.make_simplified_union will return an Any if any of the types passed in are Any. This probably doesn't make sense.

As a simple example, if we have:

def f(x: Union[str, Any]) -> int:
    return x + 1

(This example looks a little silly, but this Any might not be explicit -- it could e.g. be a class from a --silent-imports module.)
This is clearly unsafe. I think we should still require an isinstance check.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions