mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Improve and enforce type hints for imap (#92325)
This commit is contained in:
parent
e41a75f617
commit
53e533af6b
@ -170,6 +170,7 @@ homeassistant.components.hyperion.*
|
|||||||
homeassistant.components.ibeacon.*
|
homeassistant.components.ibeacon.*
|
||||||
homeassistant.components.image_processing.*
|
homeassistant.components.image_processing.*
|
||||||
homeassistant.components.image_upload.*
|
homeassistant.components.image_upload.*
|
||||||
|
homeassistant.components.imap.*
|
||||||
homeassistant.components.input_button.*
|
homeassistant.components.input_button.*
|
||||||
homeassistant.components.input_select.*
|
homeassistant.components.input_select.*
|
||||||
homeassistant.components.integration.*
|
homeassistant.components.integration.*
|
||||||
|
@ -108,9 +108,9 @@ class ImapMessage:
|
|||||||
|
|
||||||
Will look for text/plain or use text/html if not found.
|
Will look for text/plain or use text/html if not found.
|
||||||
"""
|
"""
|
||||||
message_text = None
|
message_text: str | None = None
|
||||||
message_html = None
|
message_html: str | None = None
|
||||||
message_untyped_text = None
|
message_untyped_text: str | None = None
|
||||||
|
|
||||||
for part in self.email_message.walk():
|
for part in self.email_message.walk():
|
||||||
if part.get_content_type() == CONTENT_TYPE_TEXT_PLAIN:
|
if part.get_content_type() == CONTENT_TYPE_TEXT_PLAIN:
|
||||||
@ -134,7 +134,7 @@ class ImapMessage:
|
|||||||
if message_untyped_text is not None:
|
if message_untyped_text is not None:
|
||||||
return message_untyped_text
|
return message_untyped_text
|
||||||
|
|
||||||
return self.email_message.get_payload()
|
return str(self.email_message.get_payload())
|
||||||
|
|
||||||
|
|
||||||
class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]):
|
class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]):
|
||||||
@ -231,7 +231,7 @@ class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]):
|
|||||||
_LOGGER.debug("Error while cleaning up imap connection")
|
_LOGGER.debug("Error while cleaning up imap connection")
|
||||||
self.imap_client = None
|
self.imap_client = None
|
||||||
|
|
||||||
async def shutdown(self, *_) -> None:
|
async def shutdown(self, *_: Any) -> None:
|
||||||
"""Close resources."""
|
"""Close resources."""
|
||||||
await self._cleanup(log_error=True)
|
await self._cleanup(log_error=True)
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator):
|
|||||||
await self._cleanup()
|
await self._cleanup()
|
||||||
await asyncio.sleep(BACKOFF_TIME)
|
await asyncio.sleep(BACKOFF_TIME)
|
||||||
|
|
||||||
async def shutdown(self, *_) -> None:
|
async def shutdown(self, *_: Any) -> None:
|
||||||
"""Close resources."""
|
"""Close resources."""
|
||||||
if self._push_wait_task:
|
if self._push_wait_task:
|
||||||
self._push_wait_task.cancel()
|
self._push_wait_task.cancel()
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -1462,6 +1462,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.imap.*]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_subclassing_any = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.input_button.*]
|
[mypy-homeassistant.components.input_button.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user