Improve type hints in core helper tests (#120096)

This commit is contained in:
epenet 2024-06-21 15:43:27 +02:00 committed by GitHub
parent 4aecd23f1d
commit 648ef94888
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 71 additions and 59 deletions

View file

@ -237,12 +237,12 @@ async def test_async_async_request_call_without_lock(hass: HomeAssistant) -> Non
class AsyncEntity(entity.Entity):
"""Test entity."""
def __init__(self, entity_id):
def __init__(self, entity_id: str) -> None:
"""Initialize Async test entity."""
self.entity_id = entity_id
self.hass = hass
async def testhelper(self, count):
async def testhelper(self, count: int) -> None:
"""Helper function."""
updates.append(count)
@ -274,7 +274,7 @@ async def test_async_async_request_call_with_lock(hass: HomeAssistant) -> None:
class AsyncEntity(entity.Entity):
"""Test entity."""
def __init__(self, entity_id, lock):
def __init__(self, entity_id: str, lock: asyncio.Semaphore) -> None:
"""Initialize Async test entity."""
self.entity_id = entity_id
self.hass = hass
@ -324,13 +324,13 @@ async def test_async_parallel_updates_with_zero(hass: HomeAssistant) -> None:
class AsyncEntity(entity.Entity):
"""Test entity."""
def __init__(self, entity_id, count):
def __init__(self, entity_id: str, count: int) -> None:
"""Initialize Async test entity."""
self.entity_id = entity_id
self.hass = hass
self._count = count
async def async_update(self):
async def async_update(self) -> None:
"""Test update."""
updates.append(self._count)
await test_lock.wait()
@ -363,7 +363,7 @@ async def test_async_parallel_updates_with_zero_on_sync_update(
class AsyncEntity(entity.Entity):
"""Test entity."""
def __init__(self, entity_id, count):
def __init__(self, entity_id: str, count: int) -> None:
"""Initialize Async test entity."""
self.entity_id = entity_id
self.hass = hass
@ -404,14 +404,14 @@ async def test_async_parallel_updates_with_one(hass: HomeAssistant) -> None:
class AsyncEntity(entity.Entity):
"""Test entity."""
def __init__(self, entity_id, count):
def __init__(self, entity_id: str, count: int) -> None:
"""Initialize Async test entity."""
self.entity_id = entity_id
self.hass = hass
self._count = count
self.parallel_updates = test_semaphore
async def async_update(self):
async def async_update(self) -> None:
"""Test update."""
updates.append(self._count)
await test_lock.acquire()
@ -480,14 +480,14 @@ async def test_async_parallel_updates_with_two(hass: HomeAssistant) -> None:
class AsyncEntity(entity.Entity):
"""Test entity."""
def __init__(self, entity_id, count):
def __init__(self, entity_id: str, count: int) -> None:
"""Initialize Async test entity."""
self.entity_id = entity_id
self.hass = hass
self._count = count
self.parallel_updates = test_semaphore
async def async_update(self):
async def async_update(self) -> None:
"""Test update."""
updates.append(self._count)
await test_lock.acquire()
@ -550,13 +550,13 @@ async def test_async_parallel_updates_with_one_using_executor(
class SyncEntity(entity.Entity):
"""Test entity."""
def __init__(self, entity_id):
def __init__(self, entity_id: str) -> None:
"""Initialize sync test entity."""
self.entity_id = entity_id
self.hass = hass
self.parallel_updates = test_semaphore
def update(self):
def update(self) -> None:
"""Test update."""
locked.append(self.parallel_updates.locked())
@ -629,7 +629,7 @@ async def test_async_remove_twice(hass: HomeAssistant) -> None:
def __init__(self) -> None:
self.remove_calls = []
async def async_will_remove_from_hass(self):
async def async_will_remove_from_hass(self) -> None:
self.remove_calls.append(None)
platform = MockEntityPlatform(hass, domain="test")
@ -2376,7 +2376,7 @@ async def test_cached_entity_property_class_attribute(hass: HomeAssistant) -> No
This class overrides the attribute property.
"""
def __init__(self):
def __init__(self) -> None:
self._attr_attribution = values[0]
@cached_property