pyre-check icon indicating copy to clipboard operation
pyre-check copied to clipboard

How to support the Descriptor Class type check?

Open GuangTianLi opened this issue 6 years ago • 3 comments

class Foo:
    def __get__(self, instance, owner) -> str:
        ...
    def __set__(self, instance, value: str) -> None:
        ...
class Test:
   foo = Foo()

test = Test()
test.foo.split() #  Undefined attribute [16]: `Foo` has no attribute `split`.
test.foo = 1 # There should be an error.

GuangTianLi avatar Jan 17 '19 03:01 GuangTianLi

That is correct, Pyre does not recognize descriptor classes just yet. On the other hand, Pyre supports properties and @property annotations already, so if your use case is simple enough you might get type coverage that way.

dark avatar Jan 18 '19 00:01 dark

I know that, but my case is ORM which can not be simplified by the @property. I think you can refer to the mypy.

GuangTianLi avatar Jan 18 '19 04:01 GuangTianLi

It looks like support was added in https://github.com/facebook/pyre-check/commit/64487f55ce9fba75d894701eb35b23a147743c46. Should this issue be closed out?

taion avatar Jun 15 '22 21:06 taion