KotlinIsland / KotlinIsland/basedmypy

make descriptors typesafe

Open
#617 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
202
Forks
6
PR merge metrics
No merged PRs in 30d

Description

```py
class A:
pass
class D(A):
def __get__(a, b, c): return None # no error
class C:
d: A = D()
reveal_type(A.d) # A, at runtime it will be None
```

But you should still be able to return something different if you aren't subtyping another class:
```py
class A:
def __get__(a, b, c): return None

class C:
a = A()
reveal_type(C.a) # None
```

This would mean that `FunctionType` would not extend `Callable`,
- see #614

Contributor guide

Open the contributing guide

Research direction

Start by investigating the type checker's descriptor handling and read the related discussion in #614. Use the two examples in this issue to define the expected reveal_type results for subclassed and standalone descriptors; the work is done when those cases are typed as shown and FunctionType no longer extends Callable as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.