Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

self argument is not assignable to variable typed as Self #17760

Open
DetachHead opened this issue Sep 12, 2024 · 1 comment
Open

self argument is not assignable to variable typed as Self #17760

DetachHead opened this issue Sep 12, 2024 · 1 comment
Labels
bug mypy got something wrong

Comments

@DetachHead
Copy link
Contributor

from typing import Self

class Foo:
    def foo(self) -> None:
        asdf: Self = self
main.py:5: error: Incompatible types in assignment (expression has type "Foo", variable has type "Self")  [assignment]
Found 1 error in 1 file (checked 1 source file)

playground

@DetachHead DetachHead added the bug mypy got something wrong label Sep 12, 2024
@JamesParrott
Copy link

JamesParrott commented Sep 12, 2024

I agree this could be improved. FYI, typing self: Self works:

playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants