diff --git a/README.md b/README.md index 97f498355..85d973b66 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docs/comments.md b/docs/comments.md new file mode 100644 index 000000000..8d55977b6 --- /dev/null +++ b/docs/comments.md @@ -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 +``` + diff --git a/docs/import-resolution.md b/docs/import-resolution.md index 9c93c4db2..77e4615fc 100644 --- a/docs/import-resolution.md +++ b/docs/import-resolution.md @@ -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