diff --git a/homeassistant/auth/auth_store.py b/homeassistant/auth/auth_store.py index fc47a7d71e9..1c2e8b0dfab 100644 --- a/homeassistant/auth/auth_store.py +++ b/homeassistant/auth/auth_store.py @@ -308,7 +308,7 @@ class AuthStore: credentials.data = data self._async_schedule_save() - async def async_load(self) -> None: # noqa: C901 + async def async_load(self) -> None: """Load the users.""" if self._loaded: raise RuntimeError("Auth storage is already loaded") diff --git a/homeassistant/block_async_io.py b/homeassistant/block_async_io.py index 767716dbe27..d224b0b151d 100644 --- a/homeassistant/block_async_io.py +++ b/homeassistant/block_async_io.py @@ -31,7 +31,7 @@ def _check_import_call_allowed(mapped_args: dict[str, Any]) -> bool: def _check_file_allowed(mapped_args: dict[str, Any]) -> bool: # If the file is in /proc we can ignore it. args = mapped_args["args"] - path = args[0] if type(args[0]) is str else str(args[0]) # noqa: E721 + path = args[0] if type(args[0]) is str else str(args[0]) return path.startswith(ALLOWED_FILE_PREFIXES) diff --git a/homeassistant/components/bluetooth/active_update_coordinator.py b/homeassistant/components/bluetooth/active_update_coordinator.py index 7c3d1bc3620..03c278d6b0d 100644 --- a/homeassistant/components/bluetooth/active_update_coordinator.py +++ b/homeassistant/components/bluetooth/active_update_coordinator.py @@ -132,7 +132,7 @@ class ActiveBluetoothDataUpdateCoordinator[_T](PassiveBluetoothDataUpdateCoordin ) self.last_poll_successful = False return - except Exception: # noqa: BLE001 + except Exception: if self.last_poll_successful: self.logger.exception("%s: Failure while polling", self.address) self.last_poll_successful = False diff --git a/homeassistant/components/bluetooth/active_update_processor.py b/homeassistant/components/bluetooth/active_update_processor.py index e7b65067070..8a23de682e6 100644 --- a/homeassistant/components/bluetooth/active_update_processor.py +++ b/homeassistant/components/bluetooth/active_update_processor.py @@ -127,7 +127,7 @@ class ActiveBluetoothProcessorCoordinator[_DataT]( ) self.last_poll_successful = False return - except Exception: # noqa: BLE001 + except Exception: if self.last_poll_successful: self.logger.exception("%s: Failure while polling", self.address) self.last_poll_successful = False diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 4d718433fca..16b9fb06dbb 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -523,7 +523,7 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): Remove this compatibility shim in 2025.1 or later. """ features = self.supported_features - if type(features) is int: # noqa: E721 + if type(features) is int: new_features = CameraEntityFeature(features) self._report_deprecated_supported_features_values(new_features) return new_features diff --git a/homeassistant/components/cloud/account_link.py b/homeassistant/components/cloud/account_link.py index b67c1afad71..851d658f8e0 100644 --- a/homeassistant/components/cloud/account_link.py +++ b/homeassistant/components/cloud/account_link.py @@ -65,7 +65,7 @@ async def _get_services(hass: HomeAssistant) -> list[dict[str, Any]]: services: list[dict[str, Any]] if DATA_SERVICES in hass.data: services = hass.data[DATA_SERVICES] - return services # noqa: RET504 + return services try: services = await account_link.async_fetch_available_services( diff --git a/homeassistant/components/cover/__init__.py b/homeassistant/components/cover/__init__.py index 001bff51991..c4795e0e7d9 100644 --- a/homeassistant/components/cover/__init__.py +++ b/homeassistant/components/cover/__init__.py @@ -300,7 +300,7 @@ class CoverEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): def supported_features(self) -> CoverEntityFeature: """Flag supported features.""" if (features := self._attr_supported_features) is not None: - if type(features) is int: # noqa: E721 + if type(features) is int: new_features = CoverEntityFeature(features) self._report_deprecated_supported_features_values(new_features) return new_features diff --git a/homeassistant/components/deluge/__init__.py b/homeassistant/components/deluge/__init__.py index f4608b37006..9b07ae9c875 100644 --- a/homeassistant/components/deluge/__init__.py +++ b/homeassistant/components/deluge/__init__.py @@ -41,7 +41,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: DelugeConfigEntry) -> bo await hass.async_add_executor_job(api.connect) except (ConnectionRefusedError, TimeoutError, SSLError) as ex: raise ConfigEntryNotReady("Connection to Deluge Daemon failed") from ex - except Exception as ex: # noqa: BLE001 + except Exception as ex: if type(ex).__name__ == "BadLoginError": raise ConfigEntryAuthFailed( "Credentials for Deluge client are not valid" diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index e13112f20bb..464d2bcb7e7 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -865,7 +865,7 @@ def state_supports_hue_brightness( return False features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) enum = ENTITY_FEATURES_BY_DOMAIN[domain] - features = enum(features) if type(features) is int else features # noqa: E721 + features = enum(features) if type(features) is int else features return required_feature in features diff --git a/homeassistant/components/fritz/coordinator.py b/homeassistant/components/fritz/coordinator.py index 272295cd512..52bff67c229 100644 --- a/homeassistant/components/fritz/coordinator.py +++ b/homeassistant/components/fritz/coordinator.py @@ -441,7 +441,7 @@ class FritzBoxTools(DataUpdateCoordinator[UpdateCoordinatorDataType]): hosts_info = await self.hass.async_add_executor_job( self.fritz_hosts.get_hosts_info ) - except Exception as ex: # noqa: BLE001 + except Exception as ex: if not self.hass.is_stopping: raise HomeAssistantError( translation_domain=DOMAIN, diff --git a/homeassistant/components/geniushub/config_flow.py b/homeassistant/components/geniushub/config_flow.py index b106f9907bb..18f50593dca 100644 --- a/homeassistant/components/geniushub/config_flow.py +++ b/homeassistant/components/geniushub/config_flow.py @@ -78,7 +78,7 @@ class GeniusHubConfigFlow(ConfigFlow, domain=DOMAIN): errors["base"] = "invalid_host" except (TimeoutError, aiohttp.ClientConnectionError): errors["base"] = "cannot_connect" - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: @@ -113,7 +113,7 @@ class GeniusHubConfigFlow(ConfigFlow, domain=DOMAIN): errors["base"] = "invalid_host" except (TimeoutError, aiohttp.ClientConnectionError): errors["base"] = "cannot_connect" - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: diff --git a/homeassistant/components/gtfs/sensor.py b/homeassistant/components/gtfs/sensor.py index fbc65050704..f9e9c31ce46 100644 --- a/homeassistant/components/gtfs/sensor.py +++ b/homeassistant/components/gtfs/sensor.py @@ -342,7 +342,7 @@ def get_next_departure( {tomorrow_order} origin_stop_time.departure_time LIMIT :limit - """ # noqa: S608 + """ result = schedule.engine.connect().execute( text(sql_query), { diff --git a/homeassistant/components/hassio/__init__.py b/homeassistant/components/hassio/__init__.py index fec84737e78..b95f520b9e0 100644 --- a/homeassistant/components/hassio/__init__.py +++ b/homeassistant/components/hassio/__init__.py @@ -115,7 +115,7 @@ from .coordinator import ( get_supervisor_info, # noqa: F401 get_supervisor_stats, # noqa: F401 ) -from .discovery import async_setup_discovery_view # noqa: F401 +from .discovery import async_setup_discovery_view from .handler import ( # noqa: F401 HassIO, HassioAPIError, diff --git a/homeassistant/components/homematicip_cloud/sensor.py b/homeassistant/components/homematicip_cloud/sensor.py index c44d280c190..9ed9b33d7c7 100644 --- a/homeassistant/components/homematicip_cloud/sensor.py +++ b/homeassistant/components/homematicip_cloud/sensor.py @@ -93,7 +93,7 @@ ILLUMINATION_DEVICE_ATTRIBUTES = { } -async def async_setup_entry( # noqa: C901 +async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback, diff --git a/homeassistant/components/letpot/config_flow.py b/homeassistant/components/letpot/config_flow.py index 7f2f3be1e32..fac78e440db 100644 --- a/homeassistant/components/letpot/config_flow.py +++ b/homeassistant/components/letpot/config_flow.py @@ -78,7 +78,7 @@ class LetPotConfigFlow(ConfigFlow, domain=DOMAIN): errors["base"] = "cannot_connect" except LetPotAuthenticationException: errors["base"] = "invalid_auth" - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: diff --git a/homeassistant/components/lifx/coordinator.py b/homeassistant/components/lifx/coordinator.py index 41fa04057f7..5558828a143 100644 --- a/homeassistant/components/lifx/coordinator.py +++ b/homeassistant/components/lifx/coordinator.py @@ -83,7 +83,7 @@ class SkyType(IntEnum): CLOUDS = 2 -class LIFXUpdateCoordinator(DataUpdateCoordinator[None]): # noqa: PLR0904 +class LIFXUpdateCoordinator(DataUpdateCoordinator[None]): """DataUpdateCoordinator to gather data for a specific lifx device.""" def __init__( @@ -456,7 +456,7 @@ class LIFXUpdateCoordinator(DataUpdateCoordinator[None]): # noqa: PLR0904 ) self.active_effect = FirmwareEffect[effect.upper()] - async def async_set_matrix_effect( # noqa: PLR0917 + async def async_set_matrix_effect( self, effect: str, palette: list[tuple[int, int, int, int]] | None = None, diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 76fbea70322..412ee1e6c16 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -1388,7 +1388,7 @@ class LightEntity(ToggleEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): Remove this compatibility shim in 2025.1 or later. """ features = self.supported_features - if type(features) is not int: # noqa: E721 + if type(features) is not int: return features new_features = LightEntityFeature(features) if self._deprecated_supported_features_reported is True: diff --git a/homeassistant/components/matter/__init__.py b/homeassistant/components/matter/__init__.py index e751387d7e8..e3e30fb704b 100644 --- a/homeassistant/components/matter/__init__.py +++ b/homeassistant/components/matter/__init__.py @@ -178,7 +178,7 @@ async def _client_listen( if entry.state != ConfigEntryState.LOADED: raise LOGGER.error("Failed to listen: %s", err) - except Exception as err: # noqa: BLE001 + except Exception as err: # We need to guard against unknown exceptions to not crash this task. LOGGER.exception("Unexpected exception: %s", err) if entry.state != ConfigEntryState.LOADED: diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index 291b1ec1e2a..b82cab401c5 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -780,7 +780,7 @@ class MediaPlayerEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_): Remove this compatibility shim in 2025.1 or later. """ features = self.supported_features - if type(features) is int: # noqa: E721 + if type(features) is int: new_features = MediaPlayerEntityFeature(features) self._report_deprecated_supported_features_values(new_features) return new_features diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index a5af8430629..21d250db29a 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -386,7 +386,7 @@ async def async_start( # noqa: C901 _async_add_component(discovery_payload) @callback - def async_discovery_message_received(msg: ReceiveMessage) -> None: # noqa: C901 + def async_discovery_message_received(msg: ReceiveMessage) -> None: """Process the received message.""" mqtt_data.last_discovery = msg.timestamp payload = msg.payload diff --git a/homeassistant/components/mqtt/light/schema_basic.py b/homeassistant/components/mqtt/light/schema_basic.py index 3234e9a2986..eaaa80af223 100644 --- a/homeassistant/components/mqtt/light/schema_basic.py +++ b/homeassistant/components/mqtt/light/schema_basic.py @@ -587,7 +587,7 @@ class MqttLight(MqttEntity, LightEntity, RestoreEntity): self._attr_xy_color = cast(tuple[float, float], xy_color) @callback - def _prepare_subscribe_topics(self) -> None: # noqa: C901 + def _prepare_subscribe_topics(self) -> None: """(Re)Subscribe to topics.""" self.add_subscription(CONF_STATE_TOPIC, self._state_received, {"_attr_is_on"}) self.add_subscription( diff --git a/homeassistant/components/nice_go/config_flow.py b/homeassistant/components/nice_go/config_flow.py index da3940117e9..291d4221d6c 100644 --- a/homeassistant/components/nice_go/config_flow.py +++ b/homeassistant/components/nice_go/config_flow.py @@ -50,7 +50,7 @@ class NiceGOConfigFlow(ConfigFlow, domain=DOMAIN): ) except AuthFailedError: errors["base"] = "invalid_auth" - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: @@ -92,7 +92,7 @@ class NiceGOConfigFlow(ConfigFlow, domain=DOMAIN): ) except AuthFailedError: errors["base"] = "invalid_auth" - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 6114dd39a6d..1c97870cb75 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -105,7 +105,7 @@ async def verify_connection( errors[CONF_BASE] = "response_error" except UnsupportedDeviceError: errors[CONF_BASE] = "unsupported" - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception( "Unknown exception while verifying connection with your Plugwise Smile" ) diff --git a/homeassistant/components/slide_local/config_flow.py b/homeassistant/components/slide_local/config_flow.py index a4255f0769f..7cf3f39b758 100644 --- a/homeassistant/components/slide_local/config_flow.py +++ b/homeassistant/components/slide_local/config_flow.py @@ -63,7 +63,7 @@ class SlideConfigFlow(ConfigFlow, domain=DOMAIN): return {"base": "cannot_connect"} except (AuthenticationFailed, DigestAuthCalcError): return {"base": "invalid_auth"} - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception("Exception occurred during connection test") return {"base": "unknown"} @@ -85,7 +85,7 @@ class SlideConfigFlow(ConfigFlow, domain=DOMAIN): return {"base": "cannot_connect"} except (AuthenticationFailed, DigestAuthCalcError): return {"base": "invalid_auth"} - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception("Exception occurred during connection test") return {"base": "unknown"} diff --git a/homeassistant/components/teslemetry/services.py b/homeassistant/components/teslemetry/services.py index 97cfffa1699..8215adb5711 100644 --- a/homeassistant/components/teslemetry/services.py +++ b/homeassistant/components/teslemetry/services.py @@ -98,7 +98,7 @@ def async_get_energy_site_for_entry( return energy_data -def async_register_services(hass: HomeAssistant) -> None: # noqa: C901 +def async_register_services(hass: HomeAssistant) -> None: """Set up the Teslemetry services.""" async def navigate_gps_request(call: ServiceCall) -> None: diff --git a/homeassistant/components/vacuum/__init__.py b/homeassistant/components/vacuum/__init__.py index 6fe2c3e2a5b..0cafda82786 100644 --- a/homeassistant/components/vacuum/__init__.py +++ b/homeassistant/components/vacuum/__init__.py @@ -376,7 +376,7 @@ class StateVacuumEntity( Remove this compatibility shim in 2025.1 or later. """ features = self.supported_features - if type(features) is int: # noqa: E721 + if type(features) is int: new_features = VacuumEntityFeature(features) self._report_deprecated_supported_features_values(new_features) return new_features diff --git a/homeassistant/components/websocket_api/connection.py b/homeassistant/components/websocket_api/connection.py index 62f1adc39b9..817444a970b 100644 --- a/homeassistant/components/websocket_api/connection.py +++ b/homeassistant/components/websocket_api/connection.py @@ -189,13 +189,13 @@ class ActiveConnection: if ( # Not using isinstance as we don't care about children # as these are always coming from JSON - type(msg) is not dict # noqa: E721 + type(msg) is not dict or ( not (cur_id := msg.get("id")) - or type(cur_id) is not int # noqa: E721 + or type(cur_id) is not int or cur_id < 0 or not (type_ := msg.get("type")) - or type(type_) is not str # noqa: E721 + or type(type_) is not str ) ): self.logger.error("Received invalid command: %s", msg) diff --git a/homeassistant/components/websocket_api/http.py b/homeassistant/components/websocket_api/http.py index aa2e8b547c9..b718d8e28c8 100644 --- a/homeassistant/components/websocket_api/http.py +++ b/homeassistant/components/websocket_api/http.py @@ -197,7 +197,7 @@ class WebSocketHandler: # max pending messages. return - if type(message) is not bytes: # noqa: E721 + if type(message) is not bytes: if isinstance(message, dict): message = message_to_json_bytes(message) elif isinstance(message, str): @@ -490,7 +490,7 @@ class WebSocketHandler: ) # command_msg_data is always deserialized from JSON as a list - if type(command_msg_data) is not list: # noqa: E721 + if type(command_msg_data) is not list: async_handle_str(command_msg_data) continue diff --git a/homeassistant/components/xiaomi_miio/select.py b/homeassistant/components/xiaomi_miio/select.py index eb0d6bca205..6729ce2e0f4 100644 --- a/homeassistant/components/xiaomi_miio/select.py +++ b/homeassistant/components/xiaomi_miio/select.py @@ -260,10 +260,10 @@ class XiaomiGenericSelector(XiaomiSelector): if description.options_map: self._options_map = {} - for key, val in enum_class._member_map_.items(): # noqa: SLF001 + for key, val in enum_class._member_map_.items(): self._options_map[description.options_map[key]] = val else: - self._options_map = enum_class._member_map_ # noqa: SLF001 + self._options_map = enum_class._member_map_ self._reverse_map = {val: key for key, val in self._options_map.items()} self._enum_class = enum_class diff --git a/homeassistant/components/zha/helpers.py b/homeassistant/components/zha/helpers.py index 2440e18cf53..c31627d3dc3 100644 --- a/homeassistant/components/zha/helpers.py +++ b/homeassistant/components/zha/helpers.py @@ -1170,7 +1170,7 @@ def async_add_entities( # broad exception to prevent a single entity from preventing an entire platform from loading # this can potentially be caused by a misbehaving device or a bad quirk. Not ideal but the # alternative is adding try/catch to each entity class __init__ method with a specific exception - except Exception: # noqa: BLE001 + except Exception: _LOGGER.exception( "Error while adding entity from entity data: %s", entity_data ) diff --git a/homeassistant/helpers/check_config.py b/homeassistant/helpers/check_config.py index 4b5e2f277a0..a8e8fa4160d 100644 --- a/homeassistant/helpers/check_config.py +++ b/homeassistant/helpers/check_config.py @@ -220,7 +220,7 @@ async def async_check_ha_config_file( # noqa: C901 except (vol.Invalid, HomeAssistantError) as ex: _comp_error(ex, domain, config, config[domain]) continue - except Exception as err: # noqa: BLE001 + except Exception as err: logging.getLogger(__name__).exception( "Unexpected error validating config" ) diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index b4655289469..2c8dbe69c22 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -674,11 +674,7 @@ def string(value: Any) -> str: raise vol.Invalid("string value is None") # This is expected to be the most common case, so check it first. - if ( - type(value) is str # noqa: E721 - or type(value) is NodeStrClass - or isinstance(value, str) - ): + if type(value) is str or type(value) is NodeStrClass or isinstance(value, str): return value if isinstance(value, template_helper.ResultWrapper): diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 16dee75cd23..9e8fe40c6b0 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -1028,7 +1028,7 @@ class Entity( return STATE_UNAVAILABLE if (state := self.state) is None: return STATE_UNKNOWN - if type(state) is str: # noqa: E721 + if type(state) is str: # fast path for strings return state if isinstance(state, float): diff --git a/homeassistant/helpers/json.py b/homeassistant/helpers/json.py index ebb74856429..a97dd48bf61 100644 --- a/homeassistant/helpers/json.py +++ b/homeassistant/helpers/json.py @@ -12,7 +12,7 @@ from typing import TYPE_CHECKING, Any, Final import orjson from homeassistant.util.file import write_utf8_file, write_utf8_file_atomic -from homeassistant.util.json import ( # noqa: F401 +from homeassistant.util.json import ( JSON_DECODE_EXCEPTIONS as _JSON_DECODE_EXCEPTIONS, JSON_ENCODE_EXCEPTIONS as _JSON_ENCODE_EXCEPTIONS, SerializationError, diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index e28e8aed105..8e9754ccb4d 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -502,7 +502,7 @@ def _has_match(ids: str | list[str] | None) -> TypeGuard[str | list[str]]: @bind_hass -def async_extract_referenced_entity_ids( # noqa: C901 +def async_extract_referenced_entity_ids( hass: HomeAssistant, service_call: ServiceCall, expand_group: bool = True ) -> SelectedEntities: """Extract referenced entity IDs from a service call.""" diff --git a/homeassistant/util/json.py b/homeassistant/util/json.py index 968567ae0c9..a935d44d585 100644 --- a/homeassistant/util/json.py +++ b/homeassistant/util/json.py @@ -46,7 +46,7 @@ def json_loads_array(obj: bytes | bytearray | memoryview | str, /) -> JsonArrayT """Parse JSON data and ensure result is a list.""" value: JsonValueType = json_loads(obj) # Avoid isinstance overhead as we are not interested in list subclasses - if type(value) is list: # noqa: E721 + if type(value) is list: return value raise ValueError(f"Expected JSON to be parsed as a list got {type(value)}") @@ -55,7 +55,7 @@ def json_loads_object(obj: bytes | bytearray | memoryview | str, /) -> JsonObjec """Parse JSON data and ensure result is a dictionary.""" value: JsonValueType = json_loads(obj) # Avoid isinstance overhead as we are not interested in dict subclasses - if type(value) is dict: # noqa: E721 + if type(value) is dict: return value raise ValueError(f"Expected JSON to be parsed as a dict got {type(value)}") @@ -95,7 +95,7 @@ def load_json_array( default = [] value: JsonValueType = load_json(filename, default=default) # Avoid isinstance overhead as we are not interested in list subclasses - if type(value) is list: # noqa: E721 + if type(value) is list: return value _LOGGER.exception( "Expected JSON to be parsed as a list got %s in: %s", {type(value)}, filename @@ -115,7 +115,7 @@ def load_json_object( default = {} value: JsonValueType = load_json(filename, default=default) # Avoid isinstance overhead as we are not interested in dict subclasses - if type(value) is dict: # noqa: E721 + if type(value) is dict: return value _LOGGER.exception( "Expected JSON to be parsed as a dict got %s in: %s", {type(value)}, filename diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 1d7f2b5ed88..ac27df85ccc 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -41,7 +41,7 @@ GENERAL_SETTINGS: Final[dict[str, str]] = { ), "show_error_codes": "true", "follow_imports": "normal", - # "enable_incomplete_feature": ", ".join( # noqa: FLY002 + # "enable_incomplete_feature": ", ".join( # [] # ), # Enable some checks globally. diff --git a/script/hassfest/translations.py b/script/hassfest/translations.py index 6acff1633c1..b3d397dbd55 100644 --- a/script/hassfest/translations.py +++ b/script/hassfest/translations.py @@ -454,7 +454,7 @@ ONBOARDING_SCHEMA = vol.Schema( ) -def validate_translation_file( # noqa: C901 +def validate_translation_file( config: Config, integration: Integration, all_strings: dict[str, Any] | None, diff --git a/tests/components/point/test_config_flow.py b/tests/components/point/test_config_flow.py index bd1e3cfac29..ea003af86c7 100644 --- a/tests/components/point/test_config_flow.py +++ b/tests/components/point/test_config_flow.py @@ -47,7 +47,7 @@ async def test_full_flow( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - state = config_entry_oauth2_flow._encode_jwt( # noqa: SLF001 + state = config_entry_oauth2_flow._encode_jwt( hass, { "flow_id": result["flow_id"], diff --git a/tests/components/sensor/test_init.py b/tests/components/sensor/test_init.py index 0ea46a41273..58c61715c72 100644 --- a/tests/components/sensor/test_init.py +++ b/tests/components/sensor/test_init.py @@ -570,7 +570,7 @@ async def test_unit_translation_key_without_platform_raises( match="cannot have a translation key for unit of measurement before " "being added to the entity platform", ): - unit = entity0.unit_of_measurement # noqa: F841 + unit = entity0.unit_of_measurement setup_test_component_platform(hass, sensor.DOMAIN, [entity0]) @@ -580,7 +580,7 @@ async def test_unit_translation_key_without_platform_raises( await hass.async_block_till_done() # Should not raise after being added to the platform - unit = entity0.unit_of_measurement # noqa: F841 + unit = entity0.unit_of_measurement assert unit == "Tests" diff --git a/tests/conftest.py b/tests/conftest.py index 24c4b0ceb37..83409792f5a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -43,7 +43,7 @@ from homeassistant import block_async_io from homeassistant.exceptions import ServiceNotFound # Setup patching of recorder functions before any other Home Assistant imports -from . import patch_recorder # noqa: F401, isort:skip +from . import patch_recorder # Setup patching of dt_util time functions before any other Home Assistant imports from . import patch_time # noqa: F401, isort:skip diff --git a/tests/patch_recorder.py b/tests/patch_recorder.py index 4993e84fc30..e0e66de19a5 100644 --- a/tests/patch_recorder.py +++ b/tests/patch_recorder.py @@ -6,7 +6,7 @@ from contextlib import contextmanager import sys # Patch recorder util session scope -from homeassistant.helpers import recorder as recorder_helper # noqa: E402 +from homeassistant.helpers import recorder as recorder_helper # Make sure homeassistant.components.recorder.util is not already imported assert "homeassistant.components.recorder.util" not in sys.modules diff --git a/tests/test_block_async_io.py b/tests/test_block_async_io.py index dd23d4e9709..f42fbb9f4ef 100644 --- a/tests/test_block_async_io.py +++ b/tests/test_block_async_io.py @@ -261,7 +261,7 @@ async def test_protect_path_read_bytes(caplog: pytest.LogCaptureFixture) -> None block_async_io.enable() with ( contextlib.suppress(FileNotFoundError), - Path("/config/data_not_exist").read_bytes(), # noqa: ASYNC230 + Path("/config/data_not_exist").read_bytes(), ): pass @@ -274,7 +274,7 @@ async def test_protect_path_read_text(caplog: pytest.LogCaptureFixture) -> None: block_async_io.enable() with ( contextlib.suppress(FileNotFoundError), - Path("/config/data_not_exist").read_text(encoding="utf8"), # noqa: ASYNC230 + Path("/config/data_not_exist").read_text(encoding="utf8"), ): pass @@ -287,7 +287,7 @@ async def test_protect_path_write_bytes(caplog: pytest.LogCaptureFixture) -> Non block_async_io.enable() with ( contextlib.suppress(FileNotFoundError), - Path("/config/data/not/exist").write_bytes(b"xxx"), # noqa: ASYNC230 + Path("/config/data/not/exist").write_bytes(b"xxx"), ): pass @@ -300,7 +300,7 @@ async def test_protect_path_write_text(caplog: pytest.LogCaptureFixture) -> None block_async_io.enable() with ( contextlib.suppress(FileNotFoundError), - Path("/config/data/not/exist").write_text("xxx", encoding="utf8"), # noqa: ASYNC230 + Path("/config/data/not/exist").write_text("xxx", encoding="utf8"), ): pass