From 1695d6a1ec7c6e03a6aba3fade5f48eec45cf602 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Tue, 14 Jun 2022 12:54:54 +0100 Subject: [PATCH 01/16] Beef up pyright config --- .github/workflows/tests.yml | 6 +++--- pyrightconfig.json | 17 ++++++++++------- pyrightconfig.stricter.json | 17 ++++++++++------- tests/pyright_test.py | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 63d619e3b6a0..c66dfde59e62 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -77,7 +77,7 @@ jobs: python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] fail-fast: false env: - PYRIGHT_VERSION: 1.1.248 # Must match pyright_test.py. + PYRIGHT_VERSION: 1.1.254 # Must match pyright_test.py. steps: - uses: actions/checkout@v2 - uses: jakebailey/pyright-action@v1 @@ -85,14 +85,14 @@ jobs: version: ${{ env.PYRIGHT_VERSION }} python-platform: ${{ matrix.python-platform }} python-version: ${{ matrix.python-version }} - no-comments: ${{ matrix.python-version != '3.9' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. + no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. project: ./pyrightconfig.stricter.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.9' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. + 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 diff --git a/pyrightconfig.json b/pyrightconfig.json index 6897cf7ab1a7..6f5cb1b36610 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -12,6 +12,7 @@ "strictListInference": true, "strictDictionaryInference": true, "strictParameterNoneValue": true, + "strictSetInference": true, "reportFunctionMemberAccess": "error", "reportMissingModuleSource": "none", "reportMissingTypeStubs": "error", @@ -40,16 +41,18 @@ "reportUnboundVariable": "error", "reportInvalidStubStatement": "error", "reportInvalidTypeVarUse": "error", - "reportPropertyTypeMismatch": "none", "reportSelfClsParameterName": "error", "reportUnsupportedDunderAll": "error", - // Incompatible overrides are out of typeshed's control as they are - // inherited from the implementation. + "reportInconsistentConstructor": "error", + "reportTypeCommentUsage": "error", + "reportUnnecessaryComparison": "error", + // Incompatible overrides and property type mismatches are out of typeshed's control + // as they are inherited from the implementation. + "reportPropertyTypeMismatch": "none", "reportIncompatibleMethodOverride": "none", "reportIncompatibleVariableOverride": "none", - // Overlapping overloads cannot be enabled at this time because - // of the "fractions.Fraction.__pow__" method and "tasks.gather" function. - // Mypy's overlapping overload logic misses these issues (see mypy - // issue #10143 and #10157). + // Overlapping overloads are often necessary in a stub, meaning pyright's check + // (which is stricter than pyright's; see mypy issue #10143 and #10157) + // would cause many false positives and catch few bugs. "reportOverlappingOverload": "none", } diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 3daaeb2336b7..50e117326b2e 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -79,6 +79,7 @@ "strictListInference": true, "strictDictionaryInference": true, "strictParameterNoneValue": true, + "strictSetInference": true, "reportFunctionMemberAccess": "error", "reportMissingModuleSource": "none", "reportMissingTypeStubs": "error", @@ -110,16 +111,18 @@ "reportUnboundVariable": "error", "reportInvalidStubStatement": "error", "reportInvalidTypeVarUse": "error", - "reportPropertyTypeMismatch": "none", "reportSelfClsParameterName": "error", "reportUnsupportedDunderAll": "error", - // Incompatible overrides are out of typeshed's control as they are - // inherited from the implementation. + "reportInconsistentConstructor": "error", + "reportTypeCommentUsage": "error", + "reportUnnecessaryComparison": "error", + // Incompatible overrides and property type mismatches are out of typeshed's control + // as they are inherited from the implementation. "reportIncompatibleMethodOverride": "none", "reportIncompatibleVariableOverride": "none", - // Overlapping overloads cannot be enabled at this time because - // of the "fractions.Fraction.__pow__" method and "tasks.gather" function. - // Mypy's overlapping overload logic misses these issues (see mypy - // issue #10143 and #10157). + "reportPropertyTypeMismatch": "none", + // Overlapping overloads are often necessary in a stub, meaning pyright's check + // (which is stricter than pyright's; see mypy issue #10143 and #10157) + // would cause many false positives and catch few bugs. "reportOverlappingOverload": "none", } diff --git a/tests/pyright_test.py b/tests/pyright_test.py index 418866e0166b..5fc64d5701ff 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.248" # Must match .github/workflows/tests.yml. +_PYRIGHT_VERSION = "1.1.254" # Must match .github/workflows/tests.yml. _WELL_KNOWN_FILE = Path("tests", "pyright_test.py") From 2b208cbdb61f6682fcdcdc5d74e9c0fc202ac865 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Tue, 14 Jun 2022 16:57:29 +0100 Subject: [PATCH 02/16] Add ignores for unfixable things --- stdlib/ctypes/__init__.pyi | 4 +++- stdlib/subprocess.pyi | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index ee26cbddefe4..00b2be01dc86 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -190,7 +190,9 @@ def wstring_at(address: _CVoidConstPLike, size: int = ...) -> str: ... class _SimpleCData(Generic[_T], _CData): value: _T - def __init__(self, value: _T = ...) -> None: ... + # The TypeVar can be unsolved here, + # but we can't use overloads without creating many, many mypy false-positive errors + def __init__(self, value: _T = ...) -> None: ... # type: ignore class c_byte(_SimpleCData[int]): ... diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 6ce1073002b8..34823d3734a5 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -95,7 +95,8 @@ class CompletedProcess(Generic[_T]): # and writing all the overloads would be horrific. stdout: _T stderr: _T - def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ... + # type: ignore on __init__ because the TypeVar can technically be unsolved, but see comment above + def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ... # type: ignore def check_returncode(self) -> None: ... if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any) -> GenericAlias: ... From 8414ae406c1ab8936dfabddfec4651456b07cf2f Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 14 Jun 2022 16:59:22 +0100 Subject: [PATCH 03/16] Update stdlib/subprocess.pyi --- stdlib/subprocess.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 34823d3734a5..ed01c8832e33 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -95,7 +95,7 @@ class CompletedProcess(Generic[_T]): # and writing all the overloads would be horrific. stdout: _T stderr: _T - # type: ignore on __init__ because the TypeVar can technically be unsolved, but see comment above + # type ignore on __init__ because the TypeVar can technically be unsolved, but see comment above def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ... # type: ignore def check_returncode(self) -> None: ... if sys.version_info >= (3, 9): From 4dd0069f17c79b8878dea923b99a6603dd7bf3c0 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 14 Jun 2022 17:05:32 +0100 Subject: [PATCH 04/16] Update pyrightconfig.stricter.json Co-authored-by: Jelle Zijlstra --- pyrightconfig.stricter.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 50e117326b2e..e08236b17e1f 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -122,7 +122,7 @@ "reportIncompatibleVariableOverride": "none", "reportPropertyTypeMismatch": "none", // Overlapping overloads are often necessary in a stub, meaning pyright's check - // (which is stricter than pyright's; see mypy issue #10143 and #10157) + // (which is stricter than mypy's; see mypy issue #10143 and #10157) // would cause many false positives and catch few bugs. "reportOverlappingOverload": "none", } From 1ed0f954dc8dcd6b7a08808f8cdaeb4ce9cf0f3b Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Tue, 14 Jun 2022 17:33:08 +0100 Subject: [PATCH 05/16] Change two `__init__` methods to `__new__` methods --- stdlib/_weakref.pyi | 3 ++- stdlib/abc.pyi | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/stdlib/_weakref.pyi b/stdlib/_weakref.pyi index 2d3faec1fa68..329cd0dd6458 100644 --- a/stdlib/_weakref.pyi +++ b/stdlib/_weakref.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import Self from collections.abc import Callable from typing import Any, Generic, TypeVar, overload from typing_extensions import final @@ -20,7 +21,7 @@ class ProxyType(Generic[_T]): # "weakproxy" class ReferenceType(Generic[_T]): __callback__: Callable[[ReferenceType[_T]], Any] - def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> None: ... + def __new__(cls: type[Self], o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> Self: ... def __call__(self) -> _T | None: ... def __hash__(self) -> int: ... if sys.version_info >= (3, 9): diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 58985067b125..b648b4398d08 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import SupportsWrite +from _typeshed import Self, SupportsWrite from collections.abc import Callable from typing import Any, Generic, TypeVar from typing_extensions import Literal @@ -11,7 +11,7 @@ _FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) # These definitions have special processing in mypy class ABCMeta(type): __abstractmethods__: frozenset[str] - def __init__(self, name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> None: ... + def __new__(mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> Self: ... def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ... From 968e91d1c59feb52ef0cf43986ebc8a730aa24d3 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Tue, 14 Jun 2022 17:41:05 +0100 Subject: [PATCH 06/16] Allowlists etc. --- stdlib/abc.pyi | 3 ++- tests/stubtest_allowlists/py3_common.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index b648b4398d08..380f15b508f7 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -11,7 +11,8 @@ _FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) # These definitions have special processing in mypy class ABCMeta(type): __abstractmethods__: frozenset[str] - def __new__(mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> Self: ... + # pyright doesn't like the first parameter being called mcls, hence the type: ignore + def __new__(mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> Self: ... # type: ignore def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ... diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 91d166821ff7..85e47ae161ba 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -26,8 +26,8 @@ _collections_abc.Set.__rxor__ _csv.Dialect.__init__ # C __init__ signature is inaccurate _socket.* _threading_local.local.__new__ +_weakref.ref.__init__ # Runtime defines __new__ but stubtest thinks __init__ is also defined. _weakref.ref.__call__ -abc.ABCMeta.__new__ # pytype wants the parameter named cls and not mcls _weakref.CallableProxyType.__getattr__ # Should have all attributes of proxy _weakref.ProxyType.__getattr__ # Should have all attributes of proxy _weakref.ReferenceType.__call__ # C function default annotation is wrong From 7db0f00666c3572ef91cefe08bccfb700d9ce367 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 14 Jun 2022 17:43:49 +0100 Subject: [PATCH 07/16] Update pyrightconfig.json --- pyrightconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 6f5cb1b36610..b54268dfc1ef 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -52,7 +52,7 @@ "reportIncompatibleMethodOverride": "none", "reportIncompatibleVariableOverride": "none", // Overlapping overloads are often necessary in a stub, meaning pyright's check - // (which is stricter than pyright's; see mypy issue #10143 and #10157) + // (which is stricter than mypy's; see mypy issue #10143 and #10157) // would cause many false positives and catch few bugs. "reportOverlappingOverload": "none", } From 3567494d3358e0a5da10ebe079c28fb7b03a0ba9 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Tue, 14 Jun 2022 17:48:06 +0100 Subject: [PATCH 08/16] More allowlist shenanigans --- tests/stubtest_allowlists/py3_common.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 85e47ae161ba..eafc23df67fa 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -26,11 +26,11 @@ _collections_abc.Set.__rxor__ _csv.Dialect.__init__ # C __init__ signature is inaccurate _socket.* _threading_local.local.__new__ -_weakref.ref.__init__ # Runtime defines __new__ but stubtest thinks __init__ is also defined. -_weakref.ref.__call__ +_weakref.ref.* # Alias for _weakref.ReferenceType, problems should be fixed there _weakref.CallableProxyType.__getattr__ # Should have all attributes of proxy _weakref.ProxyType.__getattr__ # Should have all attributes of proxy _weakref.ReferenceType.__call__ # C function default annotation is wrong +_weakref.ReferenceType.__init__ # Runtime defines __new__ but stubtest thinks __init__ is also defined. argparse.Namespace.__getattr__ # The whole point of this class is its attributes are dynamic asynchat.async_chat.encoding # Removal planned for 3.12, can add if someone needs this asynchat.async_chat.use_encoding # Removal planned for 3.12, can add if someone needs this @@ -221,11 +221,11 @@ urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ # Args are passed as is to warnings.catch_warnings.__init__ # Defining this ruins the __new__ overrides weakref.CallableProxyType.__getattr__ # Should have all attributes of proxy weakref.ProxyType.__getattr__ # Should have all attributes of proxy -weakref.ReferenceType.__call__ # C function default annotation is wrong +weakref.ReferenceType.* # Alias for _weakref.ReferenceType, problems should be fixed there weakref.WeakKeyDictionary.get weakref.WeakKeyDictionary.update weakref.WeakValueDictionary.get -weakref.ref.__call__ +weakref.ref.* # Alias for _weakref.ReferenceType, problems should be fixed there webbrowser.UnixBrowser.remote_action # always overridden in inheriting class webbrowser.UnixBrowser.remote_action_newtab # always overridden in inheriting class webbrowser.UnixBrowser.remote_action_newwin # always overridden in inheriting class From 7c74d5a1d9cf63b693008a3763adabcf6a4de32f Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Tue, 14 Jun 2022 17:55:24 +0100 Subject: [PATCH 09/16] stubtest --- stdlib/abc.pyi | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 380f15b508f7..9b74a0ef27bc 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -11,8 +11,14 @@ _FuncT = TypeVar("_FuncT", bound=Callable[..., Any]) # These definitions have special processing in mypy class ABCMeta(type): __abstractmethods__: frozenset[str] - # pyright doesn't like the first parameter being called mcls, hence the type: ignore - def __new__(mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any]) -> Self: ... # type: ignore + if sys.version_info >= (3, 11): + def __new__( + __mcls: type[Self], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwargs: Any + ) -> Self: ... + else: + # pyright doesn't like the first parameter being called mcls, hence the type: ignore + def __new__(mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any) -> Self: ... # type: ignore + def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ... From b81c85ce6abb36ffb2502dd1a5d24f6cf5f887b7 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Thu, 16 Jun 2022 15:30:35 +0100 Subject: [PATCH 10/16] Fix a constructor in `SQLAlchemy` --- stubs/SQLAlchemy/sqlalchemy/sql/annotation.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/SQLAlchemy/sqlalchemy/sql/annotation.pyi b/stubs/SQLAlchemy/sqlalchemy/sql/annotation.pyi index 202412831da0..ead1cc1f64b9 100644 --- a/stubs/SQLAlchemy/sqlalchemy/sql/annotation.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/sql/annotation.pyi @@ -7,7 +7,6 @@ class SupportsCloneAnnotations(SupportsAnnotations): ... class SupportsWrappingAnnotations(SupportsAnnotations): ... class Annotated: - def __new__(cls, *args): ... __dict__: Any def __init__(self, element, values) -> None: ... def __reduce__(self): ... From b9c51976578551bd1487c951d7a39d07ab2bd5e8 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Thu, 16 Jun 2022 17:02:21 +0100 Subject: [PATCH 11/16] White lies in SQLAlchemy --- stubs/SQLAlchemy/@tests/stubtest_allowlist.txt | 4 ++++ stubs/SQLAlchemy/sqlalchemy/orm/unitofwork.pyi | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt index 338b82c23f44..f4389944fe5c 100644 --- a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt +++ b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt @@ -125,6 +125,10 @@ sqlalchemy.engine.url.URL.normalized_query # runtime has extra internal arguments that are inconsistent across micro versions sqlalchemy.testing.engines.testing_engine +# __new__ signature conflicts with __init__ signature (which is more precise), +# so __new__ is deliberately omitted in the stub +sqlalchemy.sql.annotation.Annotated.__new__ + # unclear problems sqlalchemy.sql.elements.quoted_name.lower sqlalchemy.sql.elements.quoted_name.upper diff --git a/stubs/SQLAlchemy/sqlalchemy/orm/unitofwork.pyi b/stubs/SQLAlchemy/sqlalchemy/orm/unitofwork.pyi index 5ca959e0e625..dde05b0a2ec3 100644 --- a/stubs/SQLAlchemy/sqlalchemy/orm/unitofwork.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/orm/unitofwork.pyi @@ -49,7 +49,10 @@ class Preprocess(IterateMappersMixin): class PostSortRec: disabled: Any - def __new__(cls, uow, *args): ... + # At runtime __new__ is defined, not __init__, + # But if we define __new__ here then all subclasses are identified by pyright + # as having __init__ methods that are inconsistent with their __new__ methods + def __init__(self, uow, *args) -> None: ... def execute_aggregate(self, uow, recs) -> None: ... class ProcessAll(IterateMappersMixin, PostSortRec): From 2b5e5ed1f5ac34749b54fd7fd3190201cd706d57 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Thu, 16 Jun 2022 17:06:40 +0100 Subject: [PATCH 12/16] Allow --- stubs/SQLAlchemy/@tests/stubtest_allowlist.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt index f4389944fe5c..28b659a43eb8 100644 --- a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt +++ b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt @@ -129,6 +129,11 @@ sqlalchemy.testing.engines.testing_engine # so __new__ is deliberately omitted in the stub sqlalchemy.sql.annotation.Annotated.__new__ +# At runtime __new__ is defined, but we define __init__ in the stub +# because otherwise all subclasses would be identified by pyright +# as having conflicting __new__/__init__ methods +sqlalchemy.sql.orm.unitofwork.PostSortRec.__new__ + # unclear problems sqlalchemy.sql.elements.quoted_name.lower sqlalchemy.sql.elements.quoted_name.upper From 86edde94f38ec52a72886acaf9f2e116f05fa77d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 16 Jun 2022 17:09:30 +0100 Subject: [PATCH 13/16] Update stubs/SQLAlchemy/@tests/stubtest_allowlist.txt --- stubs/SQLAlchemy/@tests/stubtest_allowlist.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt index 28b659a43eb8..c7e8da23744e 100644 --- a/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt +++ b/stubs/SQLAlchemy/@tests/stubtest_allowlist.txt @@ -132,7 +132,7 @@ sqlalchemy.sql.annotation.Annotated.__new__ # At runtime __new__ is defined, but we define __init__ in the stub # because otherwise all subclasses would be identified by pyright # as having conflicting __new__/__init__ methods -sqlalchemy.sql.orm.unitofwork.PostSortRec.__new__ +sqlalchemy.orm.unitofwork.PostSortRec.__new__ # unclear problems sqlalchemy.sql.elements.quoted_name.lower From 6b11e9c51254c4f3cdf248a885eb34310c24f864 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 16 Jun 2022 18:34:37 +0100 Subject: [PATCH 14/16] Update stdlib/abc.pyi Co-authored-by: Sebastian Rittau --- stdlib/abc.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 9b74a0ef27bc..6a721a42626f 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -17,7 +17,7 @@ class ABCMeta(type): ) -> Self: ... else: # pyright doesn't like the first parameter being called mcls, hence the type: ignore - def __new__(mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any) -> Self: ... # type: ignore + def __new__(mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any) -> Self: ... # pyright: ignore def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... From 463bee3d2b5ddb891e3c93d01d65e63810781727 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 Jun 2022 17:35:58 +0000 Subject: [PATCH 15/16] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/abc.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 6a721a42626f..0f91ee537bbe 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -17,7 +17,9 @@ class ABCMeta(type): ) -> Self: ... else: # pyright doesn't like the first parameter being called mcls, hence the type: ignore - def __new__(mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any) -> Self: ... # pyright: ignore + def __new__( + mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any + ) -> Self: ... # pyright: ignore def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ... From e014952c5027bd941dac54ebca682f4911c07614 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 16 Jun 2022 18:38:59 +0100 Subject: [PATCH 16/16] Undo the damage done by pre-commit --- stdlib/abc.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/abc.pyi b/stdlib/abc.pyi index 0f91ee537bbe..f7f82333a362 100644 --- a/stdlib/abc.pyi +++ b/stdlib/abc.pyi @@ -16,10 +16,10 @@ class ABCMeta(type): __mcls: type[Self], __name: str, __bases: tuple[type, ...], __namespace: dict[str, Any], **kwargs: Any ) -> Self: ... else: - # pyright doesn't like the first parameter being called mcls, hence the type: ignore + # pyright doesn't like the first parameter being called mcls, hence the `pyright: ignore` def __new__( - mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any - ) -> Self: ... # pyright: ignore + mcls: type[Self], name: str, bases: tuple[type, ...], namespace: dict[str, Any], **kwargs: Any # pyright: ignore + ) -> Self: ... def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ... def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ...