Enable Ruff PGH rules (#115091)
parent
85b453b86c
commit
f8b6629b26
|
@ -634,7 +634,7 @@ select = [
|
||||||
"N805", # First argument of a method should be named self
|
"N805", # First argument of a method should be named self
|
||||||
"N815", # Variable {name} in class scope should not be mixedCase
|
"N815", # Variable {name} in class scope should not be mixedCase
|
||||||
"PERF", # Perflint
|
"PERF", # Perflint
|
||||||
"PGH004", # Use specific rule codes when using noqa
|
"PGH", # pygrep-hooks
|
||||||
"PIE", # flake8-pie
|
"PIE", # flake8-pie
|
||||||
"PL", # pylint
|
"PL", # pylint
|
||||||
"PT", # flake8-pytest-style
|
"PT", # flake8-pytest-style
|
||||||
|
|
|
@ -162,7 +162,7 @@ class KNXTestKit:
|
||||||
|
|
||||||
if payload is not None:
|
if payload is not None:
|
||||||
assert (
|
assert (
|
||||||
telegram.payload.value.value == payload # type: ignore
|
telegram.payload.value.value == payload # type: ignore[attr-defined]
|
||||||
), f"Payload mismatch in {telegram} - Expected: {payload}"
|
), f"Payload mismatch in {telegram} - Expected: {payload}"
|
||||||
|
|
||||||
async def assert_read(self, group_address: str) -> None:
|
async def assert_read(self, group_address: str) -> None:
|
||||||
|
|
|
@ -97,7 +97,7 @@ async def test_plex_update(
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
assert apply_mock.called_once
|
assert apply_mock.call_count == 1
|
||||||
|
|
||||||
# Failed upgrade request
|
# Failed upgrade request
|
||||||
requests_mock.put("/updater/apply", status_code=500)
|
requests_mock.put("/updater/apply", status_code=500)
|
||||||
|
|
|
@ -30,7 +30,7 @@ Base = declarative_base()
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Events(Base): # type: ignore
|
class Events(Base): # type: ignore[valid-type,misc]
|
||||||
"""Event history data."""
|
"""Event history data."""
|
||||||
|
|
||||||
__tablename__ = "events"
|
__tablename__ = "events"
|
||||||
|
@ -66,7 +66,7 @@ class Events(Base): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class States(Base): # type: ignore
|
class States(Base): # type: ignore[valid-type,misc]
|
||||||
"""State change history."""
|
"""State change history."""
|
||||||
|
|
||||||
__tablename__ = "states"
|
__tablename__ = "states"
|
||||||
|
@ -125,7 +125,7 @@ class States(Base): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class RecorderRuns(Base): # type: ignore
|
class RecorderRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of recorder run."""
|
"""Representation of recorder run."""
|
||||||
|
|
||||||
__tablename__ = "recorder_runs"
|
__tablename__ = "recorder_runs"
|
||||||
|
|
|
@ -66,7 +66,7 @@ DATETIME_TYPE = DateTime(timezone=True).with_variant(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Events(Base): # type: ignore
|
class Events(Base): # type: ignore[valid-type,misc]
|
||||||
"""Event history data."""
|
"""Event history data."""
|
||||||
|
|
||||||
__table_args__ = {
|
__table_args__ = {
|
||||||
|
@ -84,7 +84,7 @@ class Events(Base): # type: ignore
|
||||||
context_user_id = Column(String(MAX_LENGTH_EVENT_CONTEXT_ID), index=True)
|
context_user_id = Column(String(MAX_LENGTH_EVENT_CONTEXT_ID), index=True)
|
||||||
context_parent_id = Column(String(MAX_LENGTH_EVENT_CONTEXT_ID), index=True)
|
context_parent_id = Column(String(MAX_LENGTH_EVENT_CONTEXT_ID), index=True)
|
||||||
|
|
||||||
__table_args__ = ( # noqa: PIE794
|
__table_args__ = ( # type: ignore[assignment] # noqa: PIE794
|
||||||
# Used for fetching events at a specific time
|
# Used for fetching events at a specific time
|
||||||
# see logbook
|
# see logbook
|
||||||
Index("ix_events_event_type_time_fired", "event_type", "time_fired"),
|
Index("ix_events_event_type_time_fired", "event_type", "time_fired"),
|
||||||
|
@ -133,7 +133,7 @@ class Events(Base): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class States(Base): # type: ignore
|
class States(Base): # type: ignore[valid-type,misc]
|
||||||
"""State change history."""
|
"""State change history."""
|
||||||
|
|
||||||
__table_args__ = {
|
__table_args__ = {
|
||||||
|
@ -156,7 +156,7 @@ class States(Base): # type: ignore
|
||||||
event = relationship("Events", uselist=False)
|
event = relationship("Events", uselist=False)
|
||||||
old_state = relationship("States", remote_side=[state_id])
|
old_state = relationship("States", remote_side=[state_id])
|
||||||
|
|
||||||
__table_args__ = ( # noqa: PIE794
|
__table_args__ = ( # type: ignore[assignment] # noqa: PIE794
|
||||||
# Used for fetching the state of entities at a specific time
|
# Used for fetching the state of entities at a specific time
|
||||||
# (get_states in history.py)
|
# (get_states in history.py)
|
||||||
Index("ix_states_entity_id_last_updated", "entity_id", "last_updated"),
|
Index("ix_states_entity_id_last_updated", "entity_id", "last_updated"),
|
||||||
|
@ -217,7 +217,7 @@ class States(Base): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Statistics(Base): # type: ignore
|
class Statistics(Base): # type: ignore[valid-type,misc]
|
||||||
"""Statistics."""
|
"""Statistics."""
|
||||||
|
|
||||||
__table_args__ = {
|
__table_args__ = {
|
||||||
|
@ -237,7 +237,7 @@ class Statistics(Base): # type: ignore
|
||||||
state = Column(Float())
|
state = Column(Float())
|
||||||
sum = Column(Float())
|
sum = Column(Float())
|
||||||
|
|
||||||
__table_args__ = ( # noqa: PIE794
|
__table_args__ = ( # type: ignore[assignment] # noqa: PIE794
|
||||||
# Used for fetching statistics for a certain entity at a specific time
|
# Used for fetching statistics for a certain entity at a specific time
|
||||||
Index("ix_statistics_statistic_id_start", "statistic_id", "start"),
|
Index("ix_statistics_statistic_id_start", "statistic_id", "start"),
|
||||||
)
|
)
|
||||||
|
@ -253,7 +253,7 @@ class Statistics(Base): # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RecorderRuns(Base): # type: ignore
|
class RecorderRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of recorder run."""
|
"""Representation of recorder run."""
|
||||||
|
|
||||||
__tablename__ = TABLE_RECORDER_RUNS
|
__tablename__ = TABLE_RECORDER_RUNS
|
||||||
|
@ -304,7 +304,7 @@ class RecorderRuns(Base): # type: ignore
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class SchemaChanges(Base): # type: ignore
|
class SchemaChanges(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of schema version changes."""
|
"""Representation of schema version changes."""
|
||||||
|
|
||||||
__tablename__ = TABLE_SCHEMA_CHANGES
|
__tablename__ = TABLE_SCHEMA_CHANGES
|
||||||
|
@ -366,7 +366,7 @@ class LazyState(State):
|
||||||
self._last_updated = None
|
self._last_updated = None
|
||||||
self._context = None
|
self._context = None
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def attributes(self):
|
def attributes(self):
|
||||||
"""State attributes."""
|
"""State attributes."""
|
||||||
if not self._attributes:
|
if not self._attributes:
|
||||||
|
@ -383,7 +383,7 @@ class LazyState(State):
|
||||||
"""Set attributes."""
|
"""Set attributes."""
|
||||||
self._attributes = value
|
self._attributes = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def context(self):
|
def context(self):
|
||||||
"""State context."""
|
"""State context."""
|
||||||
if not self._context:
|
if not self._context:
|
||||||
|
@ -395,7 +395,7 @@ class LazyState(State):
|
||||||
"""Set context."""
|
"""Set context."""
|
||||||
self._context = value
|
self._context = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_changed(self):
|
def last_changed(self):
|
||||||
"""Last changed datetime."""
|
"""Last changed datetime."""
|
||||||
if not self._last_changed:
|
if not self._last_changed:
|
||||||
|
@ -407,7 +407,7 @@ class LazyState(State):
|
||||||
"""Set last changed datetime."""
|
"""Set last changed datetime."""
|
||||||
self._last_changed = value
|
self._last_changed = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_updated(self):
|
def last_updated(self):
|
||||||
"""Last updated datetime."""
|
"""Last updated datetime."""
|
||||||
if not self._last_updated:
|
if not self._last_updated:
|
||||||
|
|
|
@ -68,7 +68,7 @@ DATETIME_TYPE = DateTime(timezone=True).with_variant(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Events(Base): # type: ignore
|
class Events(Base): # type: ignore[valid-type,misc]
|
||||||
"""Event history data."""
|
"""Event history data."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -131,7 +131,7 @@ class Events(Base): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class States(Base): # type: ignore
|
class States(Base): # type: ignore[valid-type,misc]
|
||||||
"""State change history."""
|
"""State change history."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -211,7 +211,7 @@ class States(Base): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Statistics(Base): # type: ignore
|
class Statistics(Base): # type: ignore[valid-type,misc]
|
||||||
"""Statistics."""
|
"""Statistics."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -244,7 +244,7 @@ class Statistics(Base): # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StatisticsMeta(Base): # type: ignore
|
class StatisticsMeta(Base): # type: ignore[valid-type,misc]
|
||||||
"""Statistics meta data."""
|
"""Statistics meta data."""
|
||||||
|
|
||||||
__tablename__ = TABLE_STATISTICS_META
|
__tablename__ = TABLE_STATISTICS_META
|
||||||
|
@ -267,7 +267,7 @@ class StatisticsMeta(Base): # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RecorderRuns(Base): # type: ignore
|
class RecorderRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of recorder run."""
|
"""Representation of recorder run."""
|
||||||
|
|
||||||
__table_args__ = (Index("ix_recorder_runs_start_end", "start", "end"),)
|
__table_args__ = (Index("ix_recorder_runs_start_end", "start", "end"),)
|
||||||
|
@ -317,7 +317,7 @@ class RecorderRuns(Base): # type: ignore
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class SchemaChanges(Base): # type: ignore
|
class SchemaChanges(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of schema version changes."""
|
"""Representation of schema version changes."""
|
||||||
|
|
||||||
__tablename__ = TABLE_SCHEMA_CHANGES
|
__tablename__ = TABLE_SCHEMA_CHANGES
|
||||||
|
@ -379,7 +379,7 @@ class LazyState(State):
|
||||||
self._last_updated = None
|
self._last_updated = None
|
||||||
self._context = None
|
self._context = None
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def attributes(self):
|
def attributes(self):
|
||||||
"""State attributes."""
|
"""State attributes."""
|
||||||
if not self._attributes:
|
if not self._attributes:
|
||||||
|
@ -396,7 +396,7 @@ class LazyState(State):
|
||||||
"""Set attributes."""
|
"""Set attributes."""
|
||||||
self._attributes = value
|
self._attributes = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def context(self):
|
def context(self):
|
||||||
"""State context."""
|
"""State context."""
|
||||||
if not self._context:
|
if not self._context:
|
||||||
|
@ -408,7 +408,7 @@ class LazyState(State):
|
||||||
"""Set context."""
|
"""Set context."""
|
||||||
self._context = value
|
self._context = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_changed(self):
|
def last_changed(self):
|
||||||
"""Last changed datetime."""
|
"""Last changed datetime."""
|
||||||
if not self._last_changed:
|
if not self._last_changed:
|
||||||
|
@ -420,7 +420,7 @@ class LazyState(State):
|
||||||
"""Set last changed datetime."""
|
"""Set last changed datetime."""
|
||||||
self._last_changed = value
|
self._last_changed = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_updated(self):
|
def last_updated(self):
|
||||||
"""Last updated datetime."""
|
"""Last updated datetime."""
|
||||||
if not self._last_updated:
|
if not self._last_updated:
|
||||||
|
|
|
@ -84,7 +84,7 @@ DOUBLE_TYPE = (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Events(Base): # type: ignore
|
class Events(Base): # type: ignore[valid-type,misc]
|
||||||
"""Event history data."""
|
"""Event history data."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -148,7 +148,7 @@ class Events(Base): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class States(Base): # type: ignore
|
class States(Base): # type: ignore[valid-type,misc]
|
||||||
"""State change history."""
|
"""State change history."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -283,13 +283,13 @@ class StatisticsBase:
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_stats(cls, metadata_id: int, stats: StatisticData):
|
def from_stats(cls, metadata_id: int, stats: StatisticData):
|
||||||
"""Create object from a statistics."""
|
"""Create object from a statistics."""
|
||||||
return cls( # type: ignore
|
return cls( # type: ignore[call-arg,misc]
|
||||||
metadata_id=metadata_id,
|
metadata_id=metadata_id,
|
||||||
**stats,
|
**stats,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Statistics(Base, StatisticsBase): # type: ignore
|
class Statistics(Base, StatisticsBase): # type: ignore[valid-type,misc]
|
||||||
"""Long term statistics."""
|
"""Long term statistics."""
|
||||||
|
|
||||||
duration = timedelta(hours=1)
|
duration = timedelta(hours=1)
|
||||||
|
@ -301,7 +301,7 @@ class Statistics(Base, StatisticsBase): # type: ignore
|
||||||
__tablename__ = TABLE_STATISTICS
|
__tablename__ = TABLE_STATISTICS
|
||||||
|
|
||||||
|
|
||||||
class StatisticsShortTerm(Base, StatisticsBase): # type: ignore
|
class StatisticsShortTerm(Base, StatisticsBase): # type: ignore[valid-type,misc]
|
||||||
"""Short term statistics."""
|
"""Short term statistics."""
|
||||||
|
|
||||||
duration = timedelta(minutes=5)
|
duration = timedelta(minutes=5)
|
||||||
|
@ -322,7 +322,7 @@ class StatisticMetaData(TypedDict):
|
||||||
has_sum: bool
|
has_sum: bool
|
||||||
|
|
||||||
|
|
||||||
class StatisticsMeta(Base): # type: ignore
|
class StatisticsMeta(Base): # type: ignore[valid-type,misc]
|
||||||
"""Statistics meta data."""
|
"""Statistics meta data."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -354,7 +354,7 @@ class StatisticsMeta(Base): # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RecorderRuns(Base): # type: ignore
|
class RecorderRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of recorder run."""
|
"""Representation of recorder run."""
|
||||||
|
|
||||||
__table_args__ = (Index("ix_recorder_runs_start_end", "start", "end"),)
|
__table_args__ = (Index("ix_recorder_runs_start_end", "start", "end"),)
|
||||||
|
@ -404,7 +404,7 @@ class RecorderRuns(Base): # type: ignore
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class SchemaChanges(Base): # type: ignore
|
class SchemaChanges(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of schema version changes."""
|
"""Representation of schema version changes."""
|
||||||
|
|
||||||
__tablename__ = TABLE_SCHEMA_CHANGES
|
__tablename__ = TABLE_SCHEMA_CHANGES
|
||||||
|
@ -422,7 +422,7 @@ class SchemaChanges(Base): # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StatisticsRuns(Base): # type: ignore
|
class StatisticsRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of statistics run."""
|
"""Representation of statistics run."""
|
||||||
|
|
||||||
__tablename__ = TABLE_STATISTICS_RUNS
|
__tablename__ = TABLE_STATISTICS_RUNS
|
||||||
|
@ -498,7 +498,7 @@ class LazyState(State):
|
||||||
self._last_updated = None
|
self._last_updated = None
|
||||||
self._context = None
|
self._context = None
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def attributes(self):
|
def attributes(self):
|
||||||
"""State attributes."""
|
"""State attributes."""
|
||||||
if not self._attributes:
|
if not self._attributes:
|
||||||
|
@ -515,7 +515,7 @@ class LazyState(State):
|
||||||
"""Set attributes."""
|
"""Set attributes."""
|
||||||
self._attributes = value
|
self._attributes = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def context(self):
|
def context(self):
|
||||||
"""State context."""
|
"""State context."""
|
||||||
if not self._context:
|
if not self._context:
|
||||||
|
@ -527,7 +527,7 @@ class LazyState(State):
|
||||||
"""Set context."""
|
"""Set context."""
|
||||||
self._context = value
|
self._context = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_changed(self):
|
def last_changed(self):
|
||||||
"""Last changed datetime."""
|
"""Last changed datetime."""
|
||||||
if not self._last_changed:
|
if not self._last_changed:
|
||||||
|
@ -539,7 +539,7 @@ class LazyState(State):
|
||||||
"""Set last changed datetime."""
|
"""Set last changed datetime."""
|
||||||
self._last_changed = value
|
self._last_changed = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_updated(self):
|
def last_updated(self):
|
||||||
"""Last updated datetime."""
|
"""Last updated datetime."""
|
||||||
if not self._last_updated:
|
if not self._last_updated:
|
||||||
|
|
|
@ -83,7 +83,7 @@ DOUBLE_TYPE = (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Events(Base): # type: ignore
|
class Events(Base): # type: ignore[valid-type,misc]
|
||||||
"""Event history data."""
|
"""Event history data."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -147,7 +147,7 @@ class Events(Base): # type: ignore
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class States(Base): # type: ignore
|
class States(Base): # type: ignore[valid-type,misc]
|
||||||
"""State change history."""
|
"""State change history."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -282,13 +282,13 @@ class StatisticsBase:
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_stats(cls, metadata_id: int, stats: StatisticData):
|
def from_stats(cls, metadata_id: int, stats: StatisticData):
|
||||||
"""Create object from a statistics."""
|
"""Create object from a statistics."""
|
||||||
return cls( # type: ignore
|
return cls( # type: ignore[call-arg,misc]
|
||||||
metadata_id=metadata_id,
|
metadata_id=metadata_id,
|
||||||
**stats,
|
**stats,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Statistics(Base, StatisticsBase): # type: ignore
|
class Statistics(Base, StatisticsBase): # type: ignore[valid-type,misc]
|
||||||
"""Long term statistics."""
|
"""Long term statistics."""
|
||||||
|
|
||||||
duration = timedelta(hours=1)
|
duration = timedelta(hours=1)
|
||||||
|
@ -300,7 +300,7 @@ class Statistics(Base, StatisticsBase): # type: ignore
|
||||||
__tablename__ = TABLE_STATISTICS
|
__tablename__ = TABLE_STATISTICS
|
||||||
|
|
||||||
|
|
||||||
class StatisticsShortTerm(Base, StatisticsBase): # type: ignore
|
class StatisticsShortTerm(Base, StatisticsBase): # type: ignore[valid-type,misc]
|
||||||
"""Short term statistics."""
|
"""Short term statistics."""
|
||||||
|
|
||||||
duration = timedelta(minutes=5)
|
duration = timedelta(minutes=5)
|
||||||
|
@ -323,7 +323,7 @@ class StatisticMetaData(TypedDict):
|
||||||
unit_of_measurement: str | None
|
unit_of_measurement: str | None
|
||||||
|
|
||||||
|
|
||||||
class StatisticsMeta(Base): # type: ignore
|
class StatisticsMeta(Base): # type: ignore[valid-type,misc]
|
||||||
"""Statistics meta data."""
|
"""Statistics meta data."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -344,7 +344,7 @@ class StatisticsMeta(Base): # type: ignore
|
||||||
return StatisticsMeta(**meta)
|
return StatisticsMeta(**meta)
|
||||||
|
|
||||||
|
|
||||||
class RecorderRuns(Base): # type: ignore
|
class RecorderRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of recorder run."""
|
"""Representation of recorder run."""
|
||||||
|
|
||||||
__table_args__ = (Index("ix_recorder_runs_start_end", "start", "end"),)
|
__table_args__ = (Index("ix_recorder_runs_start_end", "start", "end"),)
|
||||||
|
@ -394,7 +394,7 @@ class RecorderRuns(Base): # type: ignore
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class SchemaChanges(Base): # type: ignore
|
class SchemaChanges(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of schema version changes."""
|
"""Representation of schema version changes."""
|
||||||
|
|
||||||
__tablename__ = TABLE_SCHEMA_CHANGES
|
__tablename__ = TABLE_SCHEMA_CHANGES
|
||||||
|
@ -412,7 +412,7 @@ class SchemaChanges(Base): # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StatisticsRuns(Base): # type: ignore
|
class StatisticsRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of statistics run."""
|
"""Representation of statistics run."""
|
||||||
|
|
||||||
__tablename__ = TABLE_STATISTICS_RUNS
|
__tablename__ = TABLE_STATISTICS_RUNS
|
||||||
|
@ -488,7 +488,7 @@ class LazyState(State):
|
||||||
self._last_updated = None
|
self._last_updated = None
|
||||||
self._context = None
|
self._context = None
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def attributes(self):
|
def attributes(self):
|
||||||
"""State attributes."""
|
"""State attributes."""
|
||||||
if not self._attributes:
|
if not self._attributes:
|
||||||
|
@ -505,7 +505,7 @@ class LazyState(State):
|
||||||
"""Set attributes."""
|
"""Set attributes."""
|
||||||
self._attributes = value
|
self._attributes = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def context(self):
|
def context(self):
|
||||||
"""State context."""
|
"""State context."""
|
||||||
if not self._context:
|
if not self._context:
|
||||||
|
@ -517,7 +517,7 @@ class LazyState(State):
|
||||||
"""Set context."""
|
"""Set context."""
|
||||||
self._context = value
|
self._context = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_changed(self):
|
def last_changed(self):
|
||||||
"""Last changed datetime."""
|
"""Last changed datetime."""
|
||||||
if not self._last_changed:
|
if not self._last_changed:
|
||||||
|
@ -529,7 +529,7 @@ class LazyState(State):
|
||||||
"""Set last changed datetime."""
|
"""Set last changed datetime."""
|
||||||
self._last_changed = value
|
self._last_changed = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_updated(self):
|
def last_updated(self):
|
||||||
"""Last updated datetime."""
|
"""Last updated datetime."""
|
||||||
if not self._last_updated:
|
if not self._last_updated:
|
||||||
|
|
|
@ -102,7 +102,7 @@ EVENTS_CONTEXT_ID_BIN_INDEX = "ix_events_context_id_bin"
|
||||||
STATES_CONTEXT_ID_BIN_INDEX = "ix_states_context_id_bin"
|
STATES_CONTEXT_ID_BIN_INDEX = "ix_states_context_id_bin"
|
||||||
|
|
||||||
|
|
||||||
class Events(Base): # type: ignore
|
class Events(Base): # type: ignore[valid-type,misc]
|
||||||
"""Event history data."""
|
"""Event history data."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -225,7 +225,7 @@ class EventTypes(Base): # type: ignore[misc,valid-type]
|
||||||
event_type = Column(String(MAX_LENGTH_EVENT_EVENT_TYPE))
|
event_type = Column(String(MAX_LENGTH_EVENT_EVENT_TYPE))
|
||||||
|
|
||||||
|
|
||||||
class States(Base): # type: ignore
|
class States(Base): # type: ignore[valid-type,misc]
|
||||||
"""State change history."""
|
"""State change history."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -406,13 +406,13 @@ class StatisticsBase:
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_stats(cls, metadata_id: int, stats: StatisticData):
|
def from_stats(cls, metadata_id: int, stats: StatisticData):
|
||||||
"""Create object from a statistics."""
|
"""Create object from a statistics."""
|
||||||
return cls( # type: ignore
|
return cls( # type: ignore[call-arg,misc]
|
||||||
metadata_id=metadata_id,
|
metadata_id=metadata_id,
|
||||||
**stats,
|
**stats,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Statistics(Base, StatisticsBase): # type: ignore
|
class Statistics(Base, StatisticsBase): # type: ignore[valid-type,misc]
|
||||||
"""Long term statistics."""
|
"""Long term statistics."""
|
||||||
|
|
||||||
duration = timedelta(hours=1)
|
duration = timedelta(hours=1)
|
||||||
|
@ -424,7 +424,7 @@ class Statistics(Base, StatisticsBase): # type: ignore
|
||||||
__tablename__ = TABLE_STATISTICS
|
__tablename__ = TABLE_STATISTICS
|
||||||
|
|
||||||
|
|
||||||
class StatisticsShortTerm(Base, StatisticsBase): # type: ignore
|
class StatisticsShortTerm(Base, StatisticsBase): # type: ignore[valid-type,misc]
|
||||||
"""Short term statistics."""
|
"""Short term statistics."""
|
||||||
|
|
||||||
duration = timedelta(minutes=5)
|
duration = timedelta(minutes=5)
|
||||||
|
@ -447,7 +447,7 @@ class StatisticMetaData(TypedDict):
|
||||||
unit_of_measurement: str | None
|
unit_of_measurement: str | None
|
||||||
|
|
||||||
|
|
||||||
class StatisticsMeta(Base): # type: ignore
|
class StatisticsMeta(Base): # type: ignore[valid-type,misc]
|
||||||
"""Statistics meta data."""
|
"""Statistics meta data."""
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
@ -468,7 +468,7 @@ class StatisticsMeta(Base): # type: ignore
|
||||||
return StatisticsMeta(**meta)
|
return StatisticsMeta(**meta)
|
||||||
|
|
||||||
|
|
||||||
class RecorderRuns(Base): # type: ignore
|
class RecorderRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of recorder run."""
|
"""Representation of recorder run."""
|
||||||
|
|
||||||
__table_args__ = (Index("ix_recorder_runs_start_end", "start", "end"),)
|
__table_args__ = (Index("ix_recorder_runs_start_end", "start", "end"),)
|
||||||
|
@ -518,7 +518,7 @@ class RecorderRuns(Base): # type: ignore
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
class SchemaChanges(Base): # type: ignore
|
class SchemaChanges(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of schema version changes."""
|
"""Representation of schema version changes."""
|
||||||
|
|
||||||
__tablename__ = TABLE_SCHEMA_CHANGES
|
__tablename__ = TABLE_SCHEMA_CHANGES
|
||||||
|
@ -536,7 +536,7 @@ class SchemaChanges(Base): # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StatisticsRuns(Base): # type: ignore
|
class StatisticsRuns(Base): # type: ignore[valid-type,misc]
|
||||||
"""Representation of statistics run."""
|
"""Representation of statistics run."""
|
||||||
|
|
||||||
__tablename__ = TABLE_STATISTICS_RUNS
|
__tablename__ = TABLE_STATISTICS_RUNS
|
||||||
|
@ -612,7 +612,7 @@ class LazyState(State):
|
||||||
self._last_updated = None
|
self._last_updated = None
|
||||||
self._context = None
|
self._context = None
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def attributes(self):
|
def attributes(self):
|
||||||
"""State attributes."""
|
"""State attributes."""
|
||||||
if not self._attributes:
|
if not self._attributes:
|
||||||
|
@ -629,7 +629,7 @@ class LazyState(State):
|
||||||
"""Set attributes."""
|
"""Set attributes."""
|
||||||
self._attributes = value
|
self._attributes = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def context(self):
|
def context(self):
|
||||||
"""State context."""
|
"""State context."""
|
||||||
if not self._context:
|
if not self._context:
|
||||||
|
@ -641,7 +641,7 @@ class LazyState(State):
|
||||||
"""Set context."""
|
"""Set context."""
|
||||||
self._context = value
|
self._context = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_changed(self):
|
def last_changed(self):
|
||||||
"""Last changed datetime."""
|
"""Last changed datetime."""
|
||||||
if not self._last_changed:
|
if not self._last_changed:
|
||||||
|
@ -653,7 +653,7 @@ class LazyState(State):
|
||||||
"""Set last changed datetime."""
|
"""Set last changed datetime."""
|
||||||
self._last_changed = value
|
self._last_changed = value
|
||||||
|
|
||||||
@property # type: ignore
|
@property
|
||||||
def last_updated(self):
|
def last_updated(self):
|
||||||
"""Last updated datetime."""
|
"""Last updated datetime."""
|
||||||
if not self._last_updated:
|
if not self._last_updated:
|
||||||
|
|
|
@ -39,4 +39,4 @@ async def test_button_opens_door(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert mock.called_once
|
assert mock.call_count == 1
|
||||||
|
|
|
@ -140,7 +140,7 @@ async def test_set_cover_position_switch_level(
|
||||||
assert state.attributes[ATTR_CURRENT_POSITION] == 10
|
assert state.attributes[ATTR_CURRENT_POSITION] == 10
|
||||||
# Ensure API called
|
# Ensure API called
|
||||||
|
|
||||||
assert device._api.post_device_command.call_count == 1 # type: ignore
|
assert device._api.post_device_command.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_set_cover_position(hass: HomeAssistant, device_factory) -> None:
|
async def test_set_cover_position(hass: HomeAssistant, device_factory) -> None:
|
||||||
|
@ -171,7 +171,7 @@ async def test_set_cover_position(hass: HomeAssistant, device_factory) -> None:
|
||||||
assert state.attributes[ATTR_CURRENT_POSITION] == 10
|
assert state.attributes[ATTR_CURRENT_POSITION] == 10
|
||||||
# Ensure API called
|
# Ensure API called
|
||||||
|
|
||||||
assert device._api.post_device_command.call_count == 1 # type: ignore
|
assert device._api.post_device_command.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_set_cover_position_unsupported(
|
async def test_set_cover_position_unsupported(
|
||||||
|
@ -196,7 +196,7 @@ async def test_set_cover_position_unsupported(
|
||||||
|
|
||||||
# Ensure API was not called
|
# Ensure API was not called
|
||||||
|
|
||||||
assert device._api.post_device_command.call_count == 0 # type: ignore
|
assert device._api.post_device_command.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_update_to_open_from_signal(hass: HomeAssistant, device_factory) -> None:
|
async def test_update_to_open_from_signal(hass: HomeAssistant, device_factory) -> None:
|
||||||
|
|
|
@ -38,7 +38,7 @@ async def test_scene_activate(hass: HomeAssistant, scene) -> None:
|
||||||
assert state.attributes["icon"] == scene.icon
|
assert state.attributes["icon"] == scene.icon
|
||||||
assert state.attributes["color"] == scene.color
|
assert state.attributes["color"] == scene.color
|
||||||
assert state.attributes["location_id"] == scene.location_id
|
assert state.attributes["location_id"] == scene.location_id
|
||||||
assert scene.execute.call_count == 1 # type: ignore
|
assert scene.execute.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_unload_config_entry(hass: HomeAssistant, scene) -> None:
|
async def test_unload_config_entry(hass: HomeAssistant, scene) -> None:
|
||||||
|
|
|
@ -20,7 +20,7 @@ import homeassistant.util.logging as logging_util
|
||||||
async def test_logging_with_queue_handler() -> None:
|
async def test_logging_with_queue_handler() -> None:
|
||||||
"""Test logging with HomeAssistantQueueHandler."""
|
"""Test logging with HomeAssistantQueueHandler."""
|
||||||
|
|
||||||
simple_queue = queue.SimpleQueue() # type: ignore
|
simple_queue = queue.SimpleQueue()
|
||||||
handler = logging_util.HomeAssistantQueueHandler(simple_queue)
|
handler = logging_util.HomeAssistantQueueHandler(simple_queue)
|
||||||
|
|
||||||
log_record = logging.makeLogRecord({"msg": "Test Log Record"})
|
log_record = logging.makeLogRecord({"msg": "Test Log Record"})
|
||||||
|
|
Loading…
Reference in New Issue