This commit is contained in:
Keming 2022-06-22 10:08:37 +08:00 committed by GitHub
parent 50d56824c0
commit de86a34dd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ A static type checker like Pyright can add incremental value to your source code
Here is a typical progression: Here is a typical progression:
1. Install pyright (either the VS Code extension or command-line tool). 1. Install pyright (either the VS Code extension or command-line tool).
2. Write a minimal `pyrightconfig.json` that defines `include` entries. Place the config file in your projects top-level directory and commit it to your repo. Alternatively, you can add a pyright section to a `pyproject.tolm` file. For additional details and a sample config file, refer to [this documentation](https://github.com/microsoft/pyright/blob/main/docs/configuration.md). 2. Write a minimal `pyrightconfig.json` that defines `include` entries. Place the config file in your projects top-level directory and commit it to your repo. Alternatively, you can add a pyright section to a `pyproject.toml` file. For additional details and a sample config file, refer to [this documentation](https://github.com/microsoft/pyright/blob/main/docs/configuration.md).
3. Optionally enable the `python.analysis.useLibraryCodeForTypes` config option (or pass `--lib` to the command-line tool). This tells Pyright that it should attempt to infer type information from library code if a type stub is not available. 3. Optionally enable the `python.analysis.useLibraryCodeForTypes` config option (or pass `--lib` to the command-line tool). This tells Pyright that it should attempt to infer type information from library code if a type stub is not available.
4. Run pyright over your source base with the default settings. Fix any errors and warnings that it emits. 4. Run pyright over your source base with the default settings. Fix any errors and warnings that it emits.
5. Enable the `reportMissingTypeStubs` setting in the config file and add (minimal) type stub files for the imported files. You may wish to create a stubs directory within your code base — a location for all of your custom type stub files. Configure the “stubPath” config entry to refer to this directory. 5. Enable the `reportMissingTypeStubs` setting in the config file and add (minimal) type stub files for the imported files. You may wish to create a stubs directory within your code base — a location for all of your custom type stub files. Configure the “stubPath” config entry to refer to this directory.