Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade mypy to 0.800 #45485

Merged
merged 4 commits into from Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/core.py
Expand Up @@ -205,7 +205,7 @@ class CoreState(enum.Enum):

def __str__(self) -> str: # pylint: disable=invalid-str-returned
"""Return the event."""
return self.value # type: ignore
return self.value


class HomeAssistant:
Expand Down Expand Up @@ -584,7 +584,7 @@ class EventOrigin(enum.Enum):

def __str__(self) -> str: # pylint: disable=invalid-str-returned
"""Return the event."""
return self.value # type: ignore
return self.value


class Event:
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/helpers/event.py
Expand Up @@ -116,7 +116,9 @@ class TrackTemplateResult:
result: Any


def threaded_listener_factory(async_factory: Callable[..., Any]) -> CALLBACK_TYPE:
def threaded_listener_factory(
async_factory: Callable[..., Any]
) -> Callable[..., CALLBACK_TYPE]:
"""Convert an async event helper to a threaded one."""

@ft.wraps(async_factory)
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/helpers/location.py
Expand Up @@ -18,9 +18,8 @@ def has_location(state: State) -> bool:

Async friendly.
"""
# type ignore: https://github.com/python/mypy/issues/7207
return (
isinstance(state, State) # type: ignore
isinstance(state, State)
and isinstance(state.attributes.get(ATTR_LATITUDE), float)
and isinstance(state.attributes.get(ATTR_LONGITUDE), float)
)
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/util/logging.py
Expand Up @@ -6,7 +6,7 @@
import logging.handlers
import queue
import traceback
from typing import Any, Callable, Coroutine
from typing import Any, Callable, Coroutine, Union

from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
from homeassistant.core import HomeAssistant, callback
Expand Down Expand Up @@ -108,15 +108,15 @@ def log_exception(format_err: Callable[..., Any], *args: Any) -> None:

def catch_log_exception(
func: Callable[..., Any], format_err: Callable[..., Any], *args: Any
) -> Callable[[], None]:
) -> Union[Callable[..., None], Callable[..., Coroutine[Any, Any, None]]]:
scop marked this conversation as resolved.
Show resolved Hide resolved
"""Decorate a callback to catch and log exceptions."""

# Check for partials to properly determine if coroutine function
check_func = func
while isinstance(check_func, partial):
check_func = check_func.func

wrapper_func = None
wrapper_func: Union[Callable[..., None], Callable[..., Coroutine[Any, Any, None]]]
if asyncio.iscoroutinefunction(check_func):

@wraps(func)
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Expand Up @@ -8,7 +8,7 @@ codecov==2.1.10
coverage==5.3
jsonpickle==1.4.1
mock-open==1.4.0
mypy==0.790
mypy==0.800
pre-commit==2.9.3
pylint==2.6.0
astroid==2.4.2
Expand Down