]> 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:49 +0000 (20:24 -0400)
version 1.18.1.  lots of i have no idea situations.
just add ignores, seems pretty pointless

Change-Id: Ieb1466df3f45fa6b8d11ccd36c7164645740ba35
(cherry picked from commit e7ff28e21e063b13cc6bfe4ca69e108bffc03c4b)

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 7339d5c7d8e491d5437dee55c2c90aa7220c68b8..41c0a9147e9421ccb3a52222db295e7531955f32 100644 (file)
@@ -44,6 +44,7 @@ if TYPE_CHECKING:
 
 
 _T = TypeVar("_T", bound=typing_Any)
+_CT = TypeVar("_CT", bound=typing_Any)
 
 
 def Any(
@@ -357,7 +358,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 d4ecbdac9861e95e55895e969a2ef1fd22f370bd..89e503c256aae2a087ccb531d92ca270b73e3376 100644 (file)
@@ -186,7 +186,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,
@@ -994,7 +995,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 c116b05756481ea00dcda391bd5b2b6010111fd0..2c812f9bab6297d961dfc803297a44ccc0c3933b 100644 (file)
@@ -735,7 +735,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)
@@ -1524,7 +1525,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 fe9c8e96e895a3e6163eabe075d37a8186c3681d..fac50b5808c9343ab34316648ba03a895a33b1ee 100644 (file)
@@ -411,7 +411,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(
@@ -422,7 +422,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 7cb2265ea43606b578bb045ad5e657a05de3cd13..d9cf3c98f908beb07d2bb8ae0b306952e7fe0f96 100644 (file)
@@ -2995,8 +2995,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`.
 
@@ -3007,7 +3007,7 @@ class ARRAY(
 
         __slots__ = ()
 
-        type: ARRAY[_T]
+        type: ARRAY[_CT]
 
         @overload
         def _setup_getitem(
index 0f1e588bd950c212ef426877a61084f5c2a90553..9669cc7d77b4765ab5bcb021f05eb2e25563c68d 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]