Skip to content

Error message for typing_extensions.Self is confusing #14089

Closed
@orsinium

Description

@orsinium

Bug Report

It looks like mypy doesn't support typing_extensions.Self. I know that Rome wasn't built in a day and the work in #11871 is on the way. However, while it's still in progress, I think it would be great to have a user-friendly error message that better explains the nature of the error.

To Reproduce

from typing_extensions import Self

class A:
    def f(self) -> Self:
        return self

Expected Behavior

I'd expect a user-friendly error message explaining the nature of the issue, something like this:

tmp.py:5: note: "typing_extensions.Self" is not supported yet, see #11871  [misc]

Actual Behavior

tmp.py:5: error: Variable "typing_extensions.Self" is not valid as a type  [valid-type]

Your Environment

  • Mypy version used: 0.990
  • Mypy command-line flags: mypy tmp.py
  • Mypy configuration options from mypy.ini (and other config files): -
  • Python version used: 3.10.6

#14089 (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