Skip to content

Totality Checks #388

Closed
Closed
@mvcisback

Description

@mvcisback

In a lot of typed languages, the compiler can be told to check if a function is total, handles all cases.

For Example:

def foo(x: Union[int, str]) -> str:
    if isinstance(x, int):
        return "bar"

Is only a partial function. If x is a str, then this function actually returns None.
Thus the output type should really be Union[str, NoneType]

I tested this snippet and mypy doesn't seem to catch this.
I'm not 100% sure, but I think if a function is partial, NoneType is a potential return type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions