Skip to content

Commit d435665

Browse files
committed
Explicitly put pyright in standard mode
It is implicitly in standard mode, but vscode does not know this, so only reports basic mode errors. This change makes vscode show the same errors that pyright does
1 parent ef12f1b commit d435665

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

docs/how-to/strict-mode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ For projects using pyright you can enable strict mode for stricter than normal t
44

55
## Configuration
66

7-
Add the `strict` line to `pyproject.toml` as follows:
7+
Change the `typeCheckingMode` line to `"strict"` in `pyproject.toml` as follows:
88

99
```toml
1010
[tool.pyright]
11-
strict = ["src", "tests"]
11+
typeCheckingMode = "strict"
1212
reportMissingImports = false # Ignore missing stubs in imported modules
1313
```
1414

template/pyproject.toml.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ name = "{{ author_name }}"
5252
version_file = "src/{{ package_name }}/_version.py"
5353
{% if type_checker=="pyright" %}
5454
[tool.pyright]
55+
typeCheckingMode = "standard"
5556
reportMissingImports = false # Ignore missing stubs in imported modules
5657
{% endif %}{% if type_checker=="mypy" %}
5758
[tool.mypy]

tests/test_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ def test_works_in_pyright_strict_mode(tmp_path: Path):
157157

158158
# Enable strict mode
159159
run_pipe(
160-
f'sed -i \'/\\[tool.pyright\\]/a\\strict = ["src", "tests"]\' {pyproject_toml}'
160+
'sed -i \'s|typeCheckingMode = "standard"|typeCheckingMode = "strict"|\''
161+
f" {pyproject_toml}"
161162
)
162163

163164
# Ensure pyright is still happy

0 commit comments

Comments
 (0)