Type Hints - __main__ (#2574)
* Add __main__ type hints * Fix most errors of __main__ * Add ignore for script.run() * Add type annotations for from_config_dict and from_config_file * Fix errors * Fix requirement error * Add mypy type check to tests * Enable travis typing check * Messed up the tox deps * Laxer type checker
This commit is contained in:
1 parent
d570d38d5c
commit
08226a4864
10 files changed
+58
-32
No files matched your search
@@ -57,7 +57,7 @@ class CoreState(enum.Enum):
|
||||
running = "RUNNING"
|
||||
stopping = "STOPPING"
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
"""Return the event."""
|
||||
return self.value
|
||||
|
||||
@@ -75,11 +75,11 @@ class HomeAssistant(object):
|
||||
self.state = CoreState.not_running
|
||||
|
||||
@property
|
||||
def is_running(self):
|
||||
def is_running(self) -> bool:
|
||||
"""Return if Home Assistant is running."""
|
||||
return self.state == CoreState.running
|
||||
|
||||
def start(self):
|
||||
def start(self) -> None:
|
||||
"""Start home assistant."""
|
||||
_LOGGER.info(
|
||||
"Starting Home Assistant (%d threads)", self.pool.worker_count)
|
||||
@@ -90,7 +90,7 @@ class HomeAssistant(object):
|
||||
self.pool.block_till_done()
|
||||
self.state = CoreState.running
|
||||
|
||||
def block_till_stopped(self):
|
||||
def block_till_stopped(self) -> int:
|
||||
"""Register service homeassistant/stop and will block until called."""
|
||||
request_shutdown = threading.Event()
|
||||
request_restart = threading.Event()
|
||||
@@ -132,7 +132,7 @@ class HomeAssistant(object):
|
||||
|
||||
return RESTART_EXIT_CODE if request_restart.isSet() else 0
|
||||
|
||||
def stop(self):
|
||||
def stop(self) -> None:
|
||||
"""Stop Home Assistant and shuts down all threads."""
|
||||
_LOGGER.info("Stopping")
|
||||
self.state = CoreState.stopping
|
||||
@@ -290,7 +290,7 @@ class EventBus(object):
|
||||
# available to execute this listener it might occur that the
|
||||
# listener gets lined up twice to be executed.
|
||||
# This will make sure the second time it does nothing.
|
||||
onetime_listener.run = True
|
||||
setattr(onetime_listener, 'run', True)
|
||||
|
||||
self.remove_listener(event_type, onetime_listener)
|
||||
|
||||
|
||||
Reference in new issue
Block a user