Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cyr-ius committed Nov 18, 2023
1 parent 43b9e01 commit 30ffbb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions custom_components/truenas/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import logging
from typing import Any

import voluptuous as vol
from truenaspy import (
Expand Down
12 changes: 7 additions & 5 deletions custom_components/truenas/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from __future__ import annotations

from dataclasses import dataclass, field
from datetime import datetime as dt
from datetime import date, datetime
from decimal import Decimal
from logging import getLogger
from typing import Any, Final, Mapping

Expand All @@ -23,6 +24,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType

from .const import (
DOMAIN,
Expand Down Expand Up @@ -307,7 +309,7 @@ async def async_setup_entry(

class Sensor(TruenasEntity, SensorEntity):
@property
def native_value(self) -> StateType | datetime | Decimal:
def native_value(self) -> StateType | date | datetime | Decimal:
"""Return the value reported by the sensor."""
return self.datas.get(self.entity_description.attr)

Expand All @@ -316,9 +318,9 @@ class UptimeSensor(Sensor):
"""Define an Truenas Uptime sensor."""

@property
def native_value(self) -> StateType | datetime | Decimal:
def native_value(self) -> StateType | date | datetime | Decimal:
"""Return the value reported by the sensor."""
return dt.strptime(
return datetime.strptime(
self.datas.get(self.entity_description.attr), "%Y-%m-%dT%H:%M:%S%z"
)

Expand All @@ -336,7 +338,7 @@ class DatasetSensor(Sensor):

async def snapshot(self) -> None:
"""Create dataset snapshot."""
ts = dt.now().isoformat(sep="_", timespec="microseconds")
ts = datetime.now().isoformat(sep="_", timespec="microseconds")
await self.coordinator.api.query(
"zfs/snapshot",
method="post",
Expand Down

0 comments on commit 30ffbb5

Please sign in to comment.