Disable no-self-use [pylint] (#70641)
* Disable no-self-use * Remove disable comments
This commit is contained in:
parent
9dcbc8469e
commit
9b9b553521
49 changed files with 14 additions and 64 deletions
|
@ -147,9 +147,7 @@ class Data:
|
|||
if not bcrypt.checkpw(password.encode(), user_hash):
|
||||
raise InvalidAuth
|
||||
|
||||
def hash_password( # pylint: disable=no-self-use
|
||||
self, password: str, for_storage: bool = False
|
||||
) -> bytes:
|
||||
def hash_password(self, password: str, for_storage: bool = False) -> bytes:
|
||||
"""Encode a password."""
|
||||
hashed: bytes = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))
|
||||
|
||||
|
|
|
@ -73,8 +73,6 @@ class AlexaCapability:
|
|||
https://developer.amazon.com/docs/device-apis/message-guide.html
|
||||
"""
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
supported_locales = {"en-US"}
|
||||
|
||||
def __init__(self, entity: State, instance: str | None = None) -> None:
|
||||
|
|
|
@ -84,7 +84,6 @@ class AbstractConfig(ABC):
|
|||
@callback
|
||||
def should_expose(self, entity_id):
|
||||
"""If an entity should be exposed."""
|
||||
# pylint: disable=no-self-use
|
||||
return False
|
||||
|
||||
@callback
|
||||
|
|
|
@ -200,8 +200,6 @@ class AlexaCapabilityResource:
|
|||
https://developer.amazon.com/docs/device-apis/resources-and-assets.html#capability-resources
|
||||
"""
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
def __init__(self, labels):
|
||||
"""Initialize an Alexa resource."""
|
||||
self._resource_labels = []
|
||||
|
|
|
@ -140,7 +140,6 @@ class AmbiclimateAuthCallbackView(HomeAssistantView):
|
|||
|
||||
async def get(self, request: web.Request) -> str:
|
||||
"""Receive authorization token."""
|
||||
# pylint: disable=no-self-use
|
||||
if (code := request.query.get("code")) is None:
|
||||
return "No code"
|
||||
hass = request.app["hass"]
|
||||
|
|
|
@ -89,7 +89,6 @@ class APIEventStream(HomeAssistantView):
|
|||
|
||||
async def get(self, request):
|
||||
"""Provide a streaming interface for the event bus."""
|
||||
# pylint: disable=no-self-use
|
||||
if not request["hass_user"].is_admin:
|
||||
raise Unauthorized()
|
||||
hass = request.app["hass"]
|
||||
|
@ -379,7 +378,6 @@ class APIErrorLog(HomeAssistantView):
|
|||
|
||||
async def get(self, request):
|
||||
"""Retrieve API error log."""
|
||||
# pylint: disable=no-self-use
|
||||
if not request["hass_user"].is_admin:
|
||||
raise Unauthorized()
|
||||
return web.FileResponse(request.app["hass"].data[DATA_LOGGING])
|
||||
|
|
|
@ -271,7 +271,6 @@ class TokenView(HomeAssistantView):
|
|||
|
||||
async def _async_handle_revoke_token(self, hass, data):
|
||||
"""Handle revoke token request."""
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
# OAuth 2.0 Token Revocation [RFC7009]
|
||||
# 2.2 The authorization server responds with HTTP status code 200
|
||||
|
|
|
@ -198,7 +198,6 @@ class LoginFlowIndexView(LoginFlowBaseView):
|
|||
|
||||
async def get(self, request):
|
||||
"""Do not allow index of flows in progress."""
|
||||
# pylint: disable=no-self-use
|
||||
return web.Response(status=HTTPStatus.METHOD_NOT_ALLOWED)
|
||||
|
||||
@RequestDataValidator(
|
||||
|
|
|
@ -76,7 +76,6 @@ class AwairDataUpdateCoordinator(DataUpdateCoordinator):
|
|||
|
||||
async def _fetch_air_data(self, device):
|
||||
"""Fetch latest air quality data."""
|
||||
# pylint: disable=no-self-use
|
||||
LOGGER.debug("Fetching data for %s", device.uuid)
|
||||
air_data = await device.air_data_latest()
|
||||
LOGGER.debug(air_data)
|
||||
|
|
|
@ -26,7 +26,7 @@ class DownloadBackupView(HomeAssistantView):
|
|||
url = "/api/backup/download/{slug}"
|
||||
name = "api:backup:download"
|
||||
|
||||
async def get( # pylint: disable=no-self-use
|
||||
async def get(
|
||||
self,
|
||||
request: Request,
|
||||
slug: str,
|
||||
|
|
|
@ -549,7 +549,6 @@ class Camera(Entity):
|
|||
This is used by cameras with CameraEntityFeature.STREAM
|
||||
and StreamType.HLS.
|
||||
"""
|
||||
# pylint: disable=no-self-use
|
||||
return None
|
||||
|
||||
async def async_handle_web_rtc_offer(self, offer_sdp: str) -> str | None:
|
||||
|
|
|
@ -160,7 +160,6 @@ class ConfigManagerFlowIndexView(FlowManagerIndexView):
|
|||
|
||||
async def get(self, request):
|
||||
"""Not implemented."""
|
||||
# pylint: disable=no-self-use
|
||||
raise aiohttp.web_exceptions.HTTPMethodNotAllowed("GET", ["POST"])
|
||||
|
||||
# pylint: disable=arguments-differ
|
||||
|
|
|
@ -17,12 +17,10 @@ class AbstractConversationAgent(ABC):
|
|||
|
||||
async def async_get_onboarding(self):
|
||||
"""Get onboard data."""
|
||||
# pylint: disable=no-self-use
|
||||
return None
|
||||
|
||||
async def async_set_onboarding(self, shown):
|
||||
"""Set onboard data."""
|
||||
# pylint: disable=no-self-use
|
||||
return True
|
||||
|
||||
@abstractmethod
|
||||
|
|
|
@ -180,7 +180,7 @@ class DownloadDiagnosticsView(http.HomeAssistantView):
|
|||
extra_urls = ["/api/diagnostics/{d_type}/{d_id}/{sub_type}/{sub_id}"]
|
||||
name = "api:diagnostics"
|
||||
|
||||
async def get( # pylint: disable=no-self-use
|
||||
async def get(
|
||||
self,
|
||||
request: web.Request,
|
||||
d_type: str,
|
||||
|
|
|
@ -336,7 +336,6 @@ class DoorBirdRequestView(HomeAssistantView):
|
|||
|
||||
async def get(self, request, event):
|
||||
"""Respond to requests from the device."""
|
||||
# pylint: disable=no-self-use
|
||||
hass = request.app["hass"]
|
||||
|
||||
token = request.query.get("token")
|
||||
|
|
|
@ -127,7 +127,7 @@ class UPNPResponderProtocol:
|
|||
_LOGGER.debug("UPNP Responder responding with: %s", response)
|
||||
self.transport.sendto(response, addr)
|
||||
|
||||
def error_received(self, exc): # pylint: disable=no-self-use
|
||||
def error_received(self, exc):
|
||||
"""Log UPNP errors."""
|
||||
_LOGGER.error("UPNP Error received: %s", exc)
|
||||
|
||||
|
|
|
@ -611,7 +611,7 @@ class ManifestJSONView(HomeAssistantView):
|
|||
name = "manifestjson"
|
||||
|
||||
@callback
|
||||
def get(self, request: web.Request) -> web.Response: # pylint: disable=no-self-use
|
||||
def get(self, request: web.Request) -> web.Response:
|
||||
"""Return the manifest.json."""
|
||||
return web.Response(
|
||||
text=MANIFEST_JSON.json, content_type="application/manifest+json"
|
||||
|
|
|
@ -167,7 +167,6 @@ class AbstractConfig(ABC):
|
|||
|
||||
def should_2fa(self, state):
|
||||
"""If an entity should have 2FA checked."""
|
||||
# pylint: disable=no-self-use
|
||||
return True
|
||||
|
||||
async def async_report_state(self, message, agent_user_id: str):
|
||||
|
|
|
@ -1004,7 +1004,6 @@ class HomeKitPairingQRView(HomeAssistantView):
|
|||
|
||||
async def get(self, request: web.Request) -> web.Response:
|
||||
"""Retrieve the pairing QRCode image."""
|
||||
# pylint: disable=no-self-use
|
||||
if not request.query_string:
|
||||
raise Unauthorized()
|
||||
entry_id, secret = request.query_string.split("-")
|
||||
|
|
|
@ -60,7 +60,6 @@ class HomematicipAuth:
|
|||
|
||||
async def get_auth(self, hass: HomeAssistant, hapid, pin):
|
||||
"""Create a HomematicIP access point object."""
|
||||
# pylint: disable=no-self-use
|
||||
auth = AsyncAuth(hass.loop, async_get_clientsession(hass))
|
||||
try:
|
||||
await auth.init(hapid)
|
||||
|
|
|
@ -69,7 +69,6 @@ class HuisbaasjeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||
"""
|
||||
# pylint: disable=no-self-use
|
||||
username = user_input[CONF_USERNAME]
|
||||
password = user_input[CONF_PASSWORD]
|
||||
|
||||
|
|
|
@ -485,7 +485,6 @@ class HyperionBaseLight(LightEntity):
|
|||
priority: dict[str, Any] | None = self._client.visible_priority
|
||||
return priority
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def _allow_priority_update(self, priority: dict[str, Any] | None = None) -> bool:
|
||||
"""Determine whether to allow a priority to update internal state."""
|
||||
return True
|
||||
|
|
|
@ -69,12 +69,10 @@ class LovelaceConfig(ABC):
|
|||
|
||||
async def async_save(self, config):
|
||||
"""Save config."""
|
||||
# pylint: disable=no-self-use
|
||||
raise HomeAssistantError("Not supported")
|
||||
|
||||
async def async_delete(self):
|
||||
"""Delete config."""
|
||||
# pylint: disable=no-self-use
|
||||
raise HomeAssistantError("Not supported")
|
||||
|
||||
@callback
|
||||
|
|
|
@ -540,7 +540,6 @@ class MediaPlayerEntity(Entity):
|
|||
|
||||
Must be implemented by integration.
|
||||
"""
|
||||
# pylint: disable=no-self-use
|
||||
return None, None
|
||||
|
||||
@property
|
||||
|
|
|
@ -301,9 +301,7 @@ class UploadMediaView(http.HomeAssistantView):
|
|||
{"media_content_id": f"{data['media_content_id']}/{uploaded_file.filename}"}
|
||||
)
|
||||
|
||||
def _move_file( # pylint: disable=no-self-use
|
||||
self, target_dir: Path, uploaded_file: FileField
|
||||
) -> None:
|
||||
def _move_file(self, target_dir: Path, uploaded_file: FileField) -> None:
|
||||
"""Move file to target."""
|
||||
if not target_dir.is_dir():
|
||||
raise ValueError("Target is not an existing directory")
|
||||
|
|
|
@ -168,7 +168,6 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
class NumatoAPI:
|
||||
"""Home-Assistant specific API for numato device access."""
|
||||
|
||||
|
|
|
@ -420,7 +420,6 @@ class PlexAuthorizationCallbackView(HomeAssistantView):
|
|||
|
||||
async def get(self, request):
|
||||
"""Receive authorization confirmation."""
|
||||
# pylint: disable=no-self-use
|
||||
hass = request.app["hass"]
|
||||
await hass.config_entries.flow.async_configure(
|
||||
flow_id=request.query["flow_id"], user_input=None
|
||||
|
|
|
@ -22,7 +22,7 @@ class PlexImageView(HomeAssistantView):
|
|||
name = "api:plex:image"
|
||||
url = "/api/plex_image_proxy/{server_id}/{media_content_id}"
|
||||
|
||||
async def get( # pylint: disable=no-self-use
|
||||
async def get(
|
||||
self,
|
||||
request: web.Request,
|
||||
server_id: str,
|
||||
|
|
|
@ -236,7 +236,6 @@ class StubPrinter:
|
|||
|
||||
def _call_print(self, *objects, **kwargs):
|
||||
"""Print text."""
|
||||
# pylint: disable=no-self-use
|
||||
_LOGGER.warning("Don't use print() inside scripts. Use logger.info() instead")
|
||||
|
||||
|
||||
|
@ -246,7 +245,6 @@ class TimeWrapper:
|
|||
# Class variable, only going to warn once per Home Assistant run
|
||||
warned = False
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def sleep(self, *args, **kwargs):
|
||||
"""Sleep method that warns once."""
|
||||
if not TimeWrapper.warned:
|
||||
|
|
|
@ -124,7 +124,7 @@ class IRobotEntity(Entity):
|
|||
"""Register callback function."""
|
||||
self.vacuum.register_on_message_callback(self.on_message)
|
||||
|
||||
def new_state_filter(self, new_state): # pylint: disable=no-self-use
|
||||
def new_state_filter(self, new_state):
|
||||
"""Filter out wifi state messages."""
|
||||
return len(new_state) > 1 or "signal" not in new_state
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ class SmartTubController:
|
|||
return data
|
||||
|
||||
async def _get_spa_data(self, spa):
|
||||
# pylint: disable=no-self-use
|
||||
full_status, reminders, errors = await asyncio.gather(
|
||||
spa.get_status_full(),
|
||||
spa.get_reminders(),
|
||||
|
|
|
@ -73,7 +73,6 @@ class Gateway:
|
|||
|
||||
self._hass.add_job(self._notify_incoming_sms, data)
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def get_and_delete_all_sms(self, state_machine, force=False):
|
||||
"""Read and delete all SMS in the modem."""
|
||||
# Read SMS memory status ...
|
||||
|
|
|
@ -145,7 +145,6 @@ class WebhookView(HomeAssistantView):
|
|||
|
||||
async def _handle(self, request: Request, webhook_id: str) -> Response:
|
||||
"""Handle webhook call."""
|
||||
# pylint: disable=no-self-use
|
||||
_LOGGER.debug("Handling webhook %s payload for %s", request.method, webhook_id)
|
||||
hass = request.app["hass"]
|
||||
return await async_handle_webhook(hass, webhook_id, request)
|
||||
|
|
|
@ -42,7 +42,6 @@ class WebsocketAPIView(HomeAssistantView):
|
|||
|
||||
async def get(self, request: web.Request) -> web.WebSocketResponse:
|
||||
"""Handle an incoming websocket connection."""
|
||||
# pylint: disable=no-self-use
|
||||
return await WebSocketHandler(request.app["hass"], request).async_handle()
|
||||
|
||||
|
||||
|
|
|
@ -186,7 +186,6 @@ class WirelessTagBaseSensor(Entity):
|
|||
"""
|
||||
return self.decorate_value(self.principal_value)
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def decorate_value(self, value):
|
||||
"""Decorate input value to be well presented for end user."""
|
||||
return f"{value:.1f}"
|
||||
|
|
|
@ -641,7 +641,6 @@ class DataManager:
|
|||
|
||||
Withings' API occasionally and incorrectly throws errors. Retrying the call tends to work.
|
||||
"""
|
||||
# pylint: disable=no-self-use
|
||||
exception = None
|
||||
for attempt in range(1, attempts + 1):
|
||||
_LOGGER.debug("Attempt %s of %s", attempt, attempts)
|
||||
|
|
|
@ -347,7 +347,6 @@ async def async_send_message( # noqa: C901
|
|||
except NotConnectedError as ex:
|
||||
_LOGGER.error("Connection error %s", ex)
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def get_random_filename(self, filename, extension=None):
|
||||
"""Return a random filename, leaving the extension intact."""
|
||||
if extension is None:
|
||||
|
|
|
@ -60,7 +60,6 @@ class ZWaveNodePingButton(ButtonEntity):
|
|||
|
||||
async def async_poll_value(self, _: bool) -> None:
|
||||
"""Poll a value."""
|
||||
# pylint: disable=no-self-use
|
||||
LOGGER.error(
|
||||
"There is no value to refresh for this entity so the zwave_js.refresh_value "
|
||||
"service won't work for it"
|
||||
|
|
|
@ -240,7 +240,6 @@ class BaseDiscoverySchemaDataTemplate:
|
|||
Can optionally be implemented by subclasses if input data needs to be
|
||||
transformed once discovered Value is available.
|
||||
"""
|
||||
# pylint: disable=no-self-use
|
||||
return {}
|
||||
|
||||
def values_to_watch(self, resolved_data: Any) -> Iterable[ZwaveValue]:
|
||||
|
@ -249,7 +248,6 @@ class BaseDiscoverySchemaDataTemplate:
|
|||
|
||||
Should be implemented by subclasses only if there are values to watch.
|
||||
"""
|
||||
# pylint: disable=no-self-use
|
||||
return []
|
||||
|
||||
def value_ids_to_watch(self, resolved_data: Any) -> set[str]:
|
||||
|
|
|
@ -487,7 +487,6 @@ class ZWaveNodeStatusSensor(SensorEntity):
|
|||
|
||||
async def async_poll_value(self, _: bool) -> None:
|
||||
"""Poll a value."""
|
||||
# pylint: disable=no-self-use
|
||||
LOGGER.error(
|
||||
"There is no value to refresh for this entity so the zwave_js.refresh_value "
|
||||
"service won't work for it"
|
||||
|
|
|
@ -328,7 +328,6 @@ class ZWaveServices:
|
|||
|
||||
async def async_set_config_parameter(self, service: ServiceCall) -> None:
|
||||
"""Set a config value on a node."""
|
||||
# pylint: disable=no-self-use
|
||||
nodes = service.data[const.ATTR_NODES]
|
||||
property_or_property_name = service.data[const.ATTR_CONFIG_PARAMETER]
|
||||
property_key = service.data.get(const.ATTR_CONFIG_PARAMETER_BITMASK)
|
||||
|
@ -356,7 +355,6 @@ class ZWaveServices:
|
|||
self, service: ServiceCall
|
||||
) -> None:
|
||||
"""Bulk set multiple partial config values on a node."""
|
||||
# pylint: disable=no-self-use
|
||||
nodes = service.data[const.ATTR_NODES]
|
||||
property_ = service.data[const.ATTR_CONFIG_PARAMETER]
|
||||
new_value = service.data[const.ATTR_CONFIG_VALUE]
|
||||
|
@ -391,7 +389,6 @@ class ZWaveServices:
|
|||
|
||||
async def async_set_value(self, service: ServiceCall) -> None:
|
||||
"""Set a value on a node."""
|
||||
# pylint: disable=no-self-use
|
||||
nodes: set[ZwaveNode] = service.data[const.ATTR_NODES]
|
||||
command_class = service.data[const.ATTR_COMMAND_CLASS]
|
||||
property_ = service.data[const.ATTR_PROPERTY]
|
||||
|
@ -503,7 +500,6 @@ class ZWaveServices:
|
|||
|
||||
async def async_ping(self, service: ServiceCall) -> None:
|
||||
"""Ping node(s)."""
|
||||
# pylint: disable=no-self-use
|
||||
const.LOGGER.warning(
|
||||
"This service is deprecated in favor of the ping button entity. Service "
|
||||
"calls will still work for now but the service will be removed in a "
|
||||
|
|
|
@ -602,7 +602,6 @@ class HomeAssistant:
|
|||
|
||||
async def _await_and_log_pending(self, pending: Iterable[Awaitable[Any]]) -> None:
|
||||
"""Await and log tasks that take a long time."""
|
||||
# pylint: disable=no-self-use
|
||||
wait_time = 0
|
||||
while pending:
|
||||
_, pending = await asyncio.wait(pending, timeout=BLOCK_LOG_TIMEOUT)
|
||||
|
|
|
@ -394,7 +394,6 @@ class OAuth2AuthorizeCallbackView(http.HomeAssistantView):
|
|||
|
||||
async def get(self, request: web.Request) -> web.Response:
|
||||
"""Receive authorization code."""
|
||||
# pylint: disable=no-self-use
|
||||
if "code" not in request.query or "state" not in request.query:
|
||||
return web.Response(
|
||||
text=f"Missing code or state parameter in {request.url}"
|
||||
|
|
|
@ -22,7 +22,6 @@ class _BaseFlowManagerView(HomeAssistantView):
|
|||
"""Initialize the flow manager index view."""
|
||||
self._flow_mgr = flow_mgr
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def _prepare_result_json(
|
||||
self, result: data_entry_flow.FlowResult
|
||||
) -> data_entry_flow.FlowResult:
|
||||
|
|
|
@ -417,7 +417,7 @@ class Template:
|
|||
|
||||
return self._parse_result(render_result)
|
||||
|
||||
def _parse_result(self, render_result: str) -> Any: # pylint: disable=no-self-use
|
||||
def _parse_result(self, render_result: str) -> Any:
|
||||
"""Parse the result."""
|
||||
try:
|
||||
result = literal_eval(render_result)
|
||||
|
|
|
@ -85,6 +85,7 @@ good-names = [
|
|||
# too-many-ancestors - it's too strict.
|
||||
# wrong-import-order - isort guards this
|
||||
# consider-using-f-string - str.format sometimes more readable
|
||||
# no-self-use - little added value with too many false-positives
|
||||
# ---
|
||||
# Enable once current issues are fixed:
|
||||
# consider-using-namedtuple-or-dataclass (Pylint CodeStyle extension)
|
||||
|
@ -111,6 +112,7 @@ disable = [
|
|||
"unused-argument",
|
||||
"wrong-import-order",
|
||||
"consider-using-f-string",
|
||||
"no-self-use",
|
||||
"consider-using-namedtuple-or-dataclass",
|
||||
"consider-using-assignment-expr",
|
||||
]
|
||||
|
|
|
@ -14,7 +14,7 @@ class MockAioSession:
|
|||
self.publish = AsyncMock()
|
||||
self.send_message = AsyncMock()
|
||||
|
||||
def create_client(self, *args, **kwargs): # pylint: disable=no-self-use
|
||||
def create_client(self, *args, **kwargs):
|
||||
"""Create a mocked client."""
|
||||
return MagicMock(
|
||||
__aenter__=AsyncMock(
|
||||
|
|
|
@ -232,7 +232,6 @@ def test_process_custom_logbook_entries(hass_):
|
|||
assert_entry(entries[0], name=name, message=message, entity_id=entity_id)
|
||||
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def assert_entry(
|
||||
entry, when=None, name=None, message=None, domain=None, entity_id=None
|
||||
):
|
||||
|
@ -261,7 +260,6 @@ def create_state_changed_event(
|
|||
)
|
||||
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def create_state_changed_event_from_old_new(
|
||||
entity_id, event_time_fired, old_state, new_state
|
||||
):
|
||||
|
|
|
@ -36,7 +36,7 @@ class PilightDaemonSim:
|
|||
def __init__(self, host, port):
|
||||
"""Init pilight client, ignore parameters."""
|
||||
|
||||
def send_code(self, call): # pylint: disable=no-self-use
|
||||
def send_code(self, call):
|
||||
"""Handle pilight.send service callback."""
|
||||
_LOGGER.error("PilightDaemonSim payload: %s", call)
|
||||
|
||||
|
@ -51,7 +51,7 @@ class PilightDaemonSim:
|
|||
self.callback(self.test_message)
|
||||
self.called = True
|
||||
|
||||
def stop(self): # pylint: disable=no-self-use
|
||||
def stop(self):
|
||||
"""Handle homeassistant.stop callback."""
|
||||
_LOGGER.error("PilightDaemonSim stop")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue