From e844b2dace3699d0e472ba91ce816d0446d947e9 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 5 Mar 2021 10:56:09 -0700 Subject: [PATCH 1/3] Update pyright CI test to use the latest version of pyright (1.1.118). Enable all but one of pyright's strictest checks. Add a "# type: ignore" to `__new__` method in `weakref.KeyRef` because it uses a non-standard name for the `cls` parameter, which is flagged as an error by pyright. --- pyrightconfig.json | 12 ++++++++---- stdlib/weakref.pyi | 2 +- tests/pyright_test.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index bbb3168a8193..88af7fe45ba8 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -76,8 +76,12 @@ "reportUnboundVariable": "error", "reportInvalidStubStatement": "error", "reportUnsupportedDunderAll": "error", - "reportInvalidTypeVarUse": "none", - "reportOverlappingOverload": "none", - "reportPropertyTypeMismatch": "none", - "reportSelfClsParameterName": "none" + "reportInvalidTypeVarUse": "error", + "reportPropertyTypeMismatch": "error", + "reportSelfClsParameterName": "error", + // Overloapping overloads cannot be enabled at this time because + // of the "factions.Fraction.__pow__" method and "tasks.gather" function. + // Mypy's overlapping overload logic misses these issues (see mypy + // issue #10143 and #10157). + "reportOverlappingOverload": "none" } \ No newline at end of file diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 7685e0ba4fcd..9f82f4fb588e 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -76,7 +76,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): class KeyedRef(ref[_T], Generic[_KT, _T]): key: _KT - def __new__(type, ob: _T, callback: Callable[[_T], Any], key: _KT) -> KeyedRef[_KT, _T]: ... + def __new__(type, ob: _T, callback: Callable[[_T], Any], key: _KT) -> KeyedRef[_KT, _T]: ... # type: ignore def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ... class WeakKeyDictionary(MutableMapping[_KT, _VT]): diff --git a/tests/pyright_test.py b/tests/pyright_test.py index 2d4f0a8e6ff3..6f9899518c99 100755 --- a/tests/pyright_test.py +++ b/tests/pyright_test.py @@ -5,7 +5,7 @@ import sys from pathlib import Path -_PYRIGHT_VERSION = "1.1.115" +_PYRIGHT_VERSION = "1.1.118" _WELL_KNOWN_FILE = Path("tests", "pyright_test.py") From 74b8adbbfd3c05ca89a68c5162337b8a43fc8d7b Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 5 Mar 2021 11:06:36 -0700 Subject: [PATCH 2/3] Added missing # type: ignore --- stdlib/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index ca0779db78c3..2b11420ad061 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -89,7 +89,7 @@ class object: @property def __class__(self: _T) -> Type[_T]: ... @__class__.setter - def __class__(self, __type: Type[object]) -> None: ... # noqa: F811 + def __class__(self, __type: Type[object]) -> None: ... # type: ignore # noqa: F811 def __init__(self) -> None: ... def __new__(cls) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ... From 26d81ac5d114a4eb4d7018ddfc7fc2f1a9dbcba1 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 5 Mar 2021 11:49:04 -0700 Subject: [PATCH 3/3] Added comments explaining why "# type: ignore" is needed. --- stdlib/builtins.pyi | 1 + stdlib/weakref.pyi | 1 + 2 files changed, 2 insertions(+) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 2b11420ad061..d38d3aa1a8b9 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -88,6 +88,7 @@ class object: __annotations__: Dict[str, Any] @property def __class__(self: _T) -> Type[_T]: ... + # Ignore errors about type mismatch between property getter and setter @__class__.setter def __class__(self, __type: Type[object]) -> None: ... # type: ignore # noqa: F811 def __init__(self) -> None: ... diff --git a/stdlib/weakref.pyi b/stdlib/weakref.pyi index 9f82f4fb588e..98f57ea60dff 100644 --- a/stdlib/weakref.pyi +++ b/stdlib/weakref.pyi @@ -76,6 +76,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]): class KeyedRef(ref[_T], Generic[_KT, _T]): key: _KT + # This __new__ method uses a non-standard name for the "cls" parameter def __new__(type, ob: _T, callback: Callable[[_T], Any], key: _KT) -> KeyedRef[_KT, _T]: ... # type: ignore def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ...