]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
do the mypy dance
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 12 Sep 2025 23:01:31 +0000 (19:01 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 13 Sep 2025 00:24:24 +0000 (20:24 -0400)
version 1.18.1.  lots of i have no idea situations.
just add ignores, seems pretty pointless

Change-Id: Ieb1466df3f45fa6b8d11ccd36c7164645740ba35

lib/sqlalchemy/dialects/postgresql/array.py
lib/sqlalchemy/ext/asyncio/engine.py
lib/sqlalchemy/orm/events.py
lib/sqlalchemy/orm/writeonly.py
lib/sqlalchemy/sql/sqltypes.py
test/typing/plain_files/dialects/postgresql/pg_stuff.py

index 45b53f0d0494962c7eac7c748e38f3ee406485fd..a3ac4d8fd445e6482ed54e92594fdef048a9c7aa 100644 (file)
@@ -44,6 +44,7 @@ if TYPE_CHECKING:
 
 
 _T = TypeVar("_T", bound=typing_Any)
+_CT = TypeVar("_CT", bound=typing_Any)
 
 
 def Any(
@@ -355,7 +356,7 @@ class ARRAY(sqltypes.ARRAY[_T]):
         self.dimensions = dimensions
         self.zero_indexes = zero_indexes
 
-    class Comparator(sqltypes.ARRAY.Comparator[_T]):
+    class Comparator(sqltypes.ARRAY.Comparator[_CT]):
         """Define comparison operations for :class:`_types.ARRAY`.
 
         Note that these operations are in addition to those provided
index 5f5ec6cf350531b6dc6ff137cca8e34e36a9d401..dfc727a30208b89af3873da5187a5545b7ecf268 100644 (file)
@@ -189,7 +189,8 @@ class AsyncConnectable:
         "default_isolation_level",
     ],
 )
-class AsyncConnection(
+# "Class has incompatible disjoint bases" - no idea
+class AsyncConnection(  # type:ignore[misc]
     ProxyComparable[Connection],
     StartableContext["AsyncConnection"],
     AsyncConnectable,
@@ -998,7 +999,8 @@ class AsyncConnection(
     ],
     attributes=["url", "pool", "dialect", "engine", "name", "driver", "echo"],
 )
-class AsyncEngine(ProxyComparable[Engine], AsyncConnectable):
+# "Class has incompatible disjoint bases" - no idea
+class AsyncEngine(ProxyComparable[Engine], AsyncConnectable):  # type: ignore[misc]  # noqa:E501
     """An asyncio proxy for a :class:`_engine.Engine`.
 
     :class:`_asyncio.AsyncEngine` is acquired using the
index b915cdfec887dbb9c54028fa17f5a2e6dce20cc1..9ef1bc154e914d9ce5881a3dba9f63516d42aef6 100644 (file)
@@ -713,7 +713,8 @@ class _InstanceEventsHold(_EventsHold[_ET]):
     def resolve(self, class_: Type[_O]) -> Optional[ClassManager[_O]]:
         return instrumentation.opt_manager_of_class(class_)
 
-    class HoldInstanceEvents(_EventsHold.HoldEvents[_ET], InstanceEvents):  # type: ignore [misc] # noqa: E501
+    # this fails on pyright if you use Any.  Fails on mypy if you use _ET
+    class HoldInstanceEvents(_EventsHold.HoldEvents[_ET], InstanceEvents):  # type: ignore[valid-type,misc] # noqa: E501
         pass
 
     dispatch = event.dispatcher(HoldInstanceEvents)
@@ -1502,7 +1503,8 @@ class _MapperEventsHold(_EventsHold[_ET]):
     ) -> Optional[Mapper[_T]]:
         return _mapper_or_none(class_)
 
-    class HoldMapperEvents(_EventsHold.HoldEvents[_ET], MapperEvents):  # type: ignore [misc] # noqa: E501
+    # this fails on pyright if you use Any.  Fails on mypy if you use _ET
+    class HoldMapperEvents(_EventsHold.HoldEvents[_ET], MapperEvents):  # type: ignore[valid-type,misc] # noqa: E501
         pass
 
     dispatch = event.dispatcher(HoldMapperEvents)
index 1343a74bfe15a3fc5e157ad75e16848053b0c816..b5aaf16e8c80e46cfb39ce99da1bd18fd26bb58d 100644 (file)
@@ -423,7 +423,7 @@ class _WriteOnlyAttributeImpl(
         initiator: Optional[AttributeEventToken],
         passive: PassiveFlag = PassiveFlag.PASSIVE_NO_FETCH,
     ) -> None:
-        if initiator is not self:
+        if initiator is not self:  # type: ignore[comparison-overlap]
             self.fire_append_event(state, dict_, value, initiator)
 
     def remove(
@@ -434,7 +434,7 @@ class _WriteOnlyAttributeImpl(
         initiator: Optional[AttributeEventToken],
         passive: PassiveFlag = PassiveFlag.PASSIVE_NO_FETCH,
     ) -> None:
-        if initiator is not self:
+        if initiator is not self:  # type: ignore[comparison-overlap]
             self.fire_remove_event(state, dict_, value, initiator)
 
     def pop(
index 916e6444e5a74abca6547a58d85404fff24c7b24..0261d7a26b8b2abc1f5f813f62330280b6a2368e 100644 (file)
@@ -3050,8 +3050,8 @@ class ARRAY(
         self.zero_indexes = zero_indexes
 
     class Comparator(
-        Indexable.Comparator[Sequence[_T]],
-        Concatenable.Comparator[Sequence[_T]],
+        Indexable.Comparator[Sequence[_CT]],
+        Concatenable.Comparator[Sequence[_CT]],
     ):
         """Define comparison operations for :class:`_types.ARRAY`.
 
@@ -3062,7 +3062,7 @@ class ARRAY(
 
         __slots__ = ()
 
-        type: ARRAY[_T]
+        type: ARRAY[_CT]
 
         @overload
         def _setup_getitem(
index 4a50a9e42cc7922f48d77d4ba4c4a2a6da9f13f5..20785bc2cb34560a51d6bac8cfcf6750f785535e 100644 (file)
@@ -116,7 +116,7 @@ array_of_ints = array([0], type_=Integer)
 # EXPECTED_TYPE: array[int]
 reveal_type(array_of_ints)
 
-# EXPECTED_MYPY: Cannot infer type argument 1 of "array"
+# EXPECTED_MYPY_RE: Cannot infer .* of "array"
 array([0], type_=Text)
 
 # EXPECTED_TYPE: ARRAY[str]