From 32b5af25c3c150df8a78258bbbf1cc7a62529741 Mon Sep 17 00:00:00 2001 From: Sveinbjorn Thordarson Date: Sun, 12 May 2024 21:16:58 +0000 Subject: [PATCH] Updated copyright headers, minor refactoring --- .github/workflows/python-package.yml | 2 +- LICENSE.txt | 2 +- README.md | 2 +- pyproject.toml | 1 + src/iceaddr/__init__.py | 4 ++-- src/iceaddr/addresses.py | 4 +--- src/iceaddr/db.py | 2 +- src/iceaddr/dist.py | 6 ++---- src/iceaddr/placenames.py | 4 +--- src/iceaddr/postcodes.py | 4 +--- tests/__init__.py | 0 tests/test_iceaddr.py | 2 +- 12 files changed, 13 insertions(+), 20 deletions(-) create mode 100644 tests/__init__.py diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index ba6c8d0..8a9c0a5 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.12"] + python-version: ["3.9", "3.12"] steps: - uses: actions/checkout@v4 diff --git a/LICENSE.txt b/LICENSE.txt index c34e7c9..d3f7ed6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2018-2023, Sveinbjorn Thordarson +Copyright (c) 2018-2024, Sveinbjorn Thordarson All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index a1ff5a1..e9ebe27 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ pip install . ## BSD License -Copyright (C) 2018-2023 Sveinbjorn Thordarson [<sveinbjorn@sveinbjorn.org>](mailto:sveinbjorn@sveinbjorn.org) +Copyright (C) 2018-2024 Sveinbjorn Thordarson [<sveinbjorn@sveinbjorn.org>](mailto:sveinbjorn@sveinbjorn.org) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/pyproject.toml b/pyproject.toml index 3476776..e2789a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,6 +117,7 @@ ignore = [ "TID", # No relative parent imports rule "TCH", # Move into type checking block - too risky, causes issues "RSE102", # Bug: https://github.com/astral-sh/ruff/issues/5416 + "FA100", # ] # Silence complaints when black doesn't format # lines that are slightly over 88 characters long diff --git a/src/iceaddr/__init__.py b/src/iceaddr/__init__.py index e5f1c59..c13de06 100644 --- a/src/iceaddr/__init__.py +++ b/src/iceaddr/__init__.py @@ -3,14 +3,14 @@ iceaddr: Look up information about Icelandic streets, addresses, placenames, landmarks, locations and postcodes. - Copyright (c) 2018-2023 Sveinbjorn Thordarson. + Copyright (c) 2018-2024 Sveinbjorn Thordarson. """ import importlib.metadata __author__ = "Sveinbjorn Thordarson" -__copyright__ = "(C) 2018-2023 Sveinbjorn Thordarson" +__copyright__ = "(C) 2018-2024 Sveinbjorn Thordarson" __version__ = importlib.metadata.version("iceaddr") from .addresses import * # noqa: F403 diff --git a/src/iceaddr/addresses.py b/src/iceaddr/addresses.py index 545082e..6f5284b 100644 --- a/src/iceaddr/addresses.py +++ b/src/iceaddr/addresses.py @@ -3,14 +3,12 @@ iceaddr: Look up information about Icelandic streets, addresses, placenames, landmarks, locations and postcodes. - Copyright (c) 2018-2023 Sveinbjorn Thordarson. + Copyright (c) 2018-2024 Sveinbjorn Thordarson. This file contains code related to Icelandic address lookup. """ -from __future__ import annotations - from typing import Any, Dict, List, Optional import re diff --git a/src/iceaddr/db.py b/src/iceaddr/db.py index 604701c..54796cb 100644 --- a/src/iceaddr/db.py +++ b/src/iceaddr/db.py @@ -3,7 +3,7 @@ iceaddr: Look up information about Icelandic streets, addresses, placenames, landmarks, locations and postcodes. - Copyright (c) 2018-2023 Sveinbjorn Thordarson. + Copyright (c) 2018-2024 Sveinbjorn Thordarson. This file contains code related to the iceaddr sqlite3 database. diff --git a/src/iceaddr/dist.py b/src/iceaddr/dist.py index c56a18d..68d5f71 100644 --- a/src/iceaddr/dist.py +++ b/src/iceaddr/dist.py @@ -7,13 +7,11 @@ """ -from __future__ import annotations - from typing import Tuple import math -_EARTH_RADIUS = 6371.0088 # Earth's radius in km +EARTH_RADIUS_KM = 6371.0088 def distance(loc1: Tuple[float, float], loc2: Tuple[float, float]) -> float: @@ -54,7 +52,7 @@ def distance(loc1: Tuple[float, float], loc2: Tuple[float, float]) -> float: + math.cos(math.radians(lat1)) * math.cos(math.radians(lat2)) * slon * slon ) c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) - return _EARTH_RADIUS * c + return EARTH_RADIUS_KM * c ICELAND_COORDS = (64.9957538607, -18.5739616708) diff --git a/src/iceaddr/placenames.py b/src/iceaddr/placenames.py index eee7812..0151b5b 100644 --- a/src/iceaddr/placenames.py +++ b/src/iceaddr/placenames.py @@ -3,14 +3,12 @@ iceaddr: Look up information about Icelandic streets, addresses, placenames, landmarks, locations and postcodes. - Copyright (c) 2018-2023 Sveinbjorn Thordarson. + Copyright (c) 2018-2024 Sveinbjorn Thordarson. This file contains code related to placename lookup. """ -from __future__ import annotations - from typing import Any, Dict, List from .db import shared_db diff --git a/src/iceaddr/postcodes.py b/src/iceaddr/postcodes.py index 23a5cea..293a9c7 100644 --- a/src/iceaddr/postcodes.py +++ b/src/iceaddr/postcodes.py @@ -3,14 +3,12 @@ iceaddr: Look up information about Icelandic streets, addresses, placenames, landmarks, locations and postcodes. - Copyright (c) 2018-2023 Sveinbjorn Thordarson. + Copyright (c) 2018-2024 Sveinbjorn Thordarson. This file contains code and data related to Icelandic postcodes. """ -from __future__ import annotations - from typing import Dict, List, Optional, Union POSTCODES: Dict[int, Dict[str, str]] = { diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_iceaddr.py b/tests/test_iceaddr.py index 2d7e0e8..f9b43be 100644 --- a/tests/test_iceaddr.py +++ b/tests/test_iceaddr.py @@ -3,7 +3,7 @@ iceaddr: Look up information about Icelandic streets, addresses, placenames, landmarks, locations and postcodes. - Copyright (c) 2018-2023 Sveinbjorn Thordarson. + Copyright (c) 2018-2024 Sveinbjorn Thordarson. Tests for iceaddr python package.