On Fri, Feb 12, 2021 at 12:14 PM Jim J. Jewett <jimjjewett@gmail.com> wrote:
Current PEP 647 draft says:

"Some built-in type guards provide narrowing for both positive and negative tests (in both the if and else clauses)"

Should there be a separate (sub-?) type for those TypeGuards that *do* allow narrowing even on a False?  Leaving it as an implementation detail available only to (some) built-in types seems to confuse the issue in both directions.

I think the PEP is using the term in a wider sense here, referring to things like `isinstance(x, C)` and `x is not None`. Note that mypy (at least) also recognizes `if x:` as narrowing `Optional[T]` to `T`, but there in the else clause we *cannot* assume that x is not a T, because it could be a falsey instance.
 
--
--Guido van Rossum (python.org/~guido)