define type for enivronment dictionaries

This commit is contained in:
Sarah Hoffmann
2022-07-03 17:38:11 +02:00
parent f12fe54d2b
commit c4928c646d
3 changed files with 9 additions and 6 deletions

View File

@@ -7,7 +7,7 @@
"""
Helper functions for executing external programs.
"""
from typing import Any, Union, Optional, Mapping
from typing import Any, Union, Optional, Mapping, IO
from pathlib import Path
import logging
import subprocess
@@ -160,7 +160,8 @@ def get_url(url: str) -> str:
headers = {"User-Agent": f"Nominatim/{version_str()}"}
try:
with urlrequest.urlopen(urlrequest.Request(url, headers=headers)) as response:
request = urlrequest.Request(url, headers=headers)
with urlrequest.urlopen(request) as response: # type: IO[bytes]
return response.read().decode('utf-8')
except Exception:
LOG.fatal('Failed to load URL: %s', url)