mirror of
https://github.com/home-assistant/core.git
synced 2025-11-14 21:40:16 +00:00
Add type ignore error codes [helpers] (#66776)
This commit is contained in:
@@ -15,7 +15,9 @@ import logging
|
||||
from numbers import Number
|
||||
import os
|
||||
import re
|
||||
from socket import _GLOBAL_DEFAULT_TIMEOUT # type: ignore # private, not in typeshed
|
||||
from socket import ( # type: ignore[attr-defined] # private, not in typeshed
|
||||
_GLOBAL_DEFAULT_TIMEOUT,
|
||||
)
|
||||
from typing import Any, TypeVar, cast, overload
|
||||
from urllib.parse import urlparse
|
||||
from uuid import UUID
|
||||
@@ -163,7 +165,7 @@ def boolean(value: Any) -> bool:
|
||||
return False
|
||||
elif isinstance(value, Number):
|
||||
# type ignore: https://github.com/python/mypy/issues/3186
|
||||
return value != 0 # type: ignore
|
||||
return value != 0 # type: ignore[comparison-overlap]
|
||||
raise vol.Invalid(f"invalid boolean value {value}")
|
||||
|
||||
|
||||
@@ -421,7 +423,7 @@ def date(value: Any) -> date_sys:
|
||||
|
||||
def time_period_str(value: str) -> timedelta:
|
||||
"""Validate and transform time offset."""
|
||||
if isinstance(value, int): # type: ignore
|
||||
if isinstance(value, int): # type: ignore[unreachable]
|
||||
raise vol.Invalid("Make sure you wrap time values in quotes")
|
||||
if not isinstance(value, str):
|
||||
raise vol.Invalid(TIME_PERIOD_ERROR.format(value))
|
||||
@@ -585,7 +587,7 @@ def template(value: Any | None) -> template_helper.Template:
|
||||
if isinstance(value, (list, dict, template_helper.Template)):
|
||||
raise vol.Invalid("template value should be a string")
|
||||
|
||||
template_value = template_helper.Template(str(value)) # type: ignore
|
||||
template_value = template_helper.Template(str(value)) # type: ignore[no-untyped-call]
|
||||
|
||||
try:
|
||||
template_value.ensure_valid()
|
||||
@@ -603,7 +605,7 @@ def dynamic_template(value: Any | None) -> template_helper.Template:
|
||||
if not template_helper.is_template_string(str(value)):
|
||||
raise vol.Invalid("template value does not contain a dynamic template")
|
||||
|
||||
template_value = template_helper.Template(str(value)) # type: ignore
|
||||
template_value = template_helper.Template(str(value)) # type: ignore[no-untyped-call]
|
||||
try:
|
||||
template_value.ensure_valid()
|
||||
return template_value
|
||||
@@ -796,7 +798,7 @@ def _deprecated_or_removed(
|
||||
"""Check if key is in config and log warning or error."""
|
||||
if key in config:
|
||||
try:
|
||||
near = f"near {config.__config_file__}:{config.__line__} " # type: ignore
|
||||
near = f"near {config.__config_file__}:{config.__line__} " # type: ignore[attr-defined]
|
||||
except AttributeError:
|
||||
near = ""
|
||||
arguments: tuple[str, ...]
|
||||
|
||||
Reference in New Issue
Block a user