Add type ignore error codes [core] (#66773)
This commit is contained in:
parent
58551ec66d
commit
8d2fb72cc3
8 changed files with 18 additions and 18 deletions
|
@ -8,7 +8,7 @@ from .util.async_ import protect_loop
|
||||||
def enable() -> None:
|
def enable() -> None:
|
||||||
"""Enable the detection of blocking calls in the event loop."""
|
"""Enable the detection of blocking calls in the event loop."""
|
||||||
# Prevent urllib3 and requests doing I/O in event loop
|
# Prevent urllib3 and requests doing I/O in event loop
|
||||||
HTTPConnection.putrequest = protect_loop(HTTPConnection.putrequest) # type: ignore
|
HTTPConnection.putrequest = protect_loop(HTTPConnection.putrequest) # type: ignore[assignment]
|
||||||
|
|
||||||
# Prevent sleeping in event loop. Non-strict since 2022.02
|
# Prevent sleeping in event loop. Non-strict since 2022.02
|
||||||
time.sleep = protect_loop(time.sleep, strict=False)
|
time.sleep = protect_loop(time.sleep, strict=False)
|
||||||
|
|
|
@ -321,7 +321,7 @@ def async_enable_logging(
|
||||||
logging.getLogger("aiohttp.access").setLevel(logging.WARNING)
|
logging.getLogger("aiohttp.access").setLevel(logging.WARNING)
|
||||||
|
|
||||||
sys.excepthook = lambda *args: logging.getLogger(None).exception(
|
sys.excepthook = lambda *args: logging.getLogger(None).exception(
|
||||||
"Uncaught exception", exc_info=args # type: ignore
|
"Uncaught exception", exc_info=args # type: ignore[arg-type]
|
||||||
)
|
)
|
||||||
threading.excepthook = lambda args: logging.getLogger(None).exception(
|
threading.excepthook = lambda args: logging.getLogger(None).exception(
|
||||||
"Uncaught thread exception",
|
"Uncaught thread exception",
|
||||||
|
|
|
@ -816,7 +816,7 @@ async def async_process_component_config( # noqa: C901
|
||||||
config_validator, "async_validate_config"
|
config_validator, "async_validate_config"
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
return await config_validator.async_validate_config( # type: ignore
|
return await config_validator.async_validate_config( # type: ignore[no-any-return]
|
||||||
hass, config
|
hass, config
|
||||||
)
|
)
|
||||||
except (vol.Invalid, HomeAssistantError) as ex:
|
except (vol.Invalid, HomeAssistantError) as ex:
|
||||||
|
@ -829,7 +829,7 @@ async def async_process_component_config( # noqa: C901
|
||||||
# No custom config validator, proceed with schema validation
|
# No custom config validator, proceed with schema validation
|
||||||
if hasattr(component, "CONFIG_SCHEMA"):
|
if hasattr(component, "CONFIG_SCHEMA"):
|
||||||
try:
|
try:
|
||||||
return component.CONFIG_SCHEMA(config) # type: ignore
|
return component.CONFIG_SCHEMA(config) # type: ignore[no-any-return]
|
||||||
except vol.Invalid as ex:
|
except vol.Invalid as ex:
|
||||||
async_log_exception(ex, domain, config, hass, integration.documentation)
|
async_log_exception(ex, domain, config, hass, integration.documentation)
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -1213,7 +1213,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||||
match_dict = {} # Match any entry
|
match_dict = {} # Match any entry
|
||||||
for entry in self._async_current_entries(include_ignore=False):
|
for entry in self._async_current_entries(include_ignore=False):
|
||||||
if all(
|
if all(
|
||||||
item in ChainMap(entry.options, entry.data).items() # type: ignore
|
item in ChainMap(entry.options, entry.data).items() # type: ignore[arg-type]
|
||||||
for item in match_dict.items()
|
for item in match_dict.items()
|
||||||
):
|
):
|
||||||
raise data_entry_flow.AbortFlow("already_configured")
|
raise data_entry_flow.AbortFlow("already_configured")
|
||||||
|
|
|
@ -238,8 +238,8 @@ class HomeAssistant:
|
||||||
"""Root object of the Home Assistant home automation."""
|
"""Root object of the Home Assistant home automation."""
|
||||||
|
|
||||||
auth: AuthManager
|
auth: AuthManager
|
||||||
http: HomeAssistantHTTP = None # type: ignore
|
http: HomeAssistantHTTP = None # type: ignore[assignment]
|
||||||
config_entries: ConfigEntries = None # type: ignore
|
config_entries: ConfigEntries = None # type: ignore[assignment]
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize new Home Assistant object."""
|
"""Initialize new Home Assistant object."""
|
||||||
|
@ -765,7 +765,7 @@ class Event:
|
||||||
|
|
||||||
def __eq__(self, other: Any) -> bool:
|
def __eq__(self, other: Any) -> bool:
|
||||||
"""Return the comparison."""
|
"""Return the comparison."""
|
||||||
return ( # type: ignore
|
return ( # type: ignore[no-any-return]
|
||||||
self.__class__ == other.__class__
|
self.__class__ == other.__class__
|
||||||
and self.event_type == other.event_type
|
and self.event_type == other.event_type
|
||||||
and self.data == other.data
|
and self.data == other.data
|
||||||
|
@ -1125,7 +1125,7 @@ class State:
|
||||||
|
|
||||||
def __eq__(self, other: Any) -> bool:
|
def __eq__(self, other: Any) -> bool:
|
||||||
"""Return the comparison of the state."""
|
"""Return the comparison of the state."""
|
||||||
return ( # type: ignore
|
return ( # type: ignore[no-any-return]
|
||||||
self.__class__ == other.__class__
|
self.__class__ == other.__class__
|
||||||
and self.entity_id == other.entity_id
|
and self.entity_id == other.entity_id
|
||||||
and self.state == other.state
|
and self.state == other.state
|
||||||
|
|
|
@ -378,11 +378,11 @@ class FlowHandler:
|
||||||
|
|
||||||
# While not purely typed, it makes typehinting more useful for us
|
# While not purely typed, it makes typehinting more useful for us
|
||||||
# and removes the need for constant None checks or asserts.
|
# and removes the need for constant None checks or asserts.
|
||||||
flow_id: str = None # type: ignore
|
flow_id: str = None # type: ignore[assignment]
|
||||||
hass: HomeAssistant = None # type: ignore
|
hass: HomeAssistant = None # type: ignore[assignment]
|
||||||
handler: str = None # type: ignore
|
handler: str = None # type: ignore[assignment]
|
||||||
# Ensure the attribute has a subscriptable, but immutable, default value.
|
# Ensure the attribute has a subscriptable, but immutable, default value.
|
||||||
context: dict[str, Any] = MappingProxyType({}) # type: ignore
|
context: dict[str, Any] = MappingProxyType({}) # type: ignore[assignment]
|
||||||
|
|
||||||
# Set by _async_create_flow callback
|
# Set by _async_create_flow callback
|
||||||
init_step = "init"
|
init_step = "init"
|
||||||
|
|
|
@ -681,7 +681,7 @@ def _load_file(
|
||||||
Async friendly.
|
Async friendly.
|
||||||
"""
|
"""
|
||||||
with suppress(KeyError):
|
with suppress(KeyError):
|
||||||
return hass.data[DATA_COMPONENTS][comp_or_platform] # type: ignore
|
return hass.data[DATA_COMPONENTS][comp_or_platform] # type: ignore[no-any-return]
|
||||||
|
|
||||||
if (cache := hass.data.get(DATA_COMPONENTS)) is None:
|
if (cache := hass.data.get(DATA_COMPONENTS)) is None:
|
||||||
if not _async_mount_config_dir(hass):
|
if not _async_mount_config_dir(hass):
|
||||||
|
|
|
@ -59,7 +59,7 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy): # type: ignore[valid
|
||||||
@property
|
@property
|
||||||
def loop_name(self) -> str:
|
def loop_name(self) -> str:
|
||||||
"""Return name of the loop."""
|
"""Return name of the loop."""
|
||||||
return self._loop_factory.__name__ # type: ignore
|
return self._loop_factory.__name__ # type: ignore[no-any-return]
|
||||||
|
|
||||||
def new_event_loop(self) -> asyncio.AbstractEventLoop:
|
def new_event_loop(self) -> asyncio.AbstractEventLoop:
|
||||||
"""Get the event loop."""
|
"""Get the event loop."""
|
||||||
|
@ -72,7 +72,7 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy): # type: ignore[valid
|
||||||
thread_name_prefix="SyncWorker", max_workers=MAX_EXECUTOR_WORKERS
|
thread_name_prefix="SyncWorker", max_workers=MAX_EXECUTOR_WORKERS
|
||||||
)
|
)
|
||||||
loop.set_default_executor(executor)
|
loop.set_default_executor(executor)
|
||||||
loop.set_default_executor = warn_use( # type: ignore
|
loop.set_default_executor = warn_use( # type: ignore[assignment]
|
||||||
loop.set_default_executor, "sets default executor on the event loop"
|
loop.set_default_executor, "sets default executor on the event loop"
|
||||||
)
|
)
|
||||||
return loop
|
return loop
|
||||||
|
@ -89,11 +89,11 @@ def _async_loop_exception_handler(_: Any, context: dict[str, Any]) -> None:
|
||||||
if source_traceback := context.get("source_traceback"):
|
if source_traceback := context.get("source_traceback"):
|
||||||
stack_summary = "".join(traceback.format_list(source_traceback))
|
stack_summary = "".join(traceback.format_list(source_traceback))
|
||||||
logger.error(
|
logger.error(
|
||||||
"Error doing job: %s: %s", context["message"], stack_summary, **kwargs # type: ignore
|
"Error doing job: %s: %s", context["message"], stack_summary, **kwargs # type: ignore[arg-type]
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.error("Error doing job: %s", context["message"], **kwargs) # type: ignore
|
logger.error("Error doing job: %s", context["message"], **kwargs) # type: ignore[arg-type]
|
||||||
|
|
||||||
|
|
||||||
async def setup_and_run_hass(runtime_config: RuntimeConfig) -> int:
|
async def setup_and_run_hass(runtime_config: RuntimeConfig) -> int:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue