From 1bb6613bcca999030baad2121d338b32b26ff04a Mon Sep 17 00:00:00 2001 From: Bertrand Bordage Date: Thu, 23 Nov 2017 16:53:41 +0100 Subject: [PATCH] Types the search query API. --- wagtail/wagtailsearch/query.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/wagtail/wagtailsearch/query.py b/wagtail/wagtailsearch/query.py index fb72b22e1..37be41e27 100644 --- a/wagtail/wagtailsearch/query.py +++ b/wagtail/wagtailsearch/query.py @@ -24,7 +24,7 @@ class Or(SearchQueryOperator): class Not(SearchQueryOperator): - def __init__(self, subquery): + def __init__(self, subquery: SearchQuery): self.subquery = subquery @@ -33,39 +33,41 @@ class MatchAll(SearchQuery): class PlainText(SearchQuery): - def __init__(self, query_string, operator=None, boost=1.0): + def __init__(self, query_string: str, operator: str = None, + boost: float = 1.0): self.query_string = query_string self.operator = operator self.boost = boost class Term(SearchQuery): - def __init__(self, term, boost=1.0): + def __init__(self, term: str, boost: float = 1.0): self.term = term self.boost = boost class Prefix(SearchQuery): - def __init__(self, prefix, boost=1.0): + def __init__(self, prefix: str, boost: float = 1.0): self.prefix = prefix self.boost = boost class Fuzzy(SearchQuery): - def __init__(self, term, max_distance=3, boost=1.0): + def __init__(self, term: str, max_distance: float = 3, boost: float = 1.0): self.term = term self.max_distance = max_distance self.boost = boost class Boost(SearchQuery): - def __init__(self, query, boost): + def __init__(self, query: SearchQuery, boost: float): self.query = query self.boost = boost class Filter(SearchQuery): - def __init__(self, query, include=None, exclude=None): + def __init__(self, query: SearchQuery, + include: SearchQuery = None, exclude: SearchQuery = None): self.query = query self.include = include self.exclude = exclude