Skip to content

Commit 6f88044

Browse files
mikejhillCopilot
andcommitted
style: format CLI module and tests with ruff
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a48a3cd commit 6f88044

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

custom_components/rouvy/api_client/__main__.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,7 @@ async def _cmd_activities(client: RouvyAsyncApiClient, args: argparse.Namespace)
407407

408408

409409
async def _cmd_activity_stats(client: RouvyAsyncApiClient, args: argparse.Namespace) -> None:
410-
stats: list[WeeklyActivityStats] = await client.async_get_activity_stats(
411-
args.year, args.month
412-
)
410+
stats: list[WeeklyActivityStats] = await client.async_get_activity_stats(args.year, args.month)
413411

414412
if args.json_output:
415413
_json_out(_as_dict(stats))
@@ -609,10 +607,7 @@ async def _cmd_routes(client: RouvyAsyncApiClient, args: argparse.Namespace) ->
609607
for route in routes:
610608
dist_km = route.distance_m / 1000.0
611609
name = (route.name[:32] + "...") if len(route.name) > 35 else route.name
612-
print(
613-
f" {name:<35s} {dist_km:>9.1f}km {route.elevation_m:>9.0f}m "
614-
f"{route.country_code}"
615-
)
610+
print(f" {name:<35s} {dist_km:>9.1f}km {route.elevation_m:>9.0f}m {route.country_code}")
616611
print("=" * 70)
617612

618613

@@ -654,9 +649,7 @@ async def _cmd_zones(client: RouvyAsyncApiClient, args: argparse.Namespace) -> N
654649
# ---------------------------------------------------------------------------
655650

656651

657-
async def _cmd_register_challenge(
658-
client: RouvyAsyncApiClient, args: argparse.Namespace
659-
) -> None:
652+
async def _cmd_register_challenge(client: RouvyAsyncApiClient, args: argparse.Namespace) -> None:
660653
success: bool = await client.async_register_challenge(args.slug)
661654

662655
if args.json_output:
@@ -669,9 +662,7 @@ async def _cmd_register_challenge(
669662
print(f"✗ Failed to register for challenge: {args.slug}")
670663

671664

672-
async def _cmd_register_event(
673-
client: RouvyAsyncApiClient, args: argparse.Namespace
674-
) -> None:
665+
async def _cmd_register_event(client: RouvyAsyncApiClient, args: argparse.Namespace) -> None:
675666
success: bool = await client.async_register_event(args.event_id)
676667

677668
if args.json_output:
@@ -707,8 +698,7 @@ async def _cmd_set(client: RouvyAsyncApiClient, args: argparse.Namespace) -> Non
707698
continue
708699
label = _format_profile_field(field_name)
709700
is_updated = any(
710-
uk in field_name.lower() or field_name.lower() in uk.lower()
711-
for uk in update_keys
701+
uk in field_name.lower() or field_name.lower() in uk.lower() for uk in update_keys
712702
)
713703
marker = " ← UPDATED" if is_updated else ""
714704
print(f"{label:25s}: {value}{marker}")
@@ -820,9 +810,7 @@ async def _cmd_set_zones(client: RouvyAsyncApiClient, args: argparse.Namespace)
820810
print(f"✓ {args.zone_type} zones updated to {zone_values}")
821811

822812

823-
async def _cmd_unregister_event(
824-
client: RouvyAsyncApiClient, args: argparse.Namespace
825-
) -> None:
813+
async def _cmd_unregister_event(client: RouvyAsyncApiClient, args: argparse.Namespace) -> None:
826814
success: bool = await client.async_unregister_event(args.event_id)
827815

828816
if args.json_output:

tests/test_cli.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ def test_skips_none_fields(self, capsys: pytest.CaptureFixture[str]) -> None:
360360

361361
client = AsyncMock()
362362
client.async_get_user_profile.return_value = _mock_profile(
363-
gender=None, birth_date=None, country=None,
363+
gender=None,
364+
birth_date=None,
365+
country=None,
364366
)
365367
_run(_cmd_profile(client, _mock_args()))
366368
output = capsys.readouterr().out
@@ -713,8 +715,12 @@ def test_updates_username(self, capsys: pytest.CaptureFixture[str]) -> None:
713715

714716
client = AsyncMock()
715717
args = _mock_args(
716-
username="NewName", first_name=None, last_name=None,
717-
team=None, country=None, privacy=None,
718+
username="NewName",
719+
first_name=None,
720+
last_name=None,
721+
team=None,
722+
country=None,
723+
privacy=None,
718724
)
719725
_run(_cmd_set_profile(client, args))
720726
output = capsys.readouterr().out
@@ -726,8 +732,12 @@ def test_updates_privacy(self, capsys: pytest.CaptureFixture[str]) -> None:
726732

727733
client = AsyncMock()
728734
args = _mock_args(
729-
username=None, first_name=None, last_name=None,
730-
team=None, country=None, privacy="PRIVATE",
735+
username=None,
736+
first_name=None,
737+
last_name=None,
738+
team=None,
739+
country=None,
740+
privacy="PRIVATE",
731741
)
732742
_run(_cmd_set_profile(client, args))
733743
client.async_update_user_social.assert_called_once_with("PRIVATE")
@@ -737,8 +747,12 @@ def test_raises_when_no_fields(self) -> None:
737747

738748
client = AsyncMock()
739749
args = _mock_args(
740-
username=None, first_name=None, last_name=None,
741-
team=None, country=None, privacy=None,
750+
username=None,
751+
first_name=None,
752+
last_name=None,
753+
team=None,
754+
country=None,
755+
privacy=None,
742756
)
743757
with pytest.raises(ValueError, match="No profile fields"):
744758
_run(_cmd_set_profile(client, args))
@@ -914,7 +928,8 @@ def test_main_value_error_exits_1(self) -> None:
914928
assert exc_info.value.code == 1
915929

916930
def test_main_json_error_on_exception(
917-
self, capsys: pytest.CaptureFixture[str],
931+
self,
932+
capsys: pytest.CaptureFixture[str],
918933
) -> None:
919934
from custom_components.rouvy.api_client.__main__ import main
920935

0 commit comments

Comments
 (0)