Support PEP 742 (TypeIs)
JelleZijlstra opened this issue · comments
Jelle Zijlstra commented
Please add support for the TypeIs
special form from PEP 742. Pytype support would help enable us to use the new feature in typeshed.
I am willing to work on this myself, but I might need some help getting the tests to run; when I last tried to build pytype locally, CMake didn't work.
Rebecca Chen commented
I'll work on this.
Jelle Zijlstra commented
Thanks! I already implemented it in both mypy and pyanalyze and it was pretty easy to do, essentially combining the mechanics of TypeGuard with the narrowing semantics of isinstance()
. My mypy PR has a set of test cases that may be useful: python/mypy#16898