I’ve published pyright 1.1.352, which has support for draft PEP 728. To use this functionality, you will need to set enableExperimentalFeatures
to true
in your pyright config.
This version incorporates the latest thinking about type consistency being valid in only one direction.
Here’s a code sample in pyright playground
If you install pyright via the community-maintained Python wrapper (published in pypi), it may take several hours before the new version is available.
If you find any issues with the PEP 728 implementation in pyright, please file bugs in the pyright issue tracker.
If you’re curious, here’s the commit for this change. Compared to other typing PEPs, this change was more complex than some but less complex than others — roughly in the middle of the spectrum.