Skip to content

Commit 2f9da23

Browse files
Document how to enable strict mode
1 parent ccf2b90 commit 2f9da23

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/how-to/strict-mode.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Enable Pyright's Strict Mode
2+
3+
For projects using pyright you can enable strict mode for stricter than normal type checking. See [the docs](https://github.com/microsoft/pyright/blob/main/docs/configuration.md) for a full breakdown. The primary benefits are increased confidence in code that has been more thoroughly analyzed and a shorter development time thanks to fast feedback from the type checker.
4+
5+
## Configuration
6+
7+
Add the `strict` line to `pyproject.toml` as follows:
8+
9+
```toml
10+
[tool.pyright]
11+
strict = ["src", "tests"]
12+
reportMissingImports = false # Ignore missing stubs in imported modules
13+
```
14+
15+
## Third Party Libraries
16+
17+
Strict mode does not usually work well with libraries that do not have [type stubs](https://github.com/microsoft/pyright/blob/main/docs/type-stubs.md), you will likely need a `# type: ignore` on any line that directly uses the library code. This may limit the usefulness of pyright but it can still be worth doing to ensure your own code is internally consistent.

0 commit comments

Comments
 (0)