From ba18e11308b11e337ea62b1ff9982796ff640da7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 11 Jul 2022 18:34:27 +0200 Subject: [PATCH] Remove profiler from mypy ignore list (#74453) --- homeassistant/components/profiler/__init__.py | 12 +++++++----- mypy.ini | 3 --- script/hassfest/mypy_config.py | 1 - 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/profiler/__init__.py b/homeassistant/components/profiler/__init__.py index 978c19dc2ab..69bbd39a77a 100644 --- a/homeassistant/components/profiler/__init__.py +++ b/homeassistant/components/profiler/__init__.py @@ -7,7 +7,7 @@ import sys import threading import time import traceback -from typing import Any +from typing import Any, cast import voluptuous as vol @@ -123,10 +123,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: for thread in threading.enumerate(): if thread == main_thread: continue + ident = cast(int, thread.ident) _LOGGER.critical( "Thread [%s]: %s", thread.name, - "".join(traceback.format_stack(frames.get(thread.ident))).strip(), + "".join(traceback.format_stack(frames.get(ident))).strip(), ) async def _async_dump_scheduled(call: ServiceCall) -> None: @@ -136,13 +137,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: original_maxother = arepr.maxother arepr.maxstring = 300 arepr.maxother = 300 + handle: asyncio.Handle try: - for handle in hass.loop._scheduled: # pylint: disable=protected-access + for handle in getattr(hass.loop, "_scheduled"): if not handle.cancelled(): _LOGGER.critical("Scheduled: %s", handle) finally: - arepr.max_string = original_maxstring - arepr.max_other = original_maxother + arepr.maxstring = original_maxstring + arepr.maxother = original_maxother async_register_admin_service( hass, diff --git a/mypy.ini b/mypy.ini index cccfdc55091..3cdd8b2880f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2719,9 +2719,6 @@ ignore_errors = true [mypy-homeassistant.components.plex.media_player] ignore_errors = true -[mypy-homeassistant.components.profiler] -ignore_errors = true - [mypy-homeassistant.components.sonos] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 8ddfa2b53a4..76304419c6c 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -37,7 +37,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.onvif.device", "homeassistant.components.onvif.sensor", "homeassistant.components.plex.media_player", - "homeassistant.components.profiler", "homeassistant.components.sonos", "homeassistant.components.sonos.alarms", "homeassistant.components.sonos.binary_sensor",