Skip to content

Commit fd4feba

Browse files
authored
Enable pyright's reportUnnecessaryTypeIgnoreComment setting for the whole test_cases directory (#8683)
1 parent 3a397a2 commit fd4feba

File tree

10 files changed

+62
-19
lines changed

10 files changed

+62
-19
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ jobs:
105105
python-platform: ${{ matrix.python-platform }}
106106
python-version: ${{ matrix.python-version }}
107107
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
108+
project: ./pyrightconfig.testcases.json
109+
- uses: jakebailey/pyright-action@v1
110+
with:
111+
version: ${{ env.PYRIGHT_VERSION }}
112+
python-platform: ${{ matrix.python-platform }}
113+
python-version: ${{ matrix.python-version }}
114+
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
108115

109116
stubtest-third-party:
110117
name: Check third party stubs with stubtest

pyrightconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"typeshedPath": ".",
33
"include": [
44
"stdlib",
5-
"stubs",
6-
"test_cases"
5+
"stubs"
76
],
87
"typeCheckingMode": "basic",
98
"strictListInference": true,

pyrightconfig.stricter.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"typeshedPath": ".",
44
"include": [
55
"stdlib",
6-
"stubs",
7-
"test_cases"
6+
"stubs"
87
],
98
"exclude": [
109
"stdlib/distutils/command",

pyrightconfig.testcases.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
3+
"typeshedPath": ".",
4+
"include": [
5+
"test_cases"
6+
],
7+
"typeCheckingMode": "basic",
8+
"strictListInference": true,
9+
"strictDictionaryInference": true,
10+
"strictParameterNoneValue": true,
11+
"reportFunctionMemberAccess": "error",
12+
"reportMissingModuleSource": "none",
13+
"reportMissingTypeStubs": "error",
14+
"reportUnusedImport": "error",
15+
"reportUnusedClass": "error",
16+
"reportUnusedFunction": "error",
17+
"reportUnusedVariable": "error",
18+
"reportDuplicateImport": "error",
19+
"reportOptionalSubscript": "error",
20+
"reportOptionalMemberAccess": "error",
21+
"reportOptionalCall": "error",
22+
"reportOptionalIterable": "error",
23+
"reportOptionalContextManager": "error",
24+
"reportOptionalOperand": "error",
25+
"reportUntypedFunctionDecorator": "error",
26+
"reportUntypedClassDecorator": "error",
27+
"reportUntypedBaseClass": "error",
28+
"reportUntypedNamedTuple": "error",
29+
"reportPrivateUsage": "none",
30+
"reportConstantRedefinition": "error",
31+
"reportInvalidStringEscapeSequence": "error",
32+
"reportUnknownParameterType": "error",
33+
"reportUnknownArgumentType": "error",
34+
"reportUnknownLambdaType": "error",
35+
"reportUnknownVariableType": "error",
36+
"reportUnknownMemberType": "error",
37+
"reportMissingTypeArgument": "error",
38+
"reportUndefinedVariable": "error",
39+
"reportUnboundVariable": "error",
40+
"reportInvalidStubStatement": "error",
41+
"reportInvalidTypeVarUse": "error",
42+
"reportPropertyTypeMismatch": "error",
43+
"reportSelfClsParameterName": "error",
44+
"reportUnsupportedDunderAll": "error",
45+
"reportIncompatibleMethodOverride": "error",
46+
"reportIncompatibleVariableOverride": "error",
47+
"reportOverlappingOverload": "error",
48+
"reportUnnecessaryTypeIgnoreComment": "error",
49+
"reportMissingTypeStubs": "error",
50+
"reportMatchNotExhaustive": "error"
51+
}

test_cases/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ mypy's
4040
setting and pyright's
4141
[`reportUnnecessaryTypeIgnoreComment`](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#type-check-diagnostics-settings)
4242
setting) to test instances where a type checker *should* emit some kind of
43-
error, if the stubs are correct. Note that mypy's `--warn-unused-ignores`
44-
setting is enabled for the entire subdirectory; however, the pyright setting
45-
must be enabled on a per-file basis with
46-
`# pyright: reportUnnecessaryTypeIgnoreComment=true` at the the top of the
47-
file.
43+
error, if the stubs are correct. Both settings are enabled by default for the entire
44+
subdirectory.
4845

4946
For more information on using `assert_type` and
5047
`--warn-unused-ignores`/`reportUnnecessaryTypeIgnoreComment` to test type

test_cases/stdlib/builtins/test_dict.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# pyright: reportUnnecessaryTypeIgnoreComment=true
2-
31
from typing import Dict, Generic, Iterable, Tuple, TypeVar
42
from typing_extensions import assert_type
53

test_cases/stdlib/builtins/test_pow.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# pyright: reportUnnecessaryTypeIgnoreComment=true
2-
31
from decimal import Decimal
42
from fractions import Fraction
53
from typing import Any

test_cases/stdlib/builtins/test_sum.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# pyright: reportUnnecessaryTypeIgnoreComment=true
2-
31
from typing import Any, List, Union
42
from typing_extensions import Literal, assert_type
53

test_cases/stdlib/test_codecs.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# pyright: reportUnnecessaryTypeIgnoreComment=true
2-
31
import codecs
42
from typing_extensions import assert_type
53

test_cases/stdlib/test_unittest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# pyright: reportUnnecessaryTypeIgnoreComment=true
2-
31
import unittest
42
from datetime import datetime, timedelta
53
from decimal import Decimal

0 commit comments

Comments
 (0)