Skip to content

Enable pyright's reportUnnecessaryTypeIgnoreComment setting for the whole test_cases directory #8683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ jobs:
python-platform: ${{ matrix.python-platform }}
python-version: ${{ matrix.python-version }}
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
project: ./pyrightconfig.testcases.json
- uses: jakebailey/pyright-action@v1
with:
version: ${{ env.PYRIGHT_VERSION }}
python-platform: ${{ matrix.python-platform }}
python-version: ${{ matrix.python-version }}
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.

stubtest-third-party:
name: Check third party stubs with stubtest
Expand Down
3 changes: 1 addition & 2 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"typeshedPath": ".",
"include": [
"stdlib",
"stubs",
"test_cases"
"stubs"
],
"typeCheckingMode": "basic",
"strictListInference": true,
Expand Down
3 changes: 1 addition & 2 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"typeshedPath": ".",
"include": [
"stdlib",
"stubs",
"test_cases"
"stubs"
],
"exclude": [
"stdlib/distutils/command",
Expand Down
51 changes: 51 additions & 0 deletions pyrightconfig.testcases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
"typeshedPath": ".",
"include": [
"test_cases"
],
"typeCheckingMode": "basic",
"strictListInference": true,
"strictDictionaryInference": true,
"strictParameterNoneValue": true,
"reportFunctionMemberAccess": "error",
"reportMissingModuleSource": "none",
"reportMissingTypeStubs": "error",
"reportUnusedImport": "error",
"reportUnusedClass": "error",
"reportUnusedFunction": "error",
"reportUnusedVariable": "error",
"reportDuplicateImport": "error",
"reportOptionalSubscript": "error",
"reportOptionalMemberAccess": "error",
"reportOptionalCall": "error",
"reportOptionalIterable": "error",
"reportOptionalContextManager": "error",
"reportOptionalOperand": "error",
"reportUntypedFunctionDecorator": "error",
"reportUntypedClassDecorator": "error",
"reportUntypedBaseClass": "error",
"reportUntypedNamedTuple": "error",
"reportPrivateUsage": "none",
"reportConstantRedefinition": "error",
"reportInvalidStringEscapeSequence": "error",
"reportUnknownParameterType": "error",
"reportUnknownArgumentType": "error",
"reportUnknownLambdaType": "error",
"reportUnknownVariableType": "error",
"reportUnknownMemberType": "error",
"reportMissingTypeArgument": "error",
"reportUndefinedVariable": "error",
"reportUnboundVariable": "error",
"reportInvalidStubStatement": "error",
"reportInvalidTypeVarUse": "error",
"reportPropertyTypeMismatch": "error",
"reportSelfClsParameterName": "error",
"reportUnsupportedDunderAll": "error",
"reportIncompatibleMethodOverride": "error",
"reportIncompatibleVariableOverride": "error",
"reportOverlappingOverload": "error",
"reportUnnecessaryTypeIgnoreComment": "error",
"reportMissingTypeStubs": "error",
"reportMatchNotExhaustive": "error"
}
7 changes: 2 additions & 5 deletions test_cases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ mypy's
setting and pyright's
[`reportUnnecessaryTypeIgnoreComment`](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#type-check-diagnostics-settings)
setting) to test instances where a type checker *should* emit some kind of
error, if the stubs are correct. Note that mypy's `--warn-unused-ignores`
setting is enabled for the entire subdirectory; however, the pyright setting
must be enabled on a per-file basis with
`# pyright: reportUnnecessaryTypeIgnoreComment=true` at the the top of the
file.
error, if the stubs are correct. Both settings are enabled by default for the entire
subdirectory.

For more information on using `assert_type` and
`--warn-unused-ignores`/`reportUnnecessaryTypeIgnoreComment` to test type
Expand Down
2 changes: 0 additions & 2 deletions test_cases/stdlib/builtins/test_dict.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# pyright: reportUnnecessaryTypeIgnoreComment=true

from typing import Dict, Generic, Iterable, Tuple, TypeVar
from typing_extensions import assert_type

Expand Down
2 changes: 0 additions & 2 deletions test_cases/stdlib/builtins/test_pow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# pyright: reportUnnecessaryTypeIgnoreComment=true

from decimal import Decimal
from fractions import Fraction
from typing import Any
Expand Down
2 changes: 0 additions & 2 deletions test_cases/stdlib/builtins/test_sum.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# pyright: reportUnnecessaryTypeIgnoreComment=true

from typing import Any, List, Union
from typing_extensions import Literal, assert_type

Expand Down
2 changes: 0 additions & 2 deletions test_cases/stdlib/test_codecs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# pyright: reportUnnecessaryTypeIgnoreComment=true

import codecs
from typing_extensions import assert_type

Expand Down
2 changes: 0 additions & 2 deletions test_cases/stdlib/test_unittest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# pyright: reportUnnecessaryTypeIgnoreComment=true

import unittest
from datetime import datetime, timedelta
from decimal import Decimal
Expand Down