diff --git a/examples/example.py b/examples/example.py index 6495c610..f84688b0 100644 --- a/examples/example.py +++ b/examples/example.py @@ -39,7 +39,7 @@ async def main() -> None: ), Chart(data=[1, 2, 3, 4, 5, 4, 3, 2, 1]), ], - sound=Sound(id=NotificationSound.WIN), + sound=Sound(sound=NotificationSound.WIN), ), ) diff --git a/poetry.lock b/poetry.lock index 09cc063e..f20d49ac 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand. [[package]] name = "aiohttp" diff --git a/pyproject.toml b/pyproject.toml index 723de96f..5c9a20ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,6 +90,7 @@ profile = "black" # results. platform = "linux" python_version = 3.9 +plugins = ["pydantic.mypy"] # flake8-mypy expects the two following for sensible formatting show_column_numbers = true diff --git a/src/demetriek/models.py b/src/demetriek/models.py index d1ec75ab..940b779d 100644 --- a/src/demetriek/models.py +++ b/src/demetriek/models.py @@ -26,16 +26,16 @@ class Range(BaseModel): """Object holding an integer range.""" - range_min: int = Field(..., alias="min") - range_max: int = Field(..., alias="max") + range_min: int = Field(alias="min") + range_max: int = Field(alias="max") class Audio(BaseModel): """Object holding the audio state of an LaMetric device.""" volume: int - volume_range: Optional[Range] - volume_limit: Optional[Range] + volume_range: Optional[Range] = None + volume_limit: Optional[Range] = None class Bluetooth(BaseModel): @@ -56,7 +56,7 @@ class Display(BaseModel): brightness_mode: BrightnessMode width: int height: int - display_type: DisplayType = Field(None, alias="type") + display_type: Optional[DisplayType] = Field(default=None, alias="type") class Wifi(BaseModel): @@ -76,7 +76,7 @@ class Wifi(BaseModel): class Device(BaseModel): """Object holding the state of an LaMetric device.""" - device_id: str = Field(..., alias="id") + device_id: str = Field(alias="id") name: str serial_number: str os_version: AwesomeVersion @@ -91,7 +91,7 @@ class Device(BaseModel): class Chart(BaseModel): """Object holding the chart frame of an LaMetric notification.""" - data: list[int] = Field(..., alias="chartData") + data: list[int] = Field(alias="chartData") class Config: """Chart model configuration.""" @@ -119,7 +119,7 @@ class Goal(BaseModel): """Object holding the goal frame of an LaMetric notification.""" icon: Optional[Union[int, str]] = None - data: GoalData = Field(..., alias="goalData") + data: GoalData = Field(alias="goalData") class Config: """Goal model configuration.""" @@ -130,8 +130,8 @@ class Config: class Sound(BaseModel): """Object holding the notification sound state of an LaMetric device.""" - category: Optional[NotificationSoundCategory] - sound: Union[AlarmSound, NotificationSound] = Field(..., alias="id") + category: Optional[NotificationSoundCategory] = None + sound: Union[AlarmSound, NotificationSound] = Field(alias="id") repeat: int = 1 @root_validator @@ -179,8 +179,8 @@ class Notification(BaseModel): icon_type: Optional[NotificationIconType] = None life_time: Optional[float] = None priority: Optional[NotificationPriority] = None - notification_id: Optional[int] = Field(None, alias="id") - notification_type: Optional[NotificationType] = Field(None, alias="type") + notification_id: Optional[int] = Field(default=None, alias="id") + notification_type: Optional[NotificationType] = Field(default=None, alias="type") class User(BaseModel): @@ -191,19 +191,19 @@ class User(BaseModel): name: str private_apps_count: int private_device_count: int - user_id: int = Field(..., alias="id") + user_id: int = Field(alias="id") class CloudDevice(BaseModel): """Object holding the state of an LaMetric device from the Cloud.""" - device_id: int = Field(..., alias="id") + device_id: int = Field(alias="id") name: str state: DeviceState serial_number: str api_key: str - ip: IPv4Address = Field(..., alias="ipv4_internal") + ip: IPv4Address = Field(alias="ipv4_internal") mac: str - ssid: str = Field(..., alias="wifi_ssid") + ssid: str = Field(alias="wifi_ssid") created_at: datetime updated_at: datetime