-
Notifications
You must be signed in to change notification settings - Fork 138
Open
Description
Describe the Bug
This is happening in django with django-types, but minimal reproduction is independent:
from typing import ClassVar, Generic, Self, TypeVar, reveal_type
MT = TypeVar("MT", bound="Model")
class Manager(Generic[MT]):
def get(self) -> MT: ...
class Model:
objects: ClassVar[Manager[Self]]
class UserProfile(Model):
...
def get_user_profile() -> UserProfile:
v = UserProfile.objects.get()
reveal_type(v)
return v
INFO revealed type: Self@Model [reveal-type]
--> /tmp/test.py:16:16
|
16 | reveal_type(v)
| ---
|
ERROR Returned type `Self@Model` is not assignable to declared return type `UserProfile` [bad-return]
--> /tmp/test.py:17:12
|
17 | return v
| ^
|
INFO 1 error
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Metadata
Metadata
Assignees
Labels
No labels