Skip to content

@disjoint_base + __new__(cls) -> Never leads to confusing error message #22306

Open

Description

@jorenham

I ran into this while improving type coverage in PyAV (src):

from typing import Never
from typing_extensions import disjoint_base

@disjoint_base
class Cat:
    def __new__(cls, /) -> Never:
        raise RuntimeError("cannot instantiate Cat")
main.py:5: error: Value of type variable "_TC" of "disjoint_base" cannot be "Callable[[], Never]"  [type-var]

https://mypy-play.net/?mypy=latest&python=3.14&gist=1f1d2c81fd843d4ba2d37355bf18b5dd

I don't think this should've lead to an error, let alone such a confusing one (from the perspective of an average typing user, because I can imagine that for mypy devs this error message is actually pretty helpful).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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