#
# 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
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(" ")]