Skip to content

Consider not allowing materialization to Never to provide assignability #3579

@refi64

Description

@refi64

Summary

I feel like this is probably a dupe of something, but I can't find anything like this. playground

from typing import Any

def f(i: int) -> None:
    pass

def g(x: Any) -> None:
    if isinstance(x, str):
        f(x) # passes?

def h(x: int | str) -> None:
    if isinstance(x, str):
        f(x) # correctly fails: Expected `int`, found `str`

I'm not aware of any type-system reason f(x) in g should succeed, and it seems to get caught by other type checkers.

Version

f9ba228f6 (playground)

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainertype propertiessubtyping, assignability, equivalence, and more

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions