Skip to content

Commit

Permalink
Adjust ruff target-version to 3.9 (#1420)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Jan 6, 2025
1 parent bb2b299 commit 13ae69d
Show file tree
Hide file tree
Showing 27 changed files with 127 additions and 164 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ warn_unused_ignores = true

[tool.ruff]
line-length = 88
target-version = "py38"
target-version = "py39"

[tool.ruff.lint]
ignore = [
Expand Down
23 changes: 11 additions & 12 deletions src/renault_api/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from datetime import datetime
from io import TextIOWrapper
from typing import Any
from typing import Dict
from typing import Optional

import aiohttp
Expand Down Expand Up @@ -109,7 +108,7 @@ def main(
@click.pass_obj
@helpers.coro_with_websession
async def accounts(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand All @@ -123,7 +122,7 @@ async def accounts(
@click.pass_obj
@helpers.coro_with_websession
async def login(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
user: str,
password: str,
Expand All @@ -148,7 +147,7 @@ def reset() -> None:
@click.pass_obj
@helpers.coro_with_websession
async def set(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
locale: Optional[str] = None,
account: Optional[str] = None,
Expand All @@ -161,7 +160,7 @@ async def set(

@main.command()
@click.pass_obj
def settings(ctx_data: Dict[str, Any]) -> None:
def settings(ctx_data: dict[str, Any]) -> None:
"""Display the current configuration keys."""
renault_settings.display_settings(ctx_data)

Expand All @@ -170,7 +169,7 @@ def settings(ctx_data: Dict[str, Any]) -> None:
@click.pass_obj
@helpers.coro_with_websession
async def status(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand All @@ -182,7 +181,7 @@ async def status(
@click.pass_obj
@helpers.coro_with_websession
async def vehicles(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand All @@ -194,7 +193,7 @@ async def vehicles(
@click.pass_obj
@helpers.coro_with_websession
async def vehicle(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand All @@ -206,7 +205,7 @@ async def vehicle(
@click.pass_obj
@helpers.coro_with_websession
async def contracts(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand All @@ -225,7 +224,7 @@ def http() -> None:
@click.pass_obj
@helpers.coro_with_websession
async def http_get(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
endpoint: str,
websession: aiohttp.ClientSession,
Expand All @@ -240,7 +239,7 @@ async def http_get(
@click.pass_obj
@helpers.coro_with_websession
async def http_post_file(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
endpoint: str,
json_body: TextIOWrapper,
Expand All @@ -258,7 +257,7 @@ async def http_post_file(
@click.pass_obj
@helpers.coro_with_websession
async def http_post(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
endpoint: str,
json_body: str,
Expand Down
7 changes: 3 additions & 4 deletions src/renault_api/cli/charge/control.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""CLI function for a vehicle."""

from typing import Any
from typing import Dict
from typing import Optional

import aiohttp
Expand All @@ -19,7 +18,7 @@
@click.pass_obj
@helpers.coro_with_websession
async def mode(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
set: Optional[str] = None,
websession: aiohttp.ClientSession,
Expand All @@ -40,7 +39,7 @@ async def mode(
@click.pass_obj
@helpers.coro_with_websession
async def start(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand All @@ -56,7 +55,7 @@ async def start(
@click.pass_obj
@helpers.coro_with_websession
async def stop(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand Down
16 changes: 7 additions & 9 deletions src/renault_api/cli/charge/history.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""CLI function for a vehicle."""

from typing import Any
from typing import Dict
from typing import List
from typing import Optional

import aiohttp
Expand All @@ -19,7 +17,7 @@
@click.pass_obj
@helpers.coro_with_websession
async def sessions(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
start: str,
end: str,
Expand All @@ -33,7 +31,7 @@ async def sessions(
)
details = await vehicle.get_details()
response = await vehicle.get_charges(start=parsed_start, end=parsed_end)
charges: List[Dict[str, Any]] = response.raw_data["charges"]
charges: list[dict[str, Any]] = response.raw_data["charges"]
if not charges: # pragma: no cover
click.echo("No data available.")
return
Expand All @@ -58,8 +56,8 @@ async def sessions(


def _format_charges_item(
item: Dict[str, Any], details: KamereonVehicleDetails
) -> List[str]:
item: dict[str, Any], details: KamereonVehicleDetails
) -> list[str]:
duration_unit = (
"minutes"
if details.reports_charge_session_durations_in_minutes()
Expand All @@ -84,7 +82,7 @@ def _format_charges_item(
@click.pass_obj
@helpers.coro_with_websession
async def history(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
start: str,
end: str,
Expand All @@ -101,7 +99,7 @@ async def history(
response = await vehicle.get_charge_history(
start=parsed_start, end=parsed_end, period=period
)
charge_summaries: List[Dict[str, Any]] = response.raw_data["chargeSummaries"]
charge_summaries: list[dict[str, Any]] = response.raw_data["chargeSummaries"]
if not charge_summaries: # pragma: no cover
click.echo("No data available.")
return
Expand All @@ -120,7 +118,7 @@ async def history(
)


def _format_charge_history_item(item: Dict[str, Any], period: str) -> List[str]:
def _format_charge_history_item(item: dict[str, Any], period: str) -> list[str]:
return [
helpers.get_display_value(item.get(period)),
helpers.get_display_value(item.get("totalChargesNumber")),
Expand Down
19 changes: 8 additions & 11 deletions src/renault_api/cli/charge/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import re
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from typing import Tuple

import aiohttp
import click
Expand Down Expand Up @@ -40,7 +37,7 @@ def schedule() -> None:
@click.pass_obj
@helpers.coro_with_websession
async def show(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand Down Expand Up @@ -75,7 +72,7 @@ async def show(
)


def _format_charge_schedule(schedule: ChargeSchedule, key: str) -> List[str]:
def _format_charge_schedule(schedule: ChargeSchedule, key: str) -> list[str]:
details: Optional[ChargeDaySchedule] = getattr(schedule, key)
if not details: # pragma: no cover
return [key.capitalize(), "-", "-", "-"]
Expand All @@ -88,10 +85,10 @@ def _format_charge_schedule(schedule: ChargeSchedule, key: str) -> List[str]:


async def _get_schedule(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
websession: aiohttp.ClientSession,
id: int,
) -> Tuple[RenaultVehicle, List[ChargeSchedule], ChargeSchedule]:
) -> tuple[RenaultVehicle, list[ChargeSchedule], ChargeSchedule]:
"""Get the given schedules activated-flag to given state."""
vehicle = await renault_vehicle.get_vehicle(
websession=websession, ctx_data=ctx_data
Expand Down Expand Up @@ -119,7 +116,7 @@ async def _get_schedule(
@click.pass_obj
@helpers.coro_with_websession
async def set(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
id: int,
websession: aiohttp.ClientSession,
Expand All @@ -141,7 +138,7 @@ async def set(
@click.pass_obj
@helpers.coro_with_websession
async def activate(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
id: int,
websession: aiohttp.ClientSession,
Expand All @@ -162,7 +159,7 @@ async def activate(
@click.pass_obj
@helpers.coro_with_websession
async def deactivate(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
id: int,
websession: aiohttp.ClientSession,
Expand Down Expand Up @@ -200,7 +197,7 @@ def update_settings(
)


def _parse_day_schedule(raw: str) -> Tuple[str, int]:
def _parse_day_schedule(raw: str) -> tuple[str, int]:
match = _DAY_SCHEDULE_REGEX.match(raw)
if not match: # pragma: no cover
raise ValueError(
Expand Down
3 changes: 1 addition & 2 deletions src/renault_api/cli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import Any
from typing import Callable
from typing import Optional
from typing import Tuple

import aiohttp
import click
Expand Down Expand Up @@ -137,7 +136,7 @@ def eof_received(orig_eof_received): # type: ignore
return all_is_lost


def parse_dates(start: str, end: str) -> Tuple[datetime, datetime]:
def parse_dates(start: str, end: str) -> tuple[datetime, datetime]:
"""Convert start/end string arguments into datetime arguments."""
parsed_start = dateparser.parse(start)
parsed_end = dateparser.parse(end)
Expand Down
5 changes: 2 additions & 3 deletions src/renault_api/cli/hvac/control.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""CLI function for a vehicle."""

from typing import Any
from typing import Dict
from typing import Optional

import aiohttp
Expand All @@ -26,7 +25,7 @@
@click.pass_obj
@helpers.coro_with_websession
async def start(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
temperature: int,
at: Optional[str],
Expand All @@ -48,7 +47,7 @@ async def start(
@click.pass_obj
@helpers.coro_with_websession
async def cancel(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
websession: aiohttp.ClientSession,
) -> None:
Expand Down
5 changes: 2 additions & 3 deletions src/renault_api/cli/hvac/history.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""CLI function for a vehicle."""

from typing import Any
from typing import Dict
from typing import Optional

import aiohttp
Expand All @@ -16,7 +15,7 @@
@click.pass_obj
@helpers.coro_with_websession
async def history(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
start: str,
end: str,
Expand All @@ -41,7 +40,7 @@ async def history(
@click.pass_obj
@helpers.coro_with_websession
async def sessions(
ctx_data: Dict[str, Any],
ctx_data: dict[str, Any],
*,
start: str,
end: str,
Expand Down
Loading

0 comments on commit 13ae69d

Please sign in to comment.