Skip to content

Commit 996e7a5

Browse files
committed
drop 'full' argument from version()
1 parent e1c5389 commit 996e7a5

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- dropped 'verbose' argument from list_boards()
13+
- dropped 'full' argument from version()
1314

1415
## [0.1.1] - 2024-07-11
1516

tests/test_tycmd.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66

77
import tycmd
8-
import re
98

109

1110
BLINK_HEX = Path(__file__).parent.joinpath("blink.hex").resolve()
@@ -48,12 +47,7 @@ def test_list_boards(mock_check_output):
4847

4948

5049
def test_version():
51-
output = tycmd.version(full=True)
52-
assert isinstance(output, str)
53-
match = re.search(r"^.+(\d+\.\d+\.\d+)", output)
54-
assert match is not None
55-
assert match.groups()[0] == tycmd._TYCMD_VERSION
56-
assert tycmd.version(full=False) == tycmd._TYCMD_VERSION
50+
assert tycmd.version() == tycmd._TYCMD_VERSION
5751

5852

5953
def test__parse_firmware_file():

tycmd.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,25 @@ def list_boards() -> list[dict]:
4949
return json.loads(return_string)
5050

5151

52-
def version(full: bool = False) -> str:
52+
def version() -> str:
5353
"""
54-
Return version information from tycmd.
55-
56-
Parameters
57-
----------
58-
full : bool, optional
59-
If True, return the full version string as returned by the tycmd binary. If
60-
False, return only the version number. Default is False.
54+
Return version information from tycmd binary.
6155
6256
Returns
6357
-------
6458
str
6559
The version of tycmd.
60+
61+
Raises
62+
------
63+
RuntimeError
64+
If the version string could not be determined.
6665
"""
6766
output = _call_tycmd(["--version"])
68-
if full:
69-
return output.strip()
67+
match = re.search(r"\d+\.\d+\.\d+", output)
68+
if match is None:
69+
raise RuntimeError("Could not determine tycmd version")
7070
else:
71-
if (match := re.search(r"\d+\.\d+\.\d+", output)) is None:
72-
return ""
7371
return match.group()
7472

7573

0 commit comments

Comments
 (0)