basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

make descriptors typesafe

Open KotlinIsland opened this issue 1 year ago • 0 comments

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:

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

KotlinIsland avatar Jan 13 '24 04:01 KotlinIsland