From 3b81b2ba2a48a6d5b7204038c8a26a693e4bd603 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Tue, 10 Jun 2025 15:08:03 +0200 Subject: [PATCH 1/8] Fix typos in documentation Signed-off-by: Leandro Lucarella --- RELEASE_NOTES.md | 2 +- src/frequenz/repo/config/__init__.py | 6 +++--- src/frequenz/repo/config/nox/__init__.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b99e3a30..dda1c7e6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -30,7 +30,7 @@ But you might still need to adapt your code: ## Bug Fixes - +- Fixed some typos in the docs. ### Cookiecutter template diff --git a/src/frequenz/repo/config/__init__.py b/src/frequenz/repo/config/__init__.py index fbbfeec8..753e5a3f 100644 --- a/src/frequenz/repo/config/__init__.py +++ b/src/frequenz/repo/config/__init__.py @@ -35,8 +35,8 @@ nox.configure(RepositoryType.LIB) ``` -Again, make sure to pick the correct project typedefault configuration based on the type of your -project (`actor_config`, `api_config`, `app_config`, `lib_config`, `model_config`). +Again, make sure to pick the correct project default configuration based on the type of +your project (`actor_config`, `api_config`, `app_config`, `lib_config`, `model_config`). If you need to use some custom configuration, you can start from the default settings in the [`frequenz.repo.config.nox.default`][] module, @@ -312,7 +312,7 @@ typed. 3. Exclude the `src/conftest.py` file from the distribution package, as it shouldn't be - shipped with the code, it is only for delelopment purposes. To do so, add the + shipped with the code, it is only for development purposes. To do so, add the following line to the `MANIFEST.in` file: ``` diff --git a/src/frequenz/repo/config/nox/__init__.py b/src/frequenz/repo/config/nox/__init__.py index 1f96662b..8cd529eb 100644 --- a/src/frequenz/repo/config/nox/__init__.py +++ b/src/frequenz/repo/config/nox/__init__.py @@ -15,7 +15,7 @@ nox.configure(RepositoryType.LIB) ``` -Again, make sure to pick the correct project typedefault configuration based on the type +Again, make sure to pick the correct project default configuration based on the type of your project (`actor_config`, `api_config`, `app_config`, `lib_config`, `model_config`). From 6aff0995d93ff53e36f32804486c3bf83dde2031 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 16 Jun 2025 12:00:34 +0200 Subject: [PATCH 2/8] Do not convert array of paths to a string When loading protobuf include paths from the pyproject.toml file, the paths are received as an array/list. If we convert them to a comma-separated string there is the risk of a path containing commas to be split incorrectly, leading to compilation errors. Using the original array/list of paths instead of a comma-separated string is safer and more flexible. Signed-off-by: Leandro Lucarella --- .../repo/config/setuptools/grpc_tools.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/frequenz/repo/config/setuptools/grpc_tools.py b/src/frequenz/repo/config/setuptools/grpc_tools.py index 9d0559eb..d6917aba 100644 --- a/src/frequenz/repo/config/setuptools/grpc_tools.py +++ b/src/frequenz/repo/config/setuptools/grpc_tools.py @@ -13,7 +13,8 @@ import pathlib as _pathlib import subprocess as _subprocess import sys as _sys -from typing import cast +from collections.abc import Iterable +from typing import assert_never, cast import setuptools as _setuptools import setuptools.command.build as _build_command @@ -30,8 +31,8 @@ class CompileProto(_setuptools.Command): proto_glob: str """The glob pattern to use to find the protobuf files.""" - include_paths: str - """Comma-separated list of paths to include when compiling the protobuf files.""" + include_paths: str | Iterable[str] + """Iterable or comma-separated list of paths to include when compiling the protobuf files.""" py_path: str """The path of the root directory where the Python files will be generated.""" @@ -72,7 +73,7 @@ def initialize_options(self) -> None: self.proto_path = config.proto_path self.proto_glob = config.proto_glob - self.include_paths = ",".join(config.include_paths) + self.include_paths = config.include_paths self.py_path = config.py_path def finalize_options(self) -> None: @@ -80,7 +81,15 @@ def finalize_options(self) -> None: def run(self) -> None: """Compile the Python protobuf files.""" - include_paths = self.include_paths.split(",") + include_paths: Iterable[str] + match self.include_paths: + case str() as str_paths: + include_paths = str_paths.split(",") + case Iterable() as paths_it: + include_paths = paths_it + case unexpected: + assert_never(unexpected) + proto_files = [ str(p) for p in _pathlib.Path(self.proto_path).rglob(self.proto_glob) ] From ef1733a5d7ae986c97e4879dfa94725edda573b7 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 16 Jun 2025 12:09:55 +0200 Subject: [PATCH 3/8] Clean comma-separated include paths in grpc_tools When include paths are passed via the commnad-line, they are passed as a comma-separated string. This means the user could add extra spaces or pass a double-comma, which would result in empty strings in the include paths list, making the protobuf compiler fail. This commit cleans the include paths by stripping whitespace and ignoring empty strings. Signed-off-by: Leandro Lucarella --- src/frequenz/repo/config/setuptools/grpc_tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/frequenz/repo/config/setuptools/grpc_tools.py b/src/frequenz/repo/config/setuptools/grpc_tools.py index d6917aba..d0da3362 100644 --- a/src/frequenz/repo/config/setuptools/grpc_tools.py +++ b/src/frequenz/repo/config/setuptools/grpc_tools.py @@ -84,7 +84,9 @@ def run(self) -> None: include_paths: Iterable[str] match self.include_paths: case str() as str_paths: - include_paths = str_paths.split(",") + # If it comes as a comma-separated string, split it into a list, + # stripping whitespace and ignoring empty strings. + include_paths = filter(len, map(str.strip, str_paths.split(","))) case Iterable() as paths_it: include_paths = paths_it case unexpected: From 735bd98de18e26da87b239fd62e24a41c843daf4 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 16 Jun 2025 12:14:39 +0200 Subject: [PATCH 4/8] Add release notes Signed-off-by: Leandro Lucarella --- RELEASE_NOTES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index dda1c7e6..faeb7913 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -31,6 +31,10 @@ But you might still need to adapt your code: ## Bug Fixes - Fixed some typos in the docs. +- `setuptools.grpc_tools`: Fix wrong passing of include paths when passed via: + + * Command-line: Now extra white-spaces and empty strings are removed, before they were passed to `protoc -I`. + * `pyproject.toml`: Now an empty array/list can be passed to override the default paths, before this resulted in an empty string being passed to `protoc -I`. ### Cookiecutter template From 64d8b8ce52646caaf80b51e0f75c5b49b3759a79 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Tue, 10 Jun 2025 15:11:34 +0200 Subject: [PATCH 5/8] Fix missing comparison for equal versions Signed-off-by: Leandro Lucarella --- RELEASE_NOTES.md | 1 + src/frequenz/repo/config/mkdocs/mike.py | 3 +++ tests/mkdocs/test_mike.py | 1 + 3 files changed, 5 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index faeb7913..8009b8c6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -31,6 +31,7 @@ But you might still need to adapt your code: ## Bug Fixes - Fixed some typos in the docs. +- Fixed wrong comparison for `mike` versions when versions were equal. - `setuptools.grpc_tools`: Fix wrong passing of include paths when passed via: * Command-line: Now extra white-spaces and empty strings are removed, before they were passed to `protoc -I`. diff --git a/src/frequenz/repo/config/mkdocs/mike.py b/src/frequenz/repo/config/mkdocs/mike.py index a5e9b6ba..633699ba 100644 --- a/src/frequenz/repo/config/mkdocs/mike.py +++ b/src/frequenz/repo/config/mkdocs/mike.py @@ -207,6 +207,9 @@ def compare_mike_version(version1: str, version2: str) -> int: if is_version_v2: # version1 is not a version return 1 + if version1 == version2: + return 0 + return -1 if version1 < version2 else 1 diff --git a/tests/mkdocs/test_mike.py b/tests/mkdocs/test_mike.py index f9f7d8f9..ad5936a2 100644 --- a/tests/mkdocs/test_mike.py +++ b/tests/mkdocs/test_mike.py @@ -266,6 +266,7 @@ def test_build_mike_version( ("v2.0-pre", "v1.0-pre", 1), ("v2.0", "v1.0-pre", 1), ("blah", "v1.0-dev", 1), + ("blah", "blah", 0), ("alpha", "beta", -1), ], ) From 15c1a4ee210e4be8cedc0b474dabd3788acaeeb3 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 16 Jun 2025 10:45:35 +0200 Subject: [PATCH 6/8] Fix semver version regex escaping of `.` This means that a version like v0x1e1 were accepted as valid semver versions. Now this version is not considered a semver version anymore. Signed-off-by: Leandro Lucarella --- RELEASE_NOTES.md | 1 + src/frequenz/repo/config/mkdocs/mike.py | 8 ++++---- tests/mkdocs/test_mike.py | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 8009b8c6..f8506903 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -32,6 +32,7 @@ But you might still need to adapt your code: - Fixed some typos in the docs. - Fixed wrong comparison for `mike` versions when versions were equal. +- Fixed version regex escaping of `.`. This means that a version like v0x1e1 were accepted as valid semver versions. Now this version is not considered a semver version anymore. - `setuptools.grpc_tools`: Fix wrong passing of include paths when passed via: * Command-line: Now extra white-spaces and empty strings are removed, before they were passed to `protoc -I`. diff --git a/src/frequenz/repo/config/mkdocs/mike.py b/src/frequenz/repo/config/mkdocs/mike.py index 633699ba..a2ba2e22 100644 --- a/src/frequenz/repo/config/mkdocs/mike.py +++ b/src/frequenz/repo/config/mkdocs/mike.py @@ -136,10 +136,10 @@ def build_mike_version(repo_info: RepoVersionInfo) -> MikeVersionInfo: ) -_is_version_re = re.compile(r"^v(\d+).(\d+)(-dev|-pre)?$") -_stable_to_semver_re = re.compile(r"^v(\d+).(\d+)$") -_pre_to_semver_re = re.compile(r"^v(\d+).(\d+)-pre$") -_dev_to_semver_re = re.compile(r"^v(\d+).(\d+)-dev$") +_is_version_re = re.compile(r"^v(\d+)\.(\d+)(?:-dev|-pre)?$") +_stable_to_semver_re = re.compile(r"^v(\d+)\.(\d+)$") +_pre_to_semver_re = re.compile(r"^v(\d+)\.(\d+)-pre$") +_dev_to_semver_re = re.compile(r"^v(\d+)\.(\d+)-dev$") def _to_fake_sortable_semver(version: str) -> str: diff --git a/tests/mkdocs/test_mike.py b/tests/mkdocs/test_mike.py index ad5936a2..38b0714a 100644 --- a/tests/mkdocs/test_mike.py +++ b/tests/mkdocs/test_mike.py @@ -267,6 +267,7 @@ def test_build_mike_version( ("v2.0", "v1.0-pre", 1), ("blah", "v1.0-dev", 1), ("blah", "blah", 0), + ("v1x0-dev", "v1.0-dev", 1), ("alpha", "beta", -1), ], ) From 5fb428b05c588b2895fd00fd8fb49c36417ac252 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 16 Jun 2025 12:56:29 +0200 Subject: [PATCH 7/8] Prepare release notes for the v0.13.5 release Signed-off-by: Leandro Lucarella --- RELEASE_NOTES.md | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f8506903..d9f1944f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,33 +1,5 @@ # Frequenz Repository Configuration Release Notes -## Summary - - - -## Upgrading - - - -### Cookiecutter template - -All upgrading should be done via the migration script or regenerating the templates. - -```bash -curl -sSL https://raw.githubusercontent.com/frequenz-floss/frequenz-repo-config-python/v0.12/cookiecutter/migrate.py | python3 -``` - -But you might still need to adapt your code: - - - -## New Features - - - -### Cookiecutter template - - - ## Bug Fixes - Fixed some typos in the docs. @@ -37,7 +9,3 @@ But you might still need to adapt your code: * Command-line: Now extra white-spaces and empty strings are removed, before they were passed to `protoc -I`. * `pyproject.toml`: Now an empty array/list can be passed to override the default paths, before this resulted in an empty string being passed to `protoc -I`. - -### Cookiecutter template - - From cb985b606f594b133e90f9b227511074ff8acc7a Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 16 Jun 2025 14:49:38 +0200 Subject: [PATCH 8/8] Clear release notes Signed-off-by: Leandro Lucarella --- RELEASE_NOTES.md | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d9f1944f..b99e3a30 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,11 +1,37 @@ # Frequenz Repository Configuration Release Notes +## Summary + + + +## Upgrading + + + +### Cookiecutter template + +All upgrading should be done via the migration script or regenerating the templates. + +```bash +curl -sSL https://raw.githubusercontent.com/frequenz-floss/frequenz-repo-config-python/v0.12/cookiecutter/migrate.py | python3 +``` + +But you might still need to adapt your code: + + + +## New Features + + + +### Cookiecutter template + + + ## Bug Fixes -- Fixed some typos in the docs. -- Fixed wrong comparison for `mike` versions when versions were equal. -- Fixed version regex escaping of `.`. This means that a version like v0x1e1 were accepted as valid semver versions. Now this version is not considered a semver version anymore. -- `setuptools.grpc_tools`: Fix wrong passing of include paths when passed via: + + +### Cookiecutter template - * Command-line: Now extra white-spaces and empty strings are removed, before they were passed to `protoc -I`. - * `pyproject.toml`: Now an empty array/list can be passed to override the default paths, before this resulted in an empty string being passed to `protoc -I`. +