mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-17 03:40:44 +03:00
Added documentation for new strict mode.
This commit is contained in:
parent
aecd8f7114
commit
955074c634
@ -49,6 +49,7 @@ To update to the latest version:
|
||||
* [Getting Started with Type Checking](/docs/getting-started.md)
|
||||
* [Command-line Options](/docs/command-line.md)
|
||||
* [Configuration](/docs/configuration.md)
|
||||
* [Comments](/docs/comments.md)
|
||||
* [Import Resolution](/docs/import-resolution.md)
|
||||
* [Building & Debugging](/docs/build-debug.md)
|
||||
* [Pyright Internals](/docs/internals.md)
|
||||
|
20
docs/comments.md
Normal file
20
docs/comments.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Comments
|
||||
|
||||
Some behaviors of pyright can be controlled through the use of comments within the source file.
|
||||
|
||||
## Type Annotations
|
||||
Verisons of Python prior to 3.6 did not support type annotations for variables. Pyright honors type annotations found within a comment at the end of the same line where a variable is assigned.
|
||||
|
||||
```
|
||||
offsets = [] # type: List[int]
|
||||
|
||||
self._target = 3 # type: Union[int, str]
|
||||
```
|
||||
|
||||
## File-level Type Controls
|
||||
Strict typing controls (where all supported type-checking switches generate errors) can be enabled for a file through the use of a special comment. Typically this comment is placed at or near the top of a code file on its own line.
|
||||
|
||||
```
|
||||
# pyright: strict
|
||||
```
|
||||
|
@ -6,6 +6,8 @@ If no venvPath is specified, Pyright falls back to the paths found in the defaul
|
||||
|
||||
The Pyright configuration file supports “execution environment” definitions, each of which can define additional paths. These are searched in addition to the venv or PYTHONPATH directories.
|
||||
|
||||
If Pyright is reporting import resolution errors, additional diagnostic information may help you determine why. If you are using the command-line version, try adding the “--verbose” switch. If you are using the VS Code extension, look at the “Output” window (View -> Output) and choose the “Pyright” view from the popup menu.
|
||||
|
||||
|
||||
## Importance of Type Stub Files
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user