mypy: minimal annotations to enable a clean run

This commit is contained in:
Sarah Hoffmann 2022-06-30 10:48:04 +02:00
parent b1903f0fbf
commit 9b636fdc10
5 changed files with 23 additions and 5 deletions

16
.mypy.ini Normal file
View File

@ -0,0 +1,16 @@
[mypy]
[mypy-icu.*]
ignore_missing_imports = True
[mypy-psycopg2.*]
ignore_missing_imports = True
[mypy-psutil]
ignore_missing_imports = True
[mypy-osmium.*]
ignore_missing_imports = True
[mypy-datrie.*]
ignore_missing_imports = True

View File

@ -7,6 +7,7 @@
"""
Nominatim configuration accessor.
"""
from typing import Dict, Any
import logging
import os
from pathlib import Path
@ -18,7 +19,7 @@ from dotenv import dotenv_values
from nominatim.errors import UsageError
LOG = logging.getLogger()
CONFIG_CACHE = {}
CONFIG_CACHE : Dict[str, Any] = {}
def flatten_config_list(content, section=''):
""" Flatten YAML configuration lists that contain include sections

View File

@ -7,6 +7,7 @@
"""
Functions for database migration to newer software versions.
"""
from typing import List, Tuple, Callable
import logging
from psycopg2 import sql as pysql
@ -20,7 +21,7 @@ from nominatim.errors import UsageError
LOG = logging.getLogger()
_MIGRATION_FUNCTIONS = []
_MIGRATION_FUNCTIONS : List[Tuple[str, Callable]] = []
def migrate(config, paths):
""" Check for the current database version and execute migrations,

View File

@ -21,8 +21,8 @@ try:
from osmium.replication.server import ReplicationServer
from osmium import WriteHandler
except ImportError as exc:
logging.getLogger().fatal("pyosmium not installed. Replication functions not available.\n"
"To install pyosmium via pip: pip3 install osmium")
logging.getLogger().critical("pyosmium not installed. Replication functions not available.\n"
"To install pyosmium via pip: pip3 install osmium")
raise UsageError("replication tools not available") from exc
LOG = logging.getLogger()

View File

@ -33,7 +33,7 @@ class SPImporter():
Take a sp loader which load the phrases from an external source.
"""
def __init__(self, config, db_connection, sp_loader) -> None:
def __init__(self, config, db_connection, sp_loader):
self.config = config
self.db_connection = db_connection
self.sp_loader = sp_loader