Add type ignore error codes [core] (#66773)

pull/66788/head
Marc Mueller 2022-02-18 08:09:22 +01:00 committed by GitHub
parent 58551ec66d
commit 8d2fb72cc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 18 deletions

View File

@ -8,7 +8,7 @@ from .util.async_ import protect_loop
def enable() -> None:
"""Enable the detection of blocking calls in the 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
time.sleep = protect_loop(time.sleep, strict=False)

View File

@ -321,7 +321,7 @@ def async_enable_logging(
logging.getLogger("aiohttp.access").setLevel(logging.WARNING)
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(
"Uncaught thread exception",

View File

@ -816,7 +816,7 @@ async def async_process_component_config( # noqa: C901
config_validator, "async_validate_config"
):
try:
return await config_validator.async_validate_config( # type: ignore
return await config_validator.async_validate_config( # type: ignore[no-any-return]
hass, config
)
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
if hasattr(component, "CONFIG_SCHEMA"):
try:
return component.CONFIG_SCHEMA(config) # type: ignore
return component.CONFIG_SCHEMA(config) # type: ignore[no-any-return]
except vol.Invalid as ex:
async_log_exception(ex, domain, config, hass, integration.documentation)
return None

View File

@ -1213,7 +1213,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
match_dict = {} # Match any entry
for entry in self._async_current_entries(include_ignore=False):
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()
):
raise data_entry_flow.AbortFlow("already_configured")

View File

@ -238,8 +238,8 @@ class HomeAssistant:
"""Root object of the Home Assistant home automation."""
auth: AuthManager
http: HomeAssistantHTTP = None # type: ignore
config_entries: ConfigEntries = None # type: ignore
http: HomeAssistantHTTP = None # type: ignore[assignment]
config_entries: ConfigEntries = None # type: ignore[assignment]
def __init__(self) -> None:
"""Initialize new Home Assistant object."""
@ -765,7 +765,7 @@ class Event:
def __eq__(self, other: Any) -> bool:
"""Return the comparison."""
return ( # type: ignore
return ( # type: ignore[no-any-return]
self.__class__ == other.__class__
and self.event_type == other.event_type
and self.data == other.data
@ -1125,7 +1125,7 @@ class State:
def __eq__(self, other: Any) -> bool:
"""Return the comparison of the state."""
return ( # type: ignore
return ( # type: ignore[no-any-return]
self.__class__ == other.__class__
and self.entity_id == other.entity_id
and self.state == other.state

View File

@ -378,11 +378,11 @@ class FlowHandler:
# While not purely typed, it makes typehinting more useful for us
# and removes the need for constant None checks or asserts.
flow_id: str = None # type: ignore
hass: HomeAssistant = None # type: ignore
handler: str = None # type: ignore
flow_id: str = None # type: ignore[assignment]
hass: HomeAssistant = None # type: ignore[assignment]
handler: str = None # type: ignore[assignment]
# 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
init_step = "init"

View File

@ -681,7 +681,7 @@ def _load_file(
Async friendly.
"""
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 not _async_mount_config_dir(hass):

View File

@ -59,7 +59,7 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy): # type: ignore[valid
@property
def loop_name(self) -> str:
"""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:
"""Get the event loop."""
@ -72,7 +72,7 @@ class HassEventLoopPolicy(asyncio.DefaultEventLoopPolicy): # type: ignore[valid
thread_name_prefix="SyncWorker", max_workers=MAX_EXECUTOR_WORKERS
)
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"
)
return loop
@ -89,11 +89,11 @@ def _async_loop_exception_handler(_: Any, context: dict[str, Any]) -> None:
if source_traceback := context.get("source_traceback"):
stack_summary = "".join(traceback.format_list(source_traceback))
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
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: