Skip to content

Commit 5fffd08

Browse files
authored
Merge v0.x.x into v0.18.x (#189)
2 parents 3dfaf06 + 3c4f2c8 commit 5fffd08

File tree

5 files changed

+48
-92
lines changed

5 files changed

+48
-92
lines changed

.github/workflows/ci-pr.yaml

Lines changed: 3 additions & 3 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
@@ -30,12 +30,12 @@ jobs:
3030
uses: frequenz-floss/[email protected]
3131

3232
- name: Fetch sources
33-
uses: actions/checkout@v4
33+
uses: actions/checkout@v5
3434
with:
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: 11 additions & 11 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 }}
@@ -79,12 +79,12 @@ jobs:
7979
uses: frequenz-floss/[email protected]
8080

8181
- name: Fetch sources
82-
uses: actions/checkout@v4
82+
uses: actions/checkout@v5
8383
with:
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
@@ -123,7 +123,7 @@ jobs:
123123
run: env
124124

125125
- name: Download package
126-
uses: actions/download-artifact@v4
126+
uses: actions/download-artifact@v5
127127
with:
128128
name: dist-packages
129129
path: dist
@@ -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
@@ -177,12 +177,12 @@ jobs:
177177
uses: frequenz-floss/[email protected]
178178

179179
- name: Fetch sources
180-
uses: actions/checkout@v4
180+
uses: actions/checkout@v5
181181
with:
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]
@@ -213,12 +213,12 @@ jobs:
213213
uses: frequenz-floss/[email protected]
214214

215215
- name: Fetch sources
216-
uses: actions/checkout@v4
216+
uses: actions/checkout@v5
217217
with:
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]
@@ -279,7 +279,7 @@ jobs:
279279
runs-on: ubuntu-24.04
280280
steps:
281281
- name: Download distribution files
282-
uses: actions/download-artifact@v4
282+
uses: actions/download-artifact@v5
283283
with:
284284
name: dist-packages
285285
path: dist
@@ -325,7 +325,7 @@ jobs:
325325
id-token: write
326326
steps:
327327
- name: Download distribution files
328-
uses: actions/download-artifact@v4
328+
uses: actions/download-artifact@v5
329329
with:
330330
name: dist-packages
331331
path: dist

pyproject.toml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
[build-system]
55
requires = [
66
"setuptools == 80.9.0",
7-
"setuptools_scm[toml] == 8.3.1",
8-
"frequenz-repo-config[lib] == 0.13.4",
7+
"setuptools_scm[toml] == 9.2.0",
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,45 +52,45 @@ 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
59-
"pydoclint == 0.6.6",
58+
"pydoclint == 0.6.11",
6059
"pydocstyle == 6.3.0",
6160
]
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",
69-
"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",
68+
"mkdocs-macros-plugin == 1.3.9",
69+
"mkdocs-material == 9.6.18",
70+
"mkdocstrings[python] == 0.30.0",
71+
"mkdocstrings-python == 1.18.2",
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.20250809",
78+
"types-protobuf == 6.30.2.20250822",
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 = [
85-
"pylint == 3.3.7",
84+
"pylint == 3.3.8",
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)