Add typing to homeassistant/*.py and homeassistant/util/ (#15569)
* Add typing to homeassistant/*.py and homeassistant/util/ * Fix wrong merge * Restore iterable in OrderedSet * Fix tests
This commit is contained in:
1 parent
b7c336a687
commit
140a874917
27 files changed
+532
-384
No files matched your search
@@ -20,9 +20,10 @@ Related Python bugs:
|
||||
- https://bugs.python.org/issue26617
|
||||
"""
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
|
||||
def patch_weakref_tasks():
|
||||
def patch_weakref_tasks() -> None:
|
||||
"""Replace weakref.WeakSet to address Python 3 bug."""
|
||||
# pylint: disable=no-self-use, protected-access, bare-except
|
||||
import asyncio.tasks
|
||||
@@ -30,7 +31,7 @@ def patch_weakref_tasks():
|
||||
class IgnoreCalls:
|
||||
"""Ignore add calls."""
|
||||
|
||||
def add(self, other):
|
||||
def add(self, other: Any) -> None:
|
||||
"""No-op add."""
|
||||
return
|
||||
|
||||
@@ -41,7 +42,7 @@ def patch_weakref_tasks():
|
||||
pass
|
||||
|
||||
|
||||
def disable_c_asyncio():
|
||||
def disable_c_asyncio() -> None:
|
||||
"""Disable using C implementation of asyncio.
|
||||
|
||||
Required to be able to apply the weakref monkey patch.
|
||||
@@ -53,12 +54,12 @@ def disable_c_asyncio():
|
||||
|
||||
PATH_TRIGGER = '_asyncio'
|
||||
|
||||
def __init__(self, path_entry):
|
||||
def __init__(self, path_entry: str) -> None:
|
||||
if path_entry != self.PATH_TRIGGER:
|
||||
raise ImportError()
|
||||
return
|
||||
|
||||
def find_module(self, fullname, path=None):
|
||||
def find_module(self, fullname: str, path: Any = None) -> None:
|
||||
"""Find a module."""
|
||||
if fullname == self.PATH_TRIGGER:
|
||||
# We lint in Py35, exception is introduced in Py36
|
||||
|
||||
Reference in new issue
Block a user