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/mkdocs/mike.py b/src/frequenz/repo/config/mkdocs/mike.py index a5e9b6ba..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: @@ -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/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`). diff --git a/src/frequenz/repo/config/setuptools/grpc_tools.py b/src/frequenz/repo/config/setuptools/grpc_tools.py index 9d0559eb..d0da3362 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,17 @@ 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: + # 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: + assert_never(unexpected) + proto_files = [ str(p) for p in _pathlib.Path(self.proto_path).rglob(self.proto_glob) ] diff --git a/tests/mkdocs/test_mike.py b/tests/mkdocs/test_mike.py index f9f7d8f9..38b0714a 100644 --- a/tests/mkdocs/test_mike.py +++ b/tests/mkdocs/test_mike.py @@ -266,6 +266,8 @@ 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), + ("v1x0-dev", "v1.0-dev", 1), ("alpha", "beta", -1), ], )