ruff formatting

This commit is contained in:
John Lancaster
2024-04-02 22:32:59 -05:00
parent e421046a04
commit 02726b0766
2 changed files with 7 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ from typing import Annotated, Dict, List, Optional, Self
import yaml import yaml
from astral import SunDirection from astral import SunDirection
from pydantic import BaseModel, BeforeValidator, Field, conint, root_validator from pydantic import BaseModel, BeforeValidator, Field, root_validator
from pydantic_core import PydanticCustomError from pydantic_core import PydanticCustomError
from rich.console import Console, ConsoleOptions, RenderResult from rich.console import Console, ConsoleOptions, RenderResult
from rich.table import Column, Table from rich.table import Column, Table
@@ -22,7 +22,9 @@ def str_to_direction(input_str: str) -> SunDirection:
try: try:
return getattr(SunDirection, input_str.upper()) return getattr(SunDirection, input_str.upper())
except AttributeError: except AttributeError:
raise PydanticCustomError('invalid_dir', 'Invalid sun direction: {dir}', dict(dir=input_str)) raise PydanticCustomError(
'invalid_dir', 'Invalid sun direction: {dir}', dict(dir=input_str)
)
OffDuration = Annotated[timedelta, BeforeValidator(str_to_timedelta)] OffDuration = Annotated[timedelta, BeforeValidator(str_to_timedelta)]
@@ -37,6 +39,7 @@ class State(BaseModel):
class ApplyKwargs(BaseModel): class ApplyKwargs(BaseModel):
"""Arguments to call with the 'scene/apply' service""" """Arguments to call with the 'scene/apply' service"""
entities: Dict[str, State] entities: Dict[str, State]
transition: Optional[int] = None transition: Optional[int] = None
@@ -73,7 +76,7 @@ class RoomControllerConfig(BaseModel):
for appname, app_cfg in yaml.load(f, Loader=yaml.SafeLoader).items(): for appname, app_cfg in yaml.load(f, Loader=yaml.SafeLoader).items():
if app_cfg['class'] == 'RoomController': if app_cfg['class'] == 'RoomController':
return cls.model_validate(app_cfg) return cls.model_validate(app_cfg)
def __rich_console__(self, console: Console, options: ConsoleOptions) -> RenderResult: def __rich_console__(self, console: Console, options: ConsoleOptions) -> RenderResult:
table = Table( table = Table(
Column('Time', width=15), Column('Time', width=15),

View File

@@ -4,7 +4,7 @@ from typing import Literal, Optional
from appdaemon.entity import Entity from appdaemon.entity import Entity
from appdaemon.plugins.hass.hassapi import Hass from appdaemon.plugins.hass.hassapi import Hass
from console import console, setup_component_logging from console import setup_component_logging
from pydantic import BaseModel, TypeAdapter from pydantic import BaseModel, TypeAdapter
from room_control import RoomController from room_control import RoomController