From 6a2960f04497c1381b6742861a98af2eb3c7911d Mon Sep 17 00:00:00 2001 From: Kevin Meagher <11620178+kjmeagher@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:29:46 -0500 Subject: [PATCH] use aliases on reference and target timezones --- .pre-commit-config.yaml | 9 +++------ multizone.py | 5 +++-- pyproject.toml | 2 +- test_mz.py | 5 ++++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 71e92c3..1ee4e85 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,22 +17,19 @@ repos: rev: v4.0.3 hooks: - id: reuse -- repo: https://github.com/psf/black - rev: 24.8.0 - hooks: - - id: black - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.9 + rev: v0.7.1 hooks: - id: ruff args: [--fix] + - id: ruff-format - repo: https://github.com/pycqa/pylint rev: v3.3.1 hooks: - id: pylint additional_dependencies: [babel, tabulate, tzlocal, xdg-base-dirs, termcolor, pytest] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy additional_dependencies: [types-tabulate, types-tzlocal, types-termcolor] diff --git a/multizone.py b/multizone.py index 7f4fe38..9973e43 100755 --- a/multizone.py +++ b/multizone.py @@ -202,12 +202,13 @@ def zone_table( zones.append((name, time)) if not found_local: - zones.append((str(localzone), localdt)) + localname = str(localzone) + zones.append((aliases.get(localname, localname), localdt)) if not found_ref and localoffset != refoffset: tzname = refdt.tzname() assert tzname is not None - zones.append((tzname, refdt)) + zones.append((aliases.get(tzname, tzname), refdt)) zones.sort(key=time_offset) return zones diff --git a/pyproject.toml b/pyproject.toml index 5e686e7..a83a3f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ include = ["multizone.py"] max-line-length = "108" [tool.pylint.message_control] -disable = "R0912" +disable = "R0912,R0914" [tool.ruff] fixable = ["D", "I", "COM"] diff --git a/test_mz.py b/test_mz.py index b444fad..bb8f6c2 100755 --- a/test_mz.py +++ b/test_mz.py @@ -180,6 +180,9 @@ def test_zone_table() -> None: tab4 = multizone.zone_table(["ROK", "EST", "UTC"], {"ROK": "Korea", "EST": "Eastern"}, time0, rok) assert tab4 == [("Korea", time_rok), ("UTC", time0), ("Eastern", time_est)] + tab5 = multizone.zone_table(["EST"], {"ROK": "Korea", "UTC": "London"}, time0, rok) + assert tab5 == [("Korea", time_rok), ("London", time0), ("EST", time_est)] + def test_table_to_string() -> None: """Test table_to_string().""" @@ -197,4 +200,4 @@ def test_table_to_string() -> None: if __name__ == "__main__": - pytest.main(["-v", __file__]) + sys.exit(pytest.main(["-v", __file__, *sys.argv[1:]]))