mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 19:09:32 +00:00
More typing (#15449)
## Description: More typing improvements. Switch to using `mypy.ini` for flexibility Add `warn_return_any` check except in `homeassistant.util.yaml` that does typing hacks. Fix some type annotations as resulting from this check and ignore others were fixing is hard. ## Checklist: - [x] The code change is tested and works locally. - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
This commit is contained in:
@@ -106,7 +106,7 @@ class CoreState(enum.Enum):
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Return the event."""
|
||||
return self.value
|
||||
return self.value # type: ignore
|
||||
|
||||
|
||||
class HomeAssistant(object):
|
||||
@@ -137,7 +137,7 @@ class HomeAssistant(object):
|
||||
# This is a dictionary that any component can store any data on.
|
||||
self.data = {}
|
||||
self.state = CoreState.not_running
|
||||
self.exit_code = None
|
||||
self.exit_code = 0 # type: int
|
||||
self.config_entries = None
|
||||
|
||||
@property
|
||||
@@ -239,7 +239,7 @@ class HomeAssistant(object):
|
||||
|
||||
target: target to call.
|
||||
"""
|
||||
task = self.loop.create_task(target)
|
||||
task = self.loop.create_task(target) # type: asyncio.tasks.Task
|
||||
|
||||
if self._track_task:
|
||||
self._pending_tasks.append(task)
|
||||
@@ -252,7 +252,8 @@ class HomeAssistant(object):
|
||||
target: Callable[..., Any],
|
||||
*args: Any) -> asyncio.Future:
|
||||
"""Add an executor job from within the event loop."""
|
||||
task = self.loop.run_in_executor(None, target, *args)
|
||||
task = self.loop.run_in_executor(
|
||||
None, target, *args) # type: asyncio.Future
|
||||
|
||||
# If a task is scheduled
|
||||
if self._track_task:
|
||||
@@ -307,7 +308,7 @@ class HomeAssistant(object):
|
||||
"""Stop Home Assistant and shuts down all threads."""
|
||||
fire_coroutine_threadsafe(self.async_stop(), self.loop)
|
||||
|
||||
async def async_stop(self, exit_code=0) -> None:
|
||||
async def async_stop(self, exit_code: int = 0) -> None:
|
||||
"""Stop Home Assistant and shuts down all threads.
|
||||
|
||||
This method is a coroutine.
|
||||
|
||||
Reference in New Issue
Block a user