pytype icon indicating copy to clipboard operation
pytype copied to clipboard

Support PEP 647: TypeGuard

Open JelleZijlstra opened this issue 3 years ago • 6 comments

I'd like to start using https://www.python.org/dev/peps/pep-0647/ in typeshed. Do you have any plans in that direction already?

I can look into adding basic support to unblock typeshed, which would mean simply interpreting TypeGuard[...] as an alias for bool.

JelleZijlstra avatar May 11 '21 01:05 JelleZijlstra

No plans yet, but as you said, it shouldn't be too difficult for us to just interpret TypeGuard as bool for now.

rchen152 avatar May 12 '21 16:05 rchen152

I should have some time to do this tomorrow afternoon.

rchen152 avatar May 12 '21 16:05 rchen152

Thanks!

JelleZijlstra avatar May 12 '21 16:05 JelleZijlstra

I've implemented rewriting TypeGuard[X] to bool in stubs; I'll try to do a release tomorrow.

rchen152 avatar May 13 '21 23:05 rchen152

Ok, pytype 2021.05.14 is out. Please let me know if you run into any issues using TypeGuard in stubs.

rchen152 avatar May 14 '21 23:05 rchen152

Thanks again!

JelleZijlstra avatar May 14 '21 23:05 JelleZijlstra

We've got a basic implementation of TypeGuard done. It'll be in the next release, hopefully tomorrow.

rchen152 avatar Nov 17 '22 23:11 rchen152