sa.type_coerce(tokens, IntArray))
-@compiles(LookupAll) # type: ignore[no-untyped-call, misc]
+@compiles(LookupAll)
def _default_lookup_all(element: LookupAll,
compiler: 'sa.Compiled', **kw: Any) -> str:
_, col, _, tokens = list(element.clauses)
compiler.process(tokens, **kw))
-@compiles(LookupAll, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(LookupAll, 'sqlite')
def _sqlite_lookup_all(element: LookupAll,
compiler: 'sa.Compiled', **kw: Any) -> str:
place, col, colname, tokens = list(element.clauses)
super().__init__(table.c.place_id, getattr(table.c, column), column,
sa.type_coerce(tokens, IntArray))
-@compiles(LookupAny) # type: ignore[no-untyped-call, misc]
+@compiles(LookupAny)
def _default_lookup_any(element: LookupAny,
compiler: 'sa.Compiled', **kw: Any) -> str:
_, col, _, tokens = list(element.clauses)
return "(%s && %s)" % (compiler.process(col, **kw),
compiler.process(tokens, **kw))
-@compiles(LookupAny, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(LookupAny, 'sqlite')
def _sqlite_lookup_any(element: LookupAny,
compiler: 'sa.Compiled', **kw: Any) -> str:
place, _, colname, tokens = list(element.clauses)
sa.type_coerce(tokens, IntArray))
-@compiles(Restrict) # type: ignore[no-untyped-call, misc]
+@compiles(Restrict)
def _default_restrict(element: Restrict,
compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "(coalesce(null, %s) @> %s)" % (compiler.process(arg1, **kw),
compiler.process(arg2, **kw))
-@compiles(Restrict, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(Restrict, 'sqlite')
def _sqlite_restrict(element: Restrict,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "array_contains(%s)" % compiler.process(element.clauses, **kw)
inherit_cache = True
-@compiles(PlacexGeometryReverseLookuppolygon) # type: ignore[no-untyped-call, misc]
+@compiles(PlacexGeometryReverseLookuppolygon)
def _default_intersects(element: PlacexGeometryReverseLookuppolygon,
compiler: 'sa.Compiled', **kw: Any) -> str:
return ("(ST_GeometryType(placex.geometry) in ('ST_Polygon', 'ST_MultiPolygon')"
" AND placex.linked_place_id is null)")
-@compiles(PlacexGeometryReverseLookuppolygon, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(PlacexGeometryReverseLookuppolygon, 'sqlite')
def _sqlite_intersects(element: PlacexGeometryReverseLookuppolygon,
compiler: 'sa.Compiled', **kw: Any) -> str:
return ("(ST_GeometryType(placex.geometry) in ('POLYGON', 'MULTIPOLYGON')"
self.tablename = table.name
-@compiles(IntersectsReverseDistance) # type: ignore[no-untyped-call, misc]
+@compiles(IntersectsReverseDistance)
def default_reverse_place_diameter(element: IntersectsReverseDistance,
compiler: 'sa.Compiled', **kw: Any) -> str:
table = element.tablename
tuple(map(lambda c: compiler.process(c, **kw), element.clauses))
-@compiles(IntersectsReverseDistance, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(IntersectsReverseDistance, 'sqlite')
def sqlite_reverse_place_diameter(element: IntersectsReverseDistance,
compiler: 'sa.Compiled', **kw: Any) -> str:
geom1, rank, geom2 = list(element.clauses)
inherit_cache = True
-@compiles(IsBelowReverseDistance) # type: ignore[no-untyped-call, misc]
+@compiles(IsBelowReverseDistance)
def default_is_below_reverse_distance(element: IsBelowReverseDistance,
compiler: 'sa.Compiled', **kw: Any) -> str:
dist, rank = list(element.clauses)
compiler.process(rank, **kw))
-@compiles(IsBelowReverseDistance, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(IsBelowReverseDistance, 'sqlite')
def sqlite_is_below_reverse_distance(element: IsBelowReverseDistance,
compiler: 'sa.Compiled', **kw: Any) -> str:
dist, rank = list(element.clauses)
table.c.housenumber, table.c.name)
-@compiles(IsAddressPoint) # type: ignore[no-untyped-call, misc]
+@compiles(IsAddressPoint)
def default_is_address_point(element: IsAddressPoint,
compiler: 'sa.Compiled', **kw: Any) -> str:
rank, hnr, name = list(element.clauses)
compiler.process(name, **kw))
-@compiles(IsAddressPoint, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(IsAddressPoint, 'sqlite')
def sqlite_is_address_point(element: IsAddressPoint,
compiler: 'sa.Compiled', **kw: Any) -> str:
rank, hnr, name = list(element.clauses)
name = 'CrosscheckNames'
inherit_cache = True
-@compiles(CrosscheckNames) # type: ignore[no-untyped-call, misc]
+@compiles(CrosscheckNames)
def compile_crosscheck_names(element: CrosscheckNames,
compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
compiler.process(arg1, **kw), compiler.process(arg2, **kw))
-@compiles(CrosscheckNames, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(CrosscheckNames, 'sqlite')
def compile_sqlite_crosscheck_names(element: CrosscheckNames,
compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
inherit_cache = True
-@compiles(JsonArrayEach) # type: ignore[no-untyped-call, misc]
+@compiles(JsonArrayEach)
def default_json_array_each(element: JsonArrayEach, compiler: 'sa.Compiled', **kw: Any) -> str:
return "json_array_elements(%s)" % compiler.process(element.clauses, **kw)
-@compiles(JsonArrayEach, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(JsonArrayEach, 'sqlite')
def sqlite_json_array_each(element: JsonArrayEach, compiler: 'sa.Compiled', **kw: Any) -> str:
return "json_each(%s)" % compiler.process(element.clauses, **kw)
inherit_cache = True
-@compiles(Greatest, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(Greatest, 'sqlite')
def sqlite_greatest(element: Greatest, compiler: 'sa.Compiled', **kw: Any) -> str:
return "max(%s)" % compiler.process(element.clauses, **kw)
inherit_cache = True
-@compiles(RegexpWord, 'postgresql') # type: ignore[no-untyped-call, misc]
+@compiles(RegexpWord, 'postgresql')
def postgres_regexp_nocase(element: RegexpWord, compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "%s ~* ('\\m(' || %s || ')\\M')::text" % (compiler.process(arg2, **kw), compiler.process(arg1, **kw))
-@compiles(RegexpWord, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(RegexpWord, 'sqlite')
def sqlite_regexp_nocase(element: RegexpWord, compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "regexp('\\b(' || %s || ')\\b', %s)" % (compiler.process(arg1, **kw), compiler.process(arg2, **kw))
inherit_cache = True
-@compiles(Geometry_DistanceSpheroid) # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_DistanceSpheroid)
def _default_distance_spheroid(element: Geometry_DistanceSpheroid,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "ST_DistanceSpheroid(%s,"\
% compiler.process(element.clauses, **kw)
-@compiles(Geometry_DistanceSpheroid, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_DistanceSpheroid, 'sqlite')
def _spatialite_distance_spheroid(element: Geometry_DistanceSpheroid,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "COALESCE(Distance(%s, true), 0.0)" % compiler.process(element.clauses, **kw)
inherit_cache = True
-@compiles(Geometry_IsLineLike) # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_IsLineLike)
def _default_is_line_like(element: Geometry_IsLineLike,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "ST_GeometryType(%s) IN ('ST_LineString', 'ST_MultiLineString')" % \
compiler.process(element.clauses, **kw)
-@compiles(Geometry_IsLineLike, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_IsLineLike, 'sqlite')
def _sqlite_is_line_like(element: Geometry_IsLineLike,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "ST_GeometryType(%s) IN ('LINESTRING', 'MULTILINESTRING')" % \
inherit_cache = True
-@compiles(Geometry_IsAreaLike) # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_IsAreaLike)
def _default_is_area_like(element: Geometry_IsAreaLike,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "ST_GeometryType(%s) IN ('ST_Polygon', 'ST_MultiPolygon')" % \
compiler.process(element.clauses, **kw)
-@compiles(Geometry_IsAreaLike, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_IsAreaLike, 'sqlite')
def _sqlite_is_area_like(element: Geometry_IsAreaLike,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "ST_GeometryType(%s) IN ('POLYGON', 'MULTIPOLYGON')" % \
inherit_cache = True
-@compiles(Geometry_IntersectsBbox) # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_IntersectsBbox)
def _default_intersects(element: Geometry_IntersectsBbox,
compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "%s && %s" % (compiler.process(arg1, **kw), compiler.process(arg2, **kw))
-@compiles(Geometry_IntersectsBbox, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_IntersectsBbox, 'sqlite')
def _sqlite_intersects(element: Geometry_IntersectsBbox,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "MbrIntersects(%s) = 1" % compiler.process(element.clauses, **kw)
inherit_cache = True
-@compiles(Geometry_ColumnIntersectsBbox) # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_ColumnIntersectsBbox)
def default_intersects_column(element: Geometry_ColumnIntersectsBbox,
compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "%s && %s" % (compiler.process(arg1, **kw), compiler.process(arg2, **kw))
-@compiles(Geometry_ColumnIntersectsBbox, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_ColumnIntersectsBbox, 'sqlite')
def spatialite_intersects_column(element: Geometry_ColumnIntersectsBbox,
compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
inherit_cache = True
-@compiles(Geometry_ColumnDWithin) # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_ColumnDWithin)
def default_dwithin_column(element: Geometry_ColumnDWithin,
compiler: 'sa.Compiled', **kw: Any) -> str:
return "ST_DWithin(%s)" % compiler.process(element.clauses, **kw)
-@compiles(Geometry_ColumnDWithin, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(Geometry_ColumnDWithin, 'sqlite')
def spatialite_dwithin_column(element: Geometry_ColumnDWithin,
compiler: 'sa.Compiled', **kw: Any) -> str:
geom1, geom2, dist = list(element.clauses)
return Geometry_DistanceSpheroid(self, other)
-@compiles(Geometry, 'sqlite') # type: ignore[no-untyped-call]
+@compiles(Geometry, 'sqlite')
def get_col_spec(self, *args, **kwargs): # type: ignore[no-untyped-def]
return 'GEOMETRY'
def _sqlite_impl(element: Any, compiler: Any, **kw: Any) -> Any:
return func_templ % compiler.process(element.clauses, **kw)
- compiles(_FuncDef, 'sqlite')(_sqlite_impl) # type: ignore[no-untyped-call]
+ compiles(_FuncDef, 'sqlite')(_sqlite_impl)
for alias in SQLITE_FUNCTION_ALIAS:
_add_function_alias(*alias)
inherit_cache = True
-@compiles(ArrayAgg, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(ArrayAgg, 'sqlite')
def sqlite_array_agg(element: ArrayAgg, compiler: 'sa.Compiled', **kw: Any) -> str:
return "group_concat(%s, ',')" % compiler.process(element.clauses, **kw)
inherit_cache = True
-@compiles(ArrayContains) # type: ignore[no-untyped-call, misc]
+@compiles(ArrayContains)
def generic_array_contains(element: ArrayContains, compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "(%s @> %s)" % (compiler.process(arg1, **kw),
compiler.process(arg2, **kw))
-@compiles(ArrayContains, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(ArrayContains, 'sqlite')
def sqlite_array_contains(element: ArrayContains, compiler: 'sa.Compiled', **kw: Any) -> str:
return "array_contains(%s)" % compiler.process(element.clauses, **kw)
inherit_cache = True
-@compiles(ArrayCat) # type: ignore[no-untyped-call, misc]
+@compiles(ArrayCat)
def generic_array_cat(element: ArrayCat, compiler: 'sa.Compiled', **kw: Any) -> str:
return "array_cat(%s)" % compiler.process(element.clauses, **kw)
-@compiles(ArrayCat, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(ArrayCat, 'sqlite')
def sqlite_array_cat(element: ArrayCat, compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "(%s || ',' || %s)" % (compiler.process(arg1, **kw), compiler.process(arg2, **kw))
name = 'JsonConcat'
inherit_cache = True
-@compiles(KeyValueConcat) # type: ignore[no-untyped-call, misc]
+@compiles(KeyValueConcat)
def default_json_concat(element: KeyValueConcat, compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "(%s || coalesce(%s, ''::hstore))" % (compiler.process(arg1, **kw), compiler.process(arg2, **kw))
-@compiles(KeyValueConcat, 'sqlite') # type: ignore[no-untyped-call, misc]
+@compiles(KeyValueConcat, 'sqlite')
def sqlite_json_concat(element: KeyValueConcat, compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
return "json_patch(%s, coalesce(%s, '{}'))" % (compiler.process(arg1, **kw), compiler.process(arg2, **kw))
else field.default
if field.metadata and 'transform' in field.metadata:
return field.metadata['transform'](v)
- if not isinstance(v, field.type):
+ if not isinstance(v, field.type): # type: ignore[arg-type]
raise UsageError(f"Parameter '{field.name}' needs to be of {field.type!s}.")
return v