mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-17 03:40:44 +03:00
Updated documentation.
This commit is contained in:
parent
1c1ce2a7ea
commit
fcdaeba35e
10
README.md
10
README.md
@ -13,8 +13,12 @@ Pyright supports [configuration files](/docs/configuration.md) that provide gran
|
||||
* [PEP 526](https://www.python.org/dev/peps/pep-0526/) syntax for variable annotations
|
||||
* [PEP 544](https://www.python.org/dev/peps/pep-0544/) structural subtyping
|
||||
* [PEP 589](https://www.python.org/dev/peps/pep-0589/) typed dictionaries
|
||||
* [PEP 593](https://www.python.org/dev/peps/pep-0593/) flexible variable annotations
|
||||
* [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
|
||||
* Type inference for function return values, instance variables, class variables, and globals
|
||||
* Smart type constraints that understand conditional code flow constructs like if/else statements
|
||||
* Type guards that understand conditional code flow constructs like if/else statements
|
||||
|
||||
### VS Code Integration
|
||||
Pyright ships as both a command-line tool and a VS Code extension that provides many powerful features that help improve programming efficiency.
|
||||
@ -66,7 +70,7 @@ To update to the latest version:
|
||||
|
||||
|
||||
## Using Pyright with VS Code Python Extension
|
||||
Pyright provides some features that overlap with functionality provided by the standard VS Code Python extension: “hover”, type completion, definitions, references, rename symbols, etc. You may see duplicate results if Pyright is installed alongside the Python extension. There is currently no way to disable this functionality in the Python extension. If you want to disable these features in Pyright, there is a setting to do so: `pyright.disableLanguageServices`.
|
||||
Pyright provides some features that overlap with functionality provided by the standard VS Code Python extension: “hover”, type completion, definitions, references, rename symbols, etc. You may see duplicate results if Pyright is installed alongside the Python extension. You can disable the duplicate language service functionality in the Python extension by setting `python.languageServer` to `None`. If you want to disable language service features in Pyright, set `pyright.disableLanguageServices` to `true`.
|
||||
|
||||
|
||||
## Documentation
|
||||
@ -83,7 +87,7 @@ Pyright provides some features that overlap with functionality provided by the s
|
||||
|
||||
|
||||
## Limitations
|
||||
Pyright currently provides support for Python 3.0 and newer. There is currently no plan to support older versions.
|
||||
Pyright provides support for Python 3.0 and newer. There is currently no plan to support older versions.
|
||||
|
||||
|
||||
## Community
|
||||
|
@ -10,12 +10,16 @@ Pyright supports [configuration files](/docs/configuration.md) that provide gran
|
||||
|
||||
### Type Checking Features
|
||||
|
||||
- [PEP 484](https://www.python.org/dev/peps/pep-0484/) type hints including generics
|
||||
- [PEP 526](https://www.python.org/dev/peps/pep-0526/) syntax for variable annotations
|
||||
- [PEP 544](https://www.python.org/dev/peps/pep-0544/) structural subtyping
|
||||
- [PEP 589](https://www.python.org/dev/peps/pep-0589/) typed dictionaries
|
||||
- Type inference for function return values, instance variables, class variables, and globals
|
||||
- Smart type constraints that understand conditional code flow constructs like if/else statements
|
||||
* [PEP 484](https://www.python.org/dev/peps/pep-0484/) type hints including generics
|
||||
* [PEP 526](https://www.python.org/dev/peps/pep-0526/) syntax for variable annotations
|
||||
* [PEP 544](https://www.python.org/dev/peps/pep-0544/) structural subtyping
|
||||
* [PEP 589](https://www.python.org/dev/peps/pep-0589/) typed dictionaries
|
||||
* [PEP 593](https://www.python.org/dev/peps/pep-0593/) flexible variable annotations
|
||||
* [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
|
||||
* Type inference for function return values, instance variables, class variables, and globals
|
||||
* Type guards that understand conditional code flow constructs like if/else statements
|
||||
|
||||
### VS Code Language Features
|
||||
|
||||
|
@ -31,9 +31,9 @@ The [tokenizer](https://github.com/Microsoft/pyright/blob/master/server/src/pars
|
||||
|
||||
The [parser](https://github.com/Microsoft/pyright/blob/master/server/src/parser/parser.ts) is responsible for converting the token stream into a parse tree. A generalized [parseTreeWalker](https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/parseTreeWalker.ts) provides a convenient way to traverse the parse tree. All subsequent analysis phases utilize the parseTreeWalker.
|
||||
|
||||
The [binder](https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/binder.ts) is responsible for building scopes and populating the symbol table for each scope. It does not perform any type checking, but it detects and reports some semantic errors that will result in unintended runtime exceptions. It also detects and reports inconsistent name bindings (e.g. a variable that uses both a global and nonlocal binding in the same scope). The binder also builds a "reverse code flow graph" for each scope, allowing the type analyzer to determine a symbol's type at any point in the code flow based on its antecedents.
|
||||
The [binder](https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/binder.ts) is responsible for building scopes and populating the symbol table for each scope. It does not perform any type checking, but it detects and reports some semantic errors that will result in unintended runtime exceptions. It also detects and reports inconsistent name bindings (e.g. a variable that uses both a global and nonlocal binding in the same scope). The binder also builds a “reverse code flow graph” for each scope, allowing the type analyzer to determine a symbol’s type at any point in the code flow based on its antecedents.
|
||||
|
||||
The [checker](https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/checker.ts) is responsible for checking all of the statements and expressions within a source file. It relies heavily on the [typeEvaluator](https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/typeEvaluator.ts) module, which performs most of the heavy lifting. The checker doesn't run on all files, only those that require full diagnostic output. For example, if a source file is not part of the program but is imported by the program, the checker doesn't need to run on it.
|
||||
The [checker](https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/checker.ts) is responsible for checking all of the statements and expressions within a source file. It relies heavily on the [typeEvaluator](https://github.com/Microsoft/pyright/blob/master/server/src/analyzer/typeEvaluator.ts) module, which performs most of the heavy lifting. The checker doesn’t run on all files, only those that require full diagnostic output. For example, if a source file is not part of the program but is imported by the program, the checker doesn’t need to run on it.
|
||||
|
||||
## Type Checking Concepts
|
||||
|
||||
@ -41,7 +41,7 @@ Pyright uses an internal type called “Unknown” to represent types that are n
|
||||
|
||||
Pyright attempts to infer the types of global (module-level) variables, class variables, instance variables, and local variables. Return and yield types are also inferred. If type annotations are provided in these cases, the type annotation overrides any inferred types.
|
||||
|
||||
Pyright supports type constraints (sometimes called “path constraints” or "type guards") to track assumptions that apply within certain code flow paths. For example, consider the following code:
|
||||
Pyright supports type constraints (sometimes called “path constraints” or “type guards”) to track assumptions that apply within certain code flow paths. For example, consider the following code:
|
||||
```python
|
||||
def (a: Optional[Union[str, List[str]]):
|
||||
if isinstance(a, str):
|
||||
|
Loading…
Reference in New Issue
Block a user