Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup useless suppressions #117166

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
_LOGGER = logging.getLogger(__name__)


class AuroraAbbDataUpdateCoordinator(DataUpdateCoordinator[dict[str, float]]): # pylint: disable=hass-enforce-coordinator-module
class AuroraAbbDataUpdateCoordinator(DataUpdateCoordinator[dict[str, float]]):
"""Class to manage fetching AuroraAbbPowerone data."""

def __init__(self, hass: HomeAssistant, comport: str, address: int) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async def _async_poll(self) -> None:
)
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def _async_poll(self) -> None:
)
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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/cloud/account_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(hass.data[DOMAIN])
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/deluge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the noqa not needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the raise from inside

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's not raised in all cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is currently not taken into account. I can revert this and fix it in Ruff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good. 👍

if type(ex).__name__ == "BadLoginError":
raise ConfigEntryAuthFailed(
"Credentials for Deluge client are not valid"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/fritz/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ async def _async_update_hosts_info(self) -> dict[str, Device]:
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,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/matter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,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:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/melnor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def _async_update_data(self):
return self._device


class MelnorBluetoothEntity(CoordinatorEntity[MelnorDataUpdateCoordinator]): # pylint: disable=hass-enforce-coordinator-module
class MelnorBluetoothEntity(CoordinatorEntity[MelnorDataUpdateCoordinator]):
"""Base class for melnor entities."""

_device: Device
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/prusalink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async def _fetch_data(self) -> JobInfo:
return await self.api.get_job()


class PrusaLinkEntity(CoordinatorEntity[PrusaLinkUpdateCoordinator]): # pylint: disable=hass-enforce-coordinator-module
class PrusaLinkEntity(CoordinatorEntity[PrusaLinkUpdateCoordinator]):
MartinHjelmare marked this conversation as resolved.
Show resolved Hide resolved
"""Defines a base PrusaLink entity."""

_attr_has_entity_name = True
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/tolo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _get_tolo_sauna_data(self) -> ToloSaunaData:
return ToloSaunaData(status, settings)


class ToloSaunaCoordinatorEntity(CoordinatorEntity[ToloSaunaUpdateCoordinator]): # pylint: disable=hass-enforce-coordinator-module
class ToloSaunaCoordinatorEntity(CoordinatorEntity[ToloSaunaUpdateCoordinator]):
"""CoordinatorEntity for TOLO Sauna."""

_attr_has_entity_name = True
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/xbox/media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from contextlib import suppress
from dataclasses import dataclass

from pydantic.error_wrappers import ValidationError # pylint: disable=no-name-in-module
from pydantic.error_wrappers import ValidationError

Check warning on line 8 in homeassistant/components/xbox/media_source.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/xbox/media_source.py#L8

Added line #L8 was not covered by tests
from xbox.webapi.api.client import XboxLiveClient
from xbox.webapi.api.provider.catalog.models import FieldsTemplate, Image
from xbox.webapi.api.provider.gameclips.models import GameclipsResponse
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/helpers/check_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def _get_integration(
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"
)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/helpers/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,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."""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ select = [
"RUF013", # PEP 484 prohibits implicit Optional
"RUF018", # Avoid assignment expressions in assert statements
"RUF019", # Unnecessary key check before dictionary access
# "RUF100", # Unused `noqa` directive; temporarily every now and then to clean them up
"S102", # Use of exec detected
"S103", # bad-file-permissions
"S108", # hardcoded-temp-file
Expand Down Expand Up @@ -762,6 +761,7 @@ ignore = [
"RUF002", # Docstring contains ambiguous unicode character.
"RUF003", # Comment contains ambiguous unicode character.
"RUF015", # Prefer next(...) over single element slice
"RUF100", # Unused `noqa` directive; comment temporarily every now and then to clean them up
"SIM102", # Use a single if statement instead of nested if statements
"SIM103", # Return the condition {condition} directly
"SIM108", # Use ternary operator {contents} instead of if-else-block
Expand Down
2 changes: 1 addition & 1 deletion script/hassfest/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def gen_ha_hardware_schema(config: Config, integration: Integration):
)


def validate_translation_file( # noqa: C901
def validate_translation_file(
config: Config,
integration: Integration,
all_strings: dict[str, Any] | None,
Expand Down