Skip to content

Commit ef1733a

Browse files
committed
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 <luca-frequenz@llucax.com>
1 parent 6aff099 commit ef1733a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/frequenz/repo/config/setuptools/grpc_tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def run(self) -> None:
8484
include_paths: Iterable[str]
8585
match self.include_paths:
8686
case str() as str_paths:
87-
include_paths = str_paths.split(",")
87+
# If it comes as a comma-separated string, split it into a list,
88+
# stripping whitespace and ignoring empty strings.
89+
include_paths = filter(len, map(str.strip, str_paths.split(",")))
8890
case Iterable() as paths_it:
8991
include_paths = paths_it
9092
case unexpected:

0 commit comments

Comments
 (0)