From 63da70685a6f0232b8f13bfa158772e035586347 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 9 Jun 2024 15:14:19 +0200 Subject: [PATCH] fix linting issues --- Makefile | 6 +++--- src/nominatim_api/search/db_search_fields.py | 2 +- src/nominatim_api/status.py | 4 ++-- src/nominatim_api/version.py | 6 +++++- src/nominatim_db/clicmd/api.py | 8 +++++--- src/nominatim_db/clicmd/args.py | 1 - src/nominatim_db/version.py | 6 +++++- 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 03ddafac..1575b72a 100644 --- a/Makefile +++ b/Makefile @@ -18,13 +18,13 @@ build-api: tests: mypy lint pytest mypy: - python3 -m mypy --strict src + mypy --strict src pytest: - python3 -m pytest test/python + pytest test/python lint: - python3 -m pylint src + pylint src bdd: cd test/bdd; behave -DREMOVE_TEMPLATE=1 diff --git a/src/nominatim_api/search/db_search_fields.py b/src/nominatim_api/search/db_search_fields.py index df2b32a7..8f674ecc 100644 --- a/src/nominatim_api/search/db_search_fields.py +++ b/src/nominatim_api/search/db_search_fields.py @@ -13,9 +13,9 @@ import dataclasses import sqlalchemy as sa from nominatim_core.typing import SaFromClause, SaColumn, SaExpression +from nominatim_core.utils.json_writer import JsonWriter from .query import Token from . import db_search_lookups as lookups -from nominatim_core.utils.json_writer import JsonWriter @dataclasses.dataclass diff --git a/src/nominatim_api/status.py b/src/nominatim_api/status.py index ec6ce5d6..614789ed 100644 --- a/src/nominatim_api/status.py +++ b/src/nominatim_api/status.py @@ -14,7 +14,7 @@ import dataclasses import sqlalchemy as sa from .connection import SearchConnection -from .version import NOMINATIM_API_VERSION, parse_version +from .version import NOMINATIM_API_VERSION, NominatimVersion, parse_version @dataclasses.dataclass class StatusResult: @@ -24,7 +24,7 @@ class StatusResult: message: str software_version = NOMINATIM_API_VERSION data_updated: Optional[dt.datetime] = None - database_version: Optional[str] = None + database_version: Optional[NominatimVersion] = None async def get_status(conn: SearchConnection) -> StatusResult: diff --git a/src/nominatim_api/version.py b/src/nominatim_api/version.py index 5d932fc9..5dd084c7 100644 --- a/src/nominatim_api/version.py +++ b/src/nominatim_api/version.py @@ -8,6 +8,10 @@ Version information for the Nominatim API. """ -from nominatim_core.version import NominatimVersion, parse_version +# See also https://github.com/PyCQA/pylint/issues/6006 +# pylint: disable=useless-import-alias,unused-import + +from nominatim_core.version import (NominatimVersion as NominatimVersion, + parse_version as parse_version) NOMINATIM_API_VERSION = '4.4.99' diff --git a/src/nominatim_db/clicmd/api.py b/src/nominatim_db/clicmd/api.py index 0f0d1ebd..25b4bff3 100644 --- a/src/nominatim_db/clicmd/api.py +++ b/src/nominatim_db/clicmd/api.py @@ -12,7 +12,9 @@ import argparse import logging import json import sys +from functools import reduce +from nominatim_core.errors import UsageError import nominatim_api as napi import nominatim_api.v1 as api_output from nominatim_api.v1.helpers import zoom_to_rank, deduplicate_results @@ -61,7 +63,7 @@ def _add_api_output_arguments(parser: argparse.ArgumentParser) -> None: "Parameter is difference tolerance in degrees.")) -def _get_geometry_output(args) -> napi.GeometryFormat: +def _get_geometry_output(args: NominatimArgs) -> napi.GeometryFormat: """ Get the requested geometry output format in a API-compatible format. """ @@ -82,7 +84,7 @@ def _get_geometry_output(args) -> napi.GeometryFormat: raise UsageError(f"Unknown polygon output format '{args.polygon_output}'.") from exp -def _get_locales(args, default: Optional[str]) -> napi.Locales: +def _get_locales(args: NominatimArgs, default: Optional[str]) -> napi.Locales: """ Get the locales from the language parameter. """ if args.lang: @@ -93,7 +95,7 @@ def _get_locales(args, default: Optional[str]) -> napi.Locales: return napi.Locales() -def _get_layers(args, default: napi.DataLayer) -> Optional[napi.DataLayer]: +def _get_layers(args: NominatimArgs, default: napi.DataLayer) -> Optional[napi.DataLayer]: """ Get the list of selected layers as a DataLayer enum. """ if not args.layers: diff --git a/src/nominatim_db/clicmd/args.py b/src/nominatim_db/clicmd/args.py index aa95dbb9..857cb55e 100644 --- a/src/nominatim_db/clicmd/args.py +++ b/src/nominatim_db/clicmd/args.py @@ -10,7 +10,6 @@ Provides custom functions over command-line arguments. from typing import Optional, List, Dict, Any, Sequence, Tuple import argparse import logging -from functools import reduce from pathlib import Path from nominatim_core.errors import UsageError diff --git a/src/nominatim_db/version.py b/src/nominatim_db/version.py index 82ae17e9..525a0d99 100644 --- a/src/nominatim_db/version.py +++ b/src/nominatim_db/version.py @@ -9,7 +9,11 @@ Version information for Nominatim. """ from typing import Optional -from nominatim_core.version import NominatimVersion, parse_version +# See also https://github.com/PyCQA/pylint/issues/6006 +# pylint: disable=useless-import-alias,unused-import + +from nominatim_core.version import (NominatimVersion as NominatimVersion, + parse_version as parse_version) NOMINATIM_VERSION = NominatimVersion(4, 4, 99, 1) -- 2.39.5