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