]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add type annotations to postgresql.pg_catalog 12462/head
authorDenis Laxalde <denis@laxalde.org>
Tue, 18 Mar 2025 10:40:25 +0000 (11:40 +0100)
committerDenis Laxalde <denis@laxalde.org>
Tue, 25 Mar 2025 07:17:12 +0000 (08:17 +0100)
Related to #6810.

lib/sqlalchemy/dialects/postgresql/pg_catalog.py

index 78f390a2118a77e6805822fc8dddf9eb19ca111c..4841056cf9d1660a47c074906c6a71a7d5afecde 100644 (file)
@@ -4,7 +4,13 @@
 #
 # This module is part of SQLAlchemy and is released under
 # the MIT License: https://www.opensource.org/licenses/mit-license.php
-# mypy: ignore-errors
+
+from __future__ import annotations
+
+from typing import Any
+from typing import Optional
+from typing import Sequence
+from typing import TYPE_CHECKING
 
 from .array import ARRAY
 from .types import OID
@@ -23,31 +29,37 @@ from ...types import String
 from ...types import Text
 from ...types import TypeDecorator
 
+if TYPE_CHECKING:
+    from ...engine.interfaces import Dialect
+    from ...sql.type_api import _ResultProcessorType
+
 
 # types
-class NAME(TypeDecorator):
+class NAME(TypeDecorator[str]):
     impl = String(64, collation="C")
     cache_ok = True
 
 
-class PG_NODE_TREE(TypeDecorator):
+class PG_NODE_TREE(TypeDecorator[str]):
     impl = Text(collation="C")
     cache_ok = True
 
 
-class INT2VECTOR(TypeDecorator):
+class INT2VECTOR(TypeDecorator[Sequence[int]]):
     impl = ARRAY(SmallInteger)
     cache_ok = True
 
 
-class OIDVECTOR(TypeDecorator):
+class OIDVECTOR(TypeDecorator[Sequence[int]]):
     impl = ARRAY(OID)
     cache_ok = True
 
 
 class _SpaceVector:
-    def result_processor(self, dialect, coltype):
-        def process(value):
+    def result_processor(
+        self, dialect: Dialect, coltype: object
+    ) -> _ResultProcessorType[list[int]]:
+        def process(value: Any) -> Optional[list[int]]:
             if value is None:
                 return value
             return [int(p) for p in value.split(" ")]