]> git.openstreetmap.org Git - nominatim.git/blobdiff - src/nominatim_api/search/db_search_lookups.py
fix style issue found by flake8
[nominatim.git] / src / nominatim_api / search / db_search_lookups.py
index faabd82794c0ac1979e464809815da569ab9a1ad..8e411c25b310816c30a3cf353d2c3fa9c60bf5d3 100644 (file)
@@ -12,13 +12,13 @@ from typing import List, Any
 import sqlalchemy as sa
 from sqlalchemy.ext.compiler import compiles
 
-from nominatim_core.typing import SaFromClause
-from nominatim_core.db.sqlalchemy_types import IntArray
+from ..typing import SaFromClause
+from ..sql.sqlalchemy_types import IntArray
 
-# pylint: disable=consider-using-f-string
 
 LookupType = sa.sql.expression.FunctionElement[Any]
 
+
 class LookupAll(LookupType):
     """ Find all entries in search_name table that contain all of
         a given list of tokens using an index for the search.
@@ -30,7 +30,7 @@ class LookupAll(LookupType):
                          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)
@@ -38,9 +38,9 @@ def _default_lookup_all(element: LookupAll,
                            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:
+                       compiler: 'sa.Compiled', **kw: Any) -> str:
     place, col, colname, tokens = list(element.clauses)
     return "(%s IN (SELECT CAST(value as bigint) FROM"\
            " (SELECT array_intersect_fuzzy(places) as p FROM"\
@@ -50,13 +50,11 @@ def _sqlite_lookup_all(element: LookupAll,
            "   ORDER BY length(places)) as x) as u,"\
            " json_each('[' || u.p || ']'))"\
            " AND array_contains(%s, %s))"\
-             % (compiler.process(place, **kw),
-                compiler.process(tokens, **kw),
-                compiler.process(colname, **kw),
-                compiler.process(col, **kw),
-                compiler.process(tokens, **kw)
-                )
-
+        % (compiler.process(place, **kw),
+           compiler.process(tokens, **kw),
+           compiler.process(colname, **kw),
+           compiler.process(col, **kw),
+           compiler.process(tokens, **kw))
 
 
 class LookupAny(LookupType):
@@ -69,16 +67,18 @@ class LookupAny(LookupType):
         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:
+                       compiler: 'sa.Compiled', **kw: Any) -> str:
     place, _, colname, tokens = list(element.clauses)
     return "%s IN (SELECT CAST(value as bigint) FROM"\
            " (SELECT array_union(places) as p FROM reverse_search_name"\
@@ -89,7 +89,6 @@ def _sqlite_lookup_any(element: LookupAny,
                                                compiler.process(colname, **kw))
 
 
-
 class Restrict(LookupType):
     """ Find all entries that contain all of the given tokens.
         Do not use an index for the search.
@@ -101,14 +100,15 @@ class Restrict(LookupType):
                          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:
+                      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:
+                     compiler: 'sa.Compiled', **kw: Any) -> str:
     return "array_contains(%s)" % compiler.process(element.clauses, **kw)