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

Disable no-self-use [pylint] #70641

Merged
merged 2 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 1 addition & 3 deletions homeassistant/auth/providers/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ def validate_login(self, username: str, password: str) -> None:
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))

Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/alexa/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/alexa/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ async def async_disable_proactive_mode(self):
@callback
def should_expose(self, entity_id):
"""If an entity should be exposed."""
# pylint: disable=no-self-use
return False

@callback
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/alexa/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/ambiclimate/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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])
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ async def post(self, request):

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
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/auth/login_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/awair/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ async def _async_update_data(self) -> Any | None:

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)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/backup/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ async def stream_source(self) -> str | None:
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:
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/config/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/conversation/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ def attribution(self):

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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/diagnostics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/doorbird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/emulated_hue/upnp.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def datagram_received(self, data, addr):
_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)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/google_assistant/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def should_expose(self, state) -> bool:

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):
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/homekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("-")
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/homematicip_cloud/hap.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ async def async_register(self):

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)
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/huisbaasje/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ async def _validate_input(self, user_input):

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]

Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/hyperion/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ def _get_priority_entry_that_dictates_state(self) -> dict[str, Any] | None:
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
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/lovelace/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ async def async_load(self, force):

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
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/media_player/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ async def async_get_browse_image(

Must be implemented by integration.
"""
# pylint: disable=no-self-use
return None, None

@property
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/components/media_source/local_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ async def post(self, request: web.Request) -> web.Response:
{"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")
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/numato/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def prepare_gpio(event):
return True


# pylint: disable=no-self-use
class NumatoAPI:
"""Home-Assistant specific API for numato device access."""

Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/plex/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/plex/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions homeassistant/components/python_script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ def __init__(self, _getattr_):

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")


Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/roomba/irobot_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async def async_added_to_hass(self):
"""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

Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/smarttub/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ async def async_update_data(self):
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(),
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/sms/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def sms_read_messages(self, state_machine, force=False):

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 ...
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/webhook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/websocket_api/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/wirelesstag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def updated_state_value(self):
"""
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}"
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/withings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ async def _do_retry(self, func, attempts=3) -> Any:

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)
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/xmpp/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ def send_text_message(self):
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:
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/zwave_js/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def __init__(self, client: ZwaveClient, node: ZwaveNode) -> None:

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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def resolve_data(self, value: ZwaveValue) -> Any:
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]:
Expand All @@ -249,7 +248,6 @@ def values_to_watch(self, resolved_data: Any) -> Iterable[ZwaveValue]:

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]:
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/zwave_js/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ def __init__(

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"
Expand Down
4 changes: 0 additions & 4 deletions homeassistant/components/zwave_js/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ def validate_entities(val: dict[str, Any]) -> dict[str, Any]:

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)
Expand Down Expand Up @@ -356,7 +355,6 @@ async def async_bulk_set_partial_config_parameters(
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]
Expand Down Expand Up @@ -391,7 +389,6 @@ async def async_poll_value(self, service: ServiceCall) -> None:

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]
Expand Down Expand Up @@ -503,7 +500,6 @@ async def async_multicast_set_value(self, service: ServiceCall) -> None:

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 "
Expand Down
Loading