Skip to content

Commit 8e59400

Browse files
committed
Merge tag 'v0.9.1' into v0.17.x
Remove the `timezonefinder` dependency to significantly reduce package size by 66M+ and enable ARM platform support. * tag 'v0.9.1': Bump mkdocstrings[python] in the mkdocstrings group Bump async-solipsism from 0.7 to 0.8 Bump types-protobuf from 6.30.2.20250516 to 6.30.2.20250703 Bump the compatible group with 2 updates Bump pytest-asyncio from 1.0.0 to 1.1.0 Bump types-markdown from 3.8.0.20250415 to 3.8.0.20250708 Bump mypy from 1.16.1 to 1.17.1 in the minor group Bump mkdocs-material from 9.6.14 to 9.6.16 in the patch group Remove timezonefinder dependency and automatic timezone lookup Bump pytest-asyncio from 0.26.0 to 1.0.0 Bump the patch group with 5 updates Bump the minor group with 2 updates Signed-off-by: Leandro Lucarella <[email protected]>
2 parents 3dfaf06 + c025df1 commit 8e59400

File tree

5 files changed

+37
-81
lines changed

5 files changed

+37
-81
lines changed

.github/workflows/ci-pr.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Run nox
20-
uses: frequenz-floss/[email protected].0
20+
uses: frequenz-floss/[email protected].1
2121
with:
2222
python-version: "3.11"
2323
nox-session: ci_checks_max
@@ -35,7 +35,7 @@ jobs:
3535
submodules: true
3636

3737
- name: Setup Python
38-
uses: frequenz-floss/[email protected].0
38+
uses: frequenz-floss/[email protected].1
3939
with:
4040
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
4141
dependencies: .[dev-mkdocs]

.github/workflows/ci.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Run nox
48-
uses: frequenz-floss/[email protected].0
48+
uses: frequenz-floss/[email protected].1
4949
with:
5050
python-version: ${{ matrix.python }}
5151
nox-session: ${{ matrix.nox-session }}
@@ -84,7 +84,7 @@ jobs:
8484
submodules: true
8585

8686
- name: Setup Python
87-
uses: frequenz-floss/[email protected].0
87+
uses: frequenz-floss/[email protected].1
8888
with:
8989
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
9090
dependencies: build
@@ -143,7 +143,7 @@ jobs:
143143
> pyproject.toml
144144
145145
- name: Setup Python
146-
uses: frequenz-floss/[email protected].0
146+
uses: frequenz-floss/[email protected].1
147147
with:
148148
python-version: ${{ matrix.python }}
149149
dependencies: dist/*.whl
@@ -182,7 +182,7 @@ jobs:
182182
submodules: true
183183

184184
- name: Setup Python
185-
uses: frequenz-floss/[email protected].0
185+
uses: frequenz-floss/[email protected].1
186186
with:
187187
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
188188
dependencies: .[dev-mkdocs]
@@ -218,7 +218,7 @@ jobs:
218218
submodules: true
219219

220220
- name: Setup Python
221-
uses: frequenz-floss/[email protected].0
221+
uses: frequenz-floss/[email protected].1
222222
with:
223223
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
224224
dependencies: .[dev-mkdocs]

pyproject.toml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
requires = [
66
"setuptools == 80.9.0",
77
"setuptools_scm[toml] == 8.3.1",
8-
"frequenz-repo-config[lib] == 0.13.4",
8+
"frequenz-repo-config[lib] == 0.13.5",
99
]
1010
build-backend = "setuptools.build_meta"
1111

@@ -42,7 +42,6 @@ dependencies = [
4242
"frequenz-client-common >= 0.3.2, < 0.4.0",
4343
"grpcio >= 1.72.1, < 2",
4444
"protobuf >= 6.31.1, < 7",
45-
"timezonefinder >= 6.2.0, < 7",
4645
"typing-extensions >= 4.13.0, < 5",
4746
]
4847
dynamic = ["version"]
@@ -53,7 +52,7 @@ email = "[email protected]"
5352

5453
[project.optional-dependencies]
5554
dev-flake8 = [
56-
"flake8 == 7.2.0",
55+
"flake8 == 7.3.0",
5756
"flake8-docstrings == 1.7.0",
5857
"flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml
5958
"pydoclint == 0.6.6",
@@ -62,36 +61,36 @@ dev-flake8 = [
6261
dev-formatting = ["black == 25.1.0", "isort == 6.0.1"]
6362
dev-mkdocs = [
6463
"black == 25.1.0",
65-
"Markdown==3.8",
64+
"Markdown==3.8.2",
6665
"mike == 2.1.3",
6766
"mkdocs-gen-files == 0.5.0",
6867
"mkdocs-literate-nav == 0.6.2",
6968
"mkdocs-macros-plugin == 1.3.7",
70-
"mkdocs-material == 9.6.14",
71-
"mkdocstrings[python] == 0.29.1",
72-
"mkdocstrings-python == 1.16.11",
73-
"frequenz-repo-config[lib] == 0.13.4",
69+
"mkdocs-material == 9.6.16",
70+
"mkdocstrings[python] == 0.30.0",
71+
"mkdocstrings-python == 1.16.12",
72+
"frequenz-repo-config[lib] == 0.13.5",
7473
]
7574
dev-mypy = [
76-
"mypy == 1.16.0",
75+
"mypy == 1.17.1",
7776
"grpc-stubs == 1.53.0.6",
78-
"types-Markdown == 3.8.0.20250415",
79-
"types-protobuf == 6.30.2.20250516",
77+
"types-Markdown == 3.8.0.20250708",
78+
"types-protobuf == 6.30.2.20250703",
8079
# For checking the noxfile, docs/ script, and tests
8180
"frequenz-client-microgrid[dev-mkdocs,dev-noxfile,dev-pytest]",
8281
]
83-
dev-noxfile = ["nox == 2025.5.1", "frequenz-repo-config[lib] == 0.13.4"]
82+
dev-noxfile = ["nox == 2025.5.1", "frequenz-repo-config[lib] == 0.13.5"]
8483
dev-pylint = [
8584
"pylint == 3.3.7",
8685
# For checking the noxfile, docs/ script, and tests
8786
"frequenz-client-microgrid[dev-mkdocs,dev-noxfile,dev-pytest]",
8887
]
8988
dev-pytest = [
90-
"pytest == 8.3.5",
91-
"frequenz-repo-config[extra-lint-examples] == 0.13.4",
89+
"pytest == 8.4.1",
90+
"frequenz-repo-config[extra-lint-examples] == 0.13.5",
9291
"pytest-mock == 3.14.1",
93-
"pytest-asyncio == 0.26.0",
94-
"async-solipsism == 0.7",
92+
"pytest-asyncio == 1.1.0",
93+
"async-solipsism == 0.8",
9594
]
9695
dev = [
9796
"frequenz-client-microgrid[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",

src/frequenz/client/microgrid/_location.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,7 @@
44
"""Location information for a microgrid."""
55

66

7-
import logging
87
from dataclasses import dataclass
9-
from functools import cached_property
10-
from zoneinfo import ZoneInfo
11-
12-
import timezonefinder
13-
14-
_timezone_finder = timezonefinder.TimezoneFinder()
15-
_logger = logging.getLogger(__name__)
168

179

1810
@dataclass(frozen=True, kw_only=True)
@@ -28,17 +20,6 @@ class Location:
2820
country_code: str | None
2921
"""The country code of the microgrid in ISO 3166-1 Alpha 2 format."""
3022

31-
@cached_property
32-
def timezone(self) -> ZoneInfo | None:
33-
"""The timezone of the microgrid, or `None` if it could not be determined."""
34-
if self.latitude is None or self.longitude is None:
35-
_logger.warning(
36-
"Latitude (%s) or longitude (%s) missing, cannot determine timezone"
37-
)
38-
return None
39-
timezone = _timezone_finder.timezone_at(lat=self.latitude, lng=self.longitude)
40-
return ZoneInfo(key=timezone) if timezone else None
41-
4223
def __str__(self) -> str:
4324
"""Return the short string representation of this instance."""
4425
country = self.country_code or "<NO COUNTRY CODE>"

tests/test_location.py

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44
"""Tests for the microgrid metadata types."""
55

6-
from collections.abc import Iterator
76
from dataclasses import dataclass
8-
from unittest.mock import MagicMock, patch
9-
from zoneinfo import ZoneInfo
107

118
import pytest
129
from frequenz.api.common.v1 import location_pb2
@@ -44,43 +41,22 @@ class _ProtoConversionTestCase: # pylint: disable=too-many-instance-attributes
4441
"""Whether to expect a warning during conversion."""
4542

4643

47-
@pytest.fixture
48-
def timezone_finder() -> Iterator[MagicMock]:
49-
"""Return a mock timezone finder."""
50-
with patch(
51-
"frequenz.client.microgrid._location._timezone_finder", autospec=True
52-
) as mock_timezone_finder:
53-
yield mock_timezone_finder
54-
55-
56-
def test_timezone_not_looked_up_if_unused(timezone_finder: MagicMock) -> None:
57-
"""Test the location timezone is not looked up if it is not used."""
58-
location = Location(latitude=52.52, longitude=13.405, country_code="DE")
59-
60-
assert location.latitude == 52.52
61-
assert location.longitude == 13.405
62-
assert location.country_code == "DE"
63-
timezone_finder.timezone_at.assert_not_called()
64-
65-
66-
def test_timezone_looked_up_but_not_found(timezone_finder: MagicMock) -> None:
67-
"""Test the location timezone is not looked up if it is not used."""
68-
timezone_finder.timezone_at.return_value = None
69-
70-
location = Location(latitude=52.52, longitude=13.405, country_code="DE")
71-
72-
assert location.timezone is None
73-
timezone_finder.timezone_at.assert_called_once_with(lat=52.52, lng=13.405)
74-
75-
76-
def test_timezone_looked_up_and_found(timezone_finder: MagicMock) -> None:
77-
"""Test the location timezone is not looked up if it is not used."""
78-
timezone_finder.timezone_at.return_value = "Europe/Berlin"
79-
80-
location = Location(latitude=52.52, longitude=13.405, country_code="DE")
44+
@pytest.mark.parametrize("latitude", [None, 52.52], ids=str)
45+
@pytest.mark.parametrize("longitude", [None, 13.405], ids=str)
46+
@pytest.mark.parametrize("country_code", [None, "DE"], ids=str)
47+
def test_location_initialization(
48+
latitude: float | None,
49+
longitude: float | None,
50+
country_code: str | None,
51+
) -> None:
52+
"""Test location initialization with different combinations of parameters."""
53+
location = Location(
54+
latitude=latitude, longitude=longitude, country_code=country_code
55+
)
8156

82-
assert location.timezone == ZoneInfo(key="Europe/Berlin")
83-
timezone_finder.timezone_at.assert_called_once_with(lat=52.52, lng=13.405)
57+
assert location.latitude == latitude
58+
assert location.longitude == longitude
59+
assert location.country_code == country_code
8460

8561

8662
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)