Updated README to refer to PEP 647.

This commit is contained in:
Eric Traut 2021-01-03 12:13:20 -08:00
parent 5b05cacc57
commit f9db4dcc8a
3 changed files with 4 additions and 1 deletions

View File

@ -21,6 +21,7 @@ Pyright supports [configuration files](/docs/configuration.md) that provide gran
* [PEP 604](https://www.python.org/dev/peps/pep-0604/) complementary syntax for unions
* [PEP 612](https://www.python.org/dev/peps/pep-0612/) parameter specification variables
* [PEP 613](https://www.python.org/dev/peps/pep-0613/) explicit type aliases
* [PEP 647](https://www.python.org/dev/peps/pep-0647/) user-defined type guards
* Type inference for function return values, instance variables, class variables, and globals
* Type guards that understand conditional code flow constructs like if/else statements

View File

@ -141,7 +141,8 @@ In addition to assignment-based type narrowing, Pyright supports the following t
* `isinstance(x, T)` (where T is a type or a tuple of types)
* `issubclass(x, T)` (where T is a type or a tuple of types)
* `callable(x)`
* `f(x)` (where f is a user-defined type guard that is annotated to return a TypeGuard[T] type)
* `f(x)` (where f is a user-defined type guard as defined in [PEP 647](https://www.python.org/dev/peps/pep-0647/))
* x (where x is any expression that is statically verifiable to be truthy or falsy in all cases)
Expressions supported for type guards include simple names, member access chains (e.g. `a.b.c.d`), the unary `not` operator, the binary `and` and `or` operators, and call expressions. Other operators (such as arithmetic operators or subscripts) are not supported.

View File

@ -22,6 +22,7 @@ Pyright supports [configuration files](/docs/configuration.md) that provide gran
* [PEP 604](https://www.python.org/dev/peps/pep-0604/) complementary syntax for unions
* [PEP 612](https://www.python.org/dev/peps/pep-0612/) parameter specification variables
* [PEP 613](https://www.python.org/dev/peps/pep-0613/) explicit type aliases
* [PEP 647](https://www.python.org/dev/peps/pep-0647/) user-defined type guards
* Type inference for function return values, instance variables, class variables, and globals
* Type guards that understand conditional code flow constructs like if/else statements