report unsafe `__get__` return types
Open
needs-discussion
typechecking
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
descriptors can be unsafe:
```py
class A:
pass
class B(A):
def __get__(self, *_) -> 1:
return 1
class C:
a: A = B()
C.a # static: A, runtime: 1
```
we can avoid this by reporting an error on the signature of `__get__`: "`__get__`s return type must be assignable to the super classes `__get__` (defaulting to the type of the superclass in it's absense)"
the same applies to `__set__`
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.