Skip to content

Unintended consequences of eliminating promotions with isinstance? #6180

@msullivan

Description

@msullivan

Previously, the following code:

def foo(x):
    # type: (unicode) -> None
    if isinstance(x, str):
        reveal_type(x)
    else:
        reveal_type(x)

would emit the expected types (str, unicode) in each branch
Post #6114, which removed the use of promotions when doing isinstance,
it only emits that the type is unicode and skips checking the first branch.

Is this bad? Should we be doing something else? Obviously str is not really a subtype of unicode, but there are a lot of places where things declared unicode can actually be str.

I think the intention with the first fix was to mostly to fix Union-related issues, so maybe we need a special case for non-unions? Argh.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions