From 5af7dfe00526f0c99789363a9389e1b61fd83da5 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 30 Jan 2024 12:40:40 +0100 Subject: [PATCH 1/3] Remove `Any` annotations --- stdlib/numbers.pyi | 81 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/stdlib/numbers.pyi b/stdlib/numbers.pyi index 55f21041ae44..c2a0301d5636 100644 --- a/stdlib/numbers.pyi +++ b/stdlib/numbers.pyi @@ -1,8 +1,9 @@ # Note: these stubs are incomplete. The more complex type # signatures are currently omitted. +from _typeshed import Incomplete from abc import ABCMeta, abstractmethod -from typing import Any, SupportsFloat, overload +from typing import SupportsFloat, overload __all__ = ["Number", "Complex", "Real", "Rational", "Integral"] @@ -16,36 +17,36 @@ class Complex(Number): def __bool__(self) -> bool: ... @property @abstractmethod - def real(self) -> Any: ... + def real(self): ... @property @abstractmethod - def imag(self) -> Any: ... + def imag(self): ... @abstractmethod - def __add__(self, other: Any) -> Any: ... + def __add__(self, other): ... @abstractmethod - def __radd__(self, other: Any) -> Any: ... + def __radd__(self, other): ... @abstractmethod - def __neg__(self) -> Any: ... + def __neg__(self): ... @abstractmethod - def __pos__(self) -> Any: ... - def __sub__(self, other: Any) -> Any: ... - def __rsub__(self, other: Any) -> Any: ... + def __pos__(self): ... + def __sub__(self, other): ... + def __rsub__(self, other): ... @abstractmethod - def __mul__(self, other: Any) -> Any: ... + def __mul__(self, other): ... @abstractmethod - def __rmul__(self, other: Any) -> Any: ... + def __rmul__(self, other): ... @abstractmethod - def __truediv__(self, other: Any) -> Any: ... + def __truediv__(self, other): ... @abstractmethod - def __rtruediv__(self, other: Any) -> Any: ... + def __rtruediv__(self, other): ... @abstractmethod - def __pow__(self, exponent: Any) -> Any: ... + def __pow__(self, exponent): ... @abstractmethod - def __rpow__(self, base: Any) -> Any: ... + def __rpow__(self, base): ... @abstractmethod def __abs__(self) -> Real: ... @abstractmethod - def conjugate(self) -> Any: ... + def conjugate(self): ... @abstractmethod def __eq__(self, other: object) -> bool: ... @@ -63,27 +64,27 @@ class Real(Complex, SupportsFloat): def __round__(self, ndigits: None = None) -> int: ... @abstractmethod @overload - def __round__(self, ndigits: int) -> Any: ... - def __divmod__(self, other: Any) -> Any: ... - def __rdivmod__(self, other: Any) -> Any: ... + def __round__(self, ndigits: int): ... + def __divmod__(self, other): ... + def __rdivmod__(self, other): ... @abstractmethod - def __floordiv__(self, other: Any) -> int: ... + def __floordiv__(self, other) -> int: ... @abstractmethod - def __rfloordiv__(self, other: Any) -> int: ... + def __rfloordiv__(self, other) -> int: ... @abstractmethod - def __mod__(self, other: Any) -> Any: ... + def __mod__(self, other): ... @abstractmethod - def __rmod__(self, other: Any) -> Any: ... + def __rmod__(self, other): ... @abstractmethod - def __lt__(self, other: Any) -> bool: ... + def __lt__(self, other) -> bool: ... @abstractmethod - def __le__(self, other: Any) -> bool: ... + def __le__(self, other) -> bool: ... def __complex__(self) -> complex: ... @property - def real(self) -> Any: ... + def real(self): ... @property - def imag(self) -> Any: ... - def conjugate(self) -> Any: ... + def imag(self): ... + def conjugate(self): ... class Rational(Real): @property @@ -99,29 +100,29 @@ class Integral(Rational): def __int__(self) -> int: ... def __index__(self) -> int: ... @abstractmethod - def __pow__(self, exponent: Any, modulus: Any | None = None) -> Any: ... + def __pow__(self, exponent, modulus: Incomplete | None = None): ... @abstractmethod - def __lshift__(self, other: Any) -> Any: ... + def __lshift__(self, other): ... @abstractmethod - def __rlshift__(self, other: Any) -> Any: ... + def __rlshift__(self, other): ... @abstractmethod - def __rshift__(self, other: Any) -> Any: ... + def __rshift__(self, other): ... @abstractmethod - def __rrshift__(self, other: Any) -> Any: ... + def __rrshift__(self, other): ... @abstractmethod - def __and__(self, other: Any) -> Any: ... + def __and__(self, other): ... @abstractmethod - def __rand__(self, other: Any) -> Any: ... + def __rand__(self, other): ... @abstractmethod - def __xor__(self, other: Any) -> Any: ... + def __xor__(self, other): ... @abstractmethod - def __rxor__(self, other: Any) -> Any: ... + def __rxor__(self, other): ... @abstractmethod - def __or__(self, other: Any) -> Any: ... + def __or__(self, other): ... @abstractmethod - def __ror__(self, other: Any) -> Any: ... + def __ror__(self, other): ... @abstractmethod - def __invert__(self) -> Any: ... + def __invert__(self): ... def __float__(self) -> float: ... @property def numerator(self) -> int: ... From a9aac5ab1b59535698f7d0331b48b91e7b675263 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 30 Jan 2024 12:53:14 +0100 Subject: [PATCH 2/3] Exclude numbers from stricter pyright config --- pyrightconfig.stricter.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index b5bdc49f9b63..b08f2e044ad7 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -1,10 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json", "typeshedPath": ".", - "include": [ - "stdlib", - "stubs", - ], + "include": ["stdlib", "stubs"], "exclude": [ // test cases use a custom pyrightconfig file "stubs/**/@tests/test_cases", @@ -12,6 +9,7 @@ "stdlib/distutils/dist.pyi", "stdlib/importlib/readers.pyi", "stdlib/lib2to3/fixes/*.pyi", + "stdlib/numbers.pyi", "stdlib/_tkinter.pyi", "stdlib/tkinter/__init__.pyi", "stdlib/tkinter/filedialog.pyi", @@ -79,7 +77,7 @@ "stubs/ttkthemes", "stubs/vobject", "stubs/WebOb", - "stubs/workalendar", + "stubs/workalendar" ], "typeCheckingMode": "strict", // TODO: Complete incomplete stubs @@ -111,5 +109,5 @@ // The name of the self/cls parameter is out of typeshed's control. "reportSelfClsParameterName": "none", // Not actionable in typeshed - "reportDeprecated": "none", + "reportDeprecated": "none" } From a30cadb3b46d85ad4b1615b4ca43fbe2b50994ec Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 30 Jan 2024 12:58:39 +0100 Subject: [PATCH 3/3] Reduce diff --- pyrightconfig.stricter.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index b08f2e044ad7..8579b6dd516b 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -1,7 +1,10 @@ { "$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json", "typeshedPath": ".", - "include": ["stdlib", "stubs"], + "include": [ + "stdlib", + "stubs", + ], "exclude": [ // test cases use a custom pyrightconfig file "stubs/**/@tests/test_cases", @@ -77,7 +80,7 @@ "stubs/ttkthemes", "stubs/vobject", "stubs/WebOb", - "stubs/workalendar" + "stubs/workalendar", ], "typeCheckingMode": "strict", // TODO: Complete incomplete stubs @@ -109,5 +112,5 @@ // The name of the self/cls parameter is out of typeshed's control. "reportSelfClsParameterName": "none", // Not actionable in typeshed - "reportDeprecated": "none" + "reportDeprecated": "none", }