Upgrade mypy to 0.790 (#41595)
parent
1417a4161f
commit
f28c3273c2
homeassistant
components/calendar
scripts/macos
|
@ -2,6 +2,7 @@
|
|||
from datetime import timedelta
|
||||
import logging
|
||||
import re
|
||||
from typing import Dict, List, cast
|
||||
|
||||
from aiohttp import web
|
||||
|
||||
|
@ -207,10 +208,10 @@ class CalendarListView(http.HomeAssistantView):
|
|||
async def get(self, request: web.Request) -> web.Response:
|
||||
"""Retrieve calendar list."""
|
||||
hass = request.app["hass"]
|
||||
calendar_list = []
|
||||
calendar_list: List[Dict[str, str]] = []
|
||||
|
||||
for entity in self.component.entities:
|
||||
state = hass.states.get(entity.entity_id)
|
||||
calendar_list.append({"name": state.name, "entity_id": entity.entity_id})
|
||||
|
||||
return self.json(sorted(calendar_list, key=lambda x: x["name"]))
|
||||
return self.json(sorted(calendar_list, key=lambda x: cast(str, x["name"])))
|
||||
|
|
|
@ -527,8 +527,8 @@ def template(value: Optional[Any]) -> template_helper.Template:
|
|||
template_value = template_helper.Template(str(value)) # type: ignore
|
||||
|
||||
try:
|
||||
template_value.ensure_valid()
|
||||
return cast(template_helper.Template, template_value)
|
||||
template_value.ensure_valid() # type: ignore[no-untyped-call]
|
||||
return template_value
|
||||
except TemplateError as ex:
|
||||
raise vol.Invalid(f"invalid template ({ex})") from ex
|
||||
|
||||
|
@ -545,8 +545,8 @@ def dynamic_template(value: Optional[Any]) -> template_helper.Template:
|
|||
|
||||
template_value = template_helper.Template(str(value)) # type: ignore
|
||||
try:
|
||||
template_value.ensure_valid()
|
||||
return cast(template_helper.Template, template_value)
|
||||
template_value.ensure_valid() # type: ignore[no-untyped-call]
|
||||
return template_value
|
||||
except TemplateError as ex:
|
||||
raise vol.Invalid(f"invalid template ({ex})") from ex
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ class EntityPlatform:
|
|||
|
||||
# This should not be replaced with hass.async_add_job because
|
||||
# we don't want to track this task in case it blocks startup.
|
||||
return hass.loop.run_in_executor(
|
||||
return hass.loop.run_in_executor( # type: ignore[return-value]
|
||||
None,
|
||||
platform.setup_platform, # type: ignore
|
||||
hass,
|
||||
|
|
|
@ -46,7 +46,8 @@ def closest(
|
|||
state.attributes.get(ATTR_LONGITUDE),
|
||||
latitude,
|
||||
longitude,
|
||||
),
|
||||
)
|
||||
or 0,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ def install_osx():
|
|||
|
||||
template_path = os.path.join(os.path.dirname(__file__), "launchd.plist")
|
||||
|
||||
with open(template_path, encoding="utf-8") as inp:
|
||||
plist = inp.read()
|
||||
with open(template_path, encoding="utf-8") as tinp:
|
||||
plist = tinp.read()
|
||||
|
||||
plist = plist.replace("$HASS_PATH$", hass_path)
|
||||
plist = plist.replace("$USER$", user)
|
||||
|
|
|
@ -44,7 +44,7 @@ def sanitize_path(path: str) -> str:
|
|||
|
||||
def slugify(text: str, *, separator: str = "_") -> str:
|
||||
"""Slugify a given text."""
|
||||
return unicode_slug.slugify(text, separator=separator) # type: ignore
|
||||
return unicode_slug.slugify(text, separator=separator)
|
||||
|
||||
|
||||
def repr_helper(inp: Any) -> str:
|
||||
|
|
|
@ -172,7 +172,7 @@ def async_create_catching_coro(target: Coroutine) -> Coroutine:
|
|||
wrapped_target = catch_log_coro_exception(
|
||||
target,
|
||||
lambda *args: "Exception in {} called from\n {}".format(
|
||||
target.__name__, # type: ignore
|
||||
target.__name__,
|
||||
"".join(traceback.format_list(trace[:-1])),
|
||||
),
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ codecov==2.1.10
|
|||
coverage==5.3
|
||||
jsonpickle==1.4.1
|
||||
mock-open==1.4.0
|
||||
mypy==0.782
|
||||
mypy==0.790
|
||||
pre-commit==2.7.1
|
||||
pylint==2.6.0
|
||||
astroid==2.4.2
|
||||
|
|
Loading…
Reference in New Issue