from typing import Callable, Any
import sqlalchemy as sa
-import sqlalchemy.types as types
+from sqlalchemy import types
-from nominatim.typing import SaColumn
+from nominatim.typing import SaColumn, SaBind
+
+#pylint: disable=all
class Geometry(types.UserDefinedType[Any]):
""" Simplified type decorator for PostGIS geometry. This type
return f'GEOMETRY({self.subtype}, 4326)'
- def bind_processor(self, dialect: sa.Dialect) -> Callable[[Any], str]:
+ def bind_processor(self, dialect: 'sa.Dialect') -> Callable[[Any], str]:
def process(value: Any) -> str:
if isinstance(value, str):
return 'SRID=4326;' + value
return process
- def result_processor(self, dialect: sa.Dialect, coltype: object) -> Callable[[Any], str]:
+ def result_processor(self, dialect: 'sa.Dialect', coltype: object) -> Callable[[Any], str]:
def process(value: Any) -> str:
assert isinstance(value, str)
return value
return process
- def bind_expression(self, bindvalue: sa.BindParameter[Any]) -> SaColumn:
+ def bind_expression(self, bindvalue: SaBind) -> SaColumn:
return sa.func.ST_GeomFromText(bindvalue, type_=self)
class comparator_factory(types.UserDefinedType.Comparator):
- def intersects(self, other: SaColumn) -> SaColumn:
+ def intersects(self, other: SaColumn) -> 'sa.Operators':
return self.op('&&')(other)
def is_line_like(self) -> SaColumn: