Skip to content

Commit

Permalink
update black
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-dupre committed Feb 25, 2021
1 parent 9f1c5f5 commit 9747448
Show file tree
Hide file tree
Showing 25 changed files with 275 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ lovely-pytest-docker = "*"
freezegun = "*"
ipython = "*"
responses = "*"
black = "==19.10b0"
black = "==20.8b1"
respx = "*"
pylint = "*"

Expand Down
149 changes: 144 additions & 5 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion idunn/api/instant_answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class InstantAnswerResult(BaseModel):
),
example=(2.32, 48.85, 2.367, 48.866),
)
maps_url: HttpUrl = Field(description="Direct URL to the result(s) on Qwant Maps.",)
maps_url: HttpUrl = Field(
description="Direct URL to the result(s) on Qwant Maps.",
)
maps_frame_url: HttpUrl = Field(
description="URL to the map displaying the results on Qwant Maps, with no user interface. "
"This URL can be used to display an `<iframe>`."
Expand Down
10 changes: 8 additions & 2 deletions idunn/api/places_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ async def get_places_bbox(
)

return PlacesBboxResponse(
places=result_places, source=params.source, bbox=results_bbox, bbox_extended=bbox_extended,
places=result_places,
source=params.source,
bbox=results_bbox,
bbox_extended=bbox_extended,
)


Expand All @@ -220,7 +223,10 @@ async def _fetch_places_list(params: PlacesQueryParam):
raw_filters = [f for c in params.category for f in c.raw_filters()]

bbox_places = await run_in_threadpool(
fetch_es_pois, raw_filters=raw_filters, bbox=params.bbox, max_size=params.size,
fetch_es_pois,
raw_filters=raw_filters,
bbox=params.bbox,
max_size=params.size,
)
return [POI(p["_source"]) for p in bbox_places]

Expand Down
3 changes: 1 addition & 2 deletions idunn/api/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@


def get_status():
"""Returns the status of the elastic cluster
"""
"""Returns the status of the elastic cluster"""
es = get_elasticsearch()
try:
cluster_health = es.cluster.health()
Expand Down
4 changes: 3 additions & 1 deletion idunn/blocks/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def wrapped_f(*args, **kwargs):
except pybreaker.CircuitBreakerError:
prometheus.exception("CircuitBreakerError")
logger.error(
"Got CircuitBreakerError in %s", f.__name__, exc_info=True,
"Got CircuitBreakerError in %s",
f.__name__,
exc_info=True,
)
except HTTPError:
prometheus.exception("HTTPError")
Expand Down
3 changes: 2 additions & 1 deletion idunn/datasources/pages_jaunes.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def get_places_from_url(self, url, params=None, size=10):
and res.context.pages.next_page_url
):
pois += self.get_places_from_url(
res.context.pages.next_page_url, size=size - len(pois),
res.context.pages.next_page_url,
size=size - len(pois),
)

return pois
Expand Down
3 changes: 2 additions & 1 deletion idunn/directions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ def directions_combigo(self, start, end, mode, lang):
def get_directions(self, from_place, to_place, mode, lang, params: QueryParams):
if not DirectionsClient.is_in_allowed_zone(mode, from_place, to_place):
raise HTTPException(
status_code=422, detail="requested path is not inside an allowed area",
status_code=422,
detail="requested path is not inside an allowed area",
)

method = self.directions_qwant
Expand Down
4 changes: 2 additions & 2 deletions idunn/geocoder/nlu_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def nlu_classifier(self, text):

@staticmethod
def regex_classifier(text, is_brand=False):
""" Match text with a category, using 'regex'
"""Match text with a category, using 'regex'
>>> NLU_Helper.regex_classifier("restau").value
'restaurant'
>>> NLU_Helper.regex_classifier("pub").value
Expand All @@ -98,7 +98,7 @@ async def classify_category(self, text, is_brand=False):

@classmethod
def fuzzy_match(cls, query, bragi_res):
""" Does the response match the query reasonably well ?
"""Does the response match the query reasonably well ?
>>> NLU_Helper.fuzzy_match("bastille", {"name": "Beuzeville-la-Bastille"})
False
>>> NLU_Helper.fuzzy_match("paris 20", {"name": "Paris 20e Arrondissement"})
Expand Down
6 changes: 5 additions & 1 deletion idunn/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def get_logging_dict(settings):
},
"loggers": {
"uvicorn": {"level": "INFO", "handlers": ["console"], "propagate": False},
"uvicorn.access": {"level": "WARNING", "handlers": ["console"], "propagate": False,},
"uvicorn.access": {
"level": "WARNING",
"handlers": ["console"],
"propagate": False,
},
"gunicorn": {"level": "INFO", "handlers": ["console"], "propagate": False},
# "gunicorn.error" logger needs to be defined explicitly,
# as it will be used by UvicornWorker to configure its own error logger
Expand Down
8 changes: 6 additions & 2 deletions idunn/utils/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ def expose_metrics_multiprocess():


REQUEST_DURATION = Histogram(
"http_request_duration_seconds", "Time spent processing a request.", ["method", "handler"],
"http_request_duration_seconds",
"Time spent processing a request.",
["method", "handler"],
)
REQUEST_COUNT = Counter(
"http_requests_total",
"Request count by method, handler and response code.",
["method", "handler", "code"],
)
REQUESTS_INPROGRESS = Gauge(
"http_requests_inprogress", "Requests in progress by method and handler", ["method", "handler"],
"http_requests_inprogress",
"Requests in progress by method and handler",
["method", "handler"],
)


Expand Down
4 changes: 3 additions & 1 deletion idunn/utils/result_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ def coverage(terms):

if not check_coverage:
logger.info(
"Removed `%s` from results because query `%s` is not accurate enough", name, query,
"Removed `%s` from results because query `%s` is not accurate enough",
name,
query,
)
return False

Expand Down
11 changes: 10 additions & 1 deletion tests/test_accessibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ def test_accessibility_block():


def test_accessibility_unknown():
web_block = AccessibilityBlock.from_es(POI({"properties": {"wheelchair": "toto",}}), lang="en")
web_block = AccessibilityBlock.from_es(
POI(
{
"properties": {
"wheelchair": "toto",
}
}
),
lang="en",
)
assert web_block is None


Expand Down

0 comments on commit 9747448

Please sign in to comment.