Skip to content

Commit 955074c

Browse files
committed
Added documentation for new strict mode.
1 parent aecd8f7 commit 955074c

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ To update to the latest version:
4949
* [Getting Started with Type Checking](/docs/getting-started.md)
5050
* [Command-line Options](/docs/command-line.md)
5151
* [Configuration](/docs/configuration.md)
52+
* [Comments](/docs/comments.md)
5253
* [Import Resolution](/docs/import-resolution.md)
5354
* [Building & Debugging](/docs/build-debug.md)
5455
* [Pyright Internals](/docs/internals.md)

docs/comments.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Comments
2+
3+
Some behaviors of pyright can be controlled through the use of comments within the source file.
4+
5+
## Type Annotations
6+
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.
7+
8+
```
9+
offsets = [] # type: List[int]
10+
11+
self._target = 3 # type: Union[int, str]
12+
```
13+
14+
## File-level Type Controls
15+
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.
16+
17+
```
18+
# pyright: strict
19+
```
20+

docs/import-resolution.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ If no venvPath is specified, Pyright falls back to the paths found in the defaul
66

77
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.
88

9+
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.
10+
911

1012
## Importance of Type Stub Files
1113

0 commit comments

Comments
 (0)