Skip to content

Commit 8af75ac

Browse files
committed
fix regex in _parse_additional_config()
1 parent d4f3954 commit 8af75ac

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

can/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __call__(
145145

146146
def _parse_additional_config(unknown_args: Sequence[str]) -> TAdditionalCliArgs:
147147
for arg in unknown_args:
148-
if not re.match(r"^--[a-zA-Z\-]*?=\S*?$", arg):
148+
if not re.match(r"^--[a-zA-Z][a-zA-Z0-9\-]*=\S*?$", arg):
149149
raise ValueError(f"Parsing argument {arg} failed")
150150

151151
def _split_arg(_arg: str) -> Tuple[str, str]:

test/test_logger.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def test_parse_additional_config(self):
146146
"--receive-own-messages=True",
147147
"--false-boolean=False",
148148
"--offset=1.5",
149+
"--tseg1-abr=127",
149150
]
150151
parsed_args = can.logger._parse_additional_config(unknown_args)
151152

@@ -170,6 +171,9 @@ def test_parse_additional_config(self):
170171
assert "offset" in parsed_args
171172
assert parsed_args["offset"] == 1.5
172173

174+
assert "tseg1_abr" in parsed_args
175+
assert parsed_args["tseg1_abr"] == 127
176+
173177
with pytest.raises(ValueError):
174178
can.logger._parse_additional_config(["--wrong-format"])
175179

0 commit comments

Comments
 (0)