Skip to content

false positive errors when calling operator override that returns Never from another function that returns Never #18002

@DetachHead

Description

@DetachHead
from typing import Never

class Foo:
    def __mul__(self, value: float, /) -> Never:
        raise Exception("multiplication is banned")

    def __rmul__(self, value: float, /) -> Never: # error: Implicit return in function which does not return  [misc]
        self * value
    
    def __rmul_attempt_2__(self, value: float, /) -> Never:
        return self * value # error: Return statement in function which does not return  [misc]

playground

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