diff --git a/pyrightconfig.json b/pyrightconfig.json index 9fc8f5f5f..c44602107 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -9,35 +9,24 @@ // test cases use a custom config file "stubs/**/@tests/test_cases" ], - "typeCheckingMode": "basic", - "strictListInference": true, - "strictDictionaryInference": true, - "strictSetInference": true, - "reportFunctionMemberAccess": "error", - "reportMissingTypeStubs": "error", - "reportUnusedImport": "error", - "reportUnusedClass": "error", - "reportUnusedFunction": "error", - "reportUnusedVariable": "error", - "reportDuplicateImport": "error", - "reportUntypedFunctionDecorator": "error", - "reportUntypedClassDecorator": "error", - "reportUntypedBaseClass": "error", - "reportUntypedNamedTuple": "error", - "reportConstantRedefinition": "error", - "reportInvalidStringEscapeSequence": "error", - "reportUnknownArgumentType": "error", - "reportUnknownLambdaType": "error", - "reportMissingTypeArgument": "error", - "reportInvalidStubStatement": "error", - "reportInvalidTypeVarUse": "error", - "reportUnsupportedDunderAll": "error", - "reportInconsistentConstructor": "error", - "reportTypeCommentUsage": "error", - "reportUnnecessaryComparison": "error", + "typeCheckingMode": "strict", + // Allowed in base settings for incomplete stubs, checked in stricter settings + "reportIncompleteStub": "none", + "reportMissingParameterType": "none", + "reportUnknownMemberType": "none", + "reportUnknownParameterType": "none", + "reportUnknownVariableType": "none", + // Extra strict settings + "reportCallInDefaultInitializer": "error", + "reportImplicitStringConcatenation": "error", "reportUnnecessaryTypeIgnoreComment": "error", // Leave "type: ignore" comments to mypy "enableTypeIgnoreComments": false, + // No effect in stubs + "reportMissingSuperCall": "none", + "reportUninitializedInstanceVariable": "none", + // stdlib stubs trigger reportShadowedImports + "reportShadowedImports": "none", // Stubs are allowed to use private variables "reportPrivateUsage": "none", // Stubs don't need the actual modules to be installed diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index dc8605bfe..80f5e6f62 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -75,13 +75,21 @@ "stubs/vobject", ], "typeCheckingMode": "strict", + // TODO: Complete incomplete stubs + "reportIncompleteStub": "none", + // Extra strict settings + "reportCallInDefaultInitializer": "error", + "reportImplicitStringConcatenation": "error", "reportUnnecessaryTypeIgnoreComment": "error", // Leave "type: ignore" comments to mypy "enableTypeIgnoreComments": false, + // No effect in stubs + "reportMissingSuperCall": "none", + "reportUninitializedInstanceVariable": "none", + // stdlib stubs trigger reportShadowedImports + "reportShadowedImports": "none", // Stubs are allowed to use private variables "reportPrivateUsage": "none", - // TODO: Complete incomplete stubs - "reportIncompleteStub": "none", // Stubs don't need the actual modules to be installed "reportMissingModuleSource": "none", // Incompatible overrides and property type mismatches are out of typeshed's control diff --git a/pyrightconfig.testcases.json b/pyrightconfig.testcases.json index 13a7d8b37..059df46cc 100644 --- a/pyrightconfig.testcases.json +++ b/pyrightconfig.testcases.json @@ -6,13 +6,26 @@ "stubs/**/@tests/test_cases" ], "typeCheckingMode": "strict", - // Using unspecific "type ignore" comments in test_cases. + // Extra strict settings + "reportShadowedImports": "error", // Don't accidentally name a file something that shadows stdlib + "reportImplicitStringConcatenation": "error", + "reportUninitializedInstanceVariable": "error", + "reportUnnecessaryTypeIgnoreComment": "error", + // Using unspecific `type: ignore` comments in test_cases. // See https://github.com/python/typeshed/pull/8083 "enableTypeIgnoreComments": true, - "reportPropertyTypeMismatch": "error", - "reportUnnecessaryTypeIgnoreComment": "error", - "reportMissingModuleSource": "none", + // If a test case uses this anti-pattern, there's likely a reason and annoying to `type: ignore`. + // Let flake8-bugbear flag it (B006) + "reportCallInDefaultInitializer": "none", + // Too strict and not needed for type testing + "reportMissingSuperCall": "none", + // Stubs are allowed to use private variables. We may want to test those. "reportPrivateUsage": "none", + // Stubs don't need the actual modules to be installed + "reportMissingModuleSource": "none", + // Incompatible property type mismatches may be out of typeshed's control + // when they are inherited from the implementation. + "reportPropertyTypeMismatch": "none", // isinstance checks are still needed when validating inputs outside of typeshed's control "reportUnnecessaryIsInstance": "none", // The name of the self/cls parameter is out of typeshed's control. diff --git a/test_cases/stdlib/builtins/check_dict.py b/test_cases/stdlib/builtins/check_dict.py index 2161bb264..731662e63 100644 --- a/test_cases/stdlib/builtins/check_dict.py +++ b/test_cases/stdlib/builtins/check_dict.py @@ -20,6 +20,9 @@ _VT = TypeVar("_VT") class KeysAndGetItem(Generic[_KT, _VT]): data: dict[_KT, _VT] + def __init__(self, data: dict[_KT, _VT]) -> None: + self.data = data + def keys(self) -> Iterable[_KT]: return self.data.keys() @@ -27,11 +30,11 @@ class KeysAndGetItem(Generic[_KT, _VT]): return self.data[__k] -kt1: KeysAndGetItem[int, str] = KeysAndGetItem() +kt1: KeysAndGetItem[int, str] = KeysAndGetItem({0: ""}) assert_type(dict(kt1), Dict[int, str]) dict(kt1, arg="a") # type: ignore -kt2: KeysAndGetItem[str, int] = KeysAndGetItem() +kt2: KeysAndGetItem[str, int] = KeysAndGetItem({"": 0}) assert_type(dict(kt2, arg=1), Dict[str, int])