Skip to content

Commit

Permalink
Update pylint to 2.11.1 (home-assistant#56364)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Sep 18, 2021
1 parent 476d04e commit 48bada5
Show file tree
Hide file tree
Showing 49 changed files with 77 additions and 43 deletions.
1 change: 1 addition & 0 deletions homeassistant/components/ambiclimate/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class AmbiclimateAuthCallbackView(HomeAssistantView):

async def get(self, request: web.Request) -> str:
"""Receive authorization token."""
# pylint: disable=no-self-use
code = request.query.get("code")
if code is None:
return "No code"
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/androidtv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ def _adb_decorator(func):
@functools.wraps(func)
async def _adb_exception_catcher(self, *args, **kwargs):
"""Call an ADB-related method and catch exceptions."""
# pylint: disable=protected-access
if not self.available and not override_available:
return None

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ 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 @@ -414,6 +415,7 @@ 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
2 changes: 2 additions & 0 deletions homeassistant/components/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ 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
# if the token has been revoked successfully or if the client
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/auth/login_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def __init__(self, flow_mgr, store_result):

async def get(self, request):
"""Do not allow index of flows in progress."""
# pylint: disable=no-self-use
return web.Response(status=HTTP_METHOD_NOT_ALLOWED)

@RequestDataValidator(
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/awair/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ 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/blueprint/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def _create_file(self, blueprint: Blueprint, blueprint_path: str) -> None:
raise FileAlreadyExists(self.domain, blueprint_path)

path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(blueprint.yaml())
path.write_text(blueprint.yaml(), encoding="utf-8")

async def async_add_blueprint(
self, blueprint: Blueprint, blueprint_path: str
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ async def create_stream(self) -> Stream | None:

async def stream_source(self) -> str | None:
"""Return the source of the stream."""
# pylint: disable=no-self-use
return None

def camera_image(
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/config/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ 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: 2 additions & 0 deletions homeassistant/components/conversation/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ 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
5 changes: 1 addition & 4 deletions homeassistant/components/denonavr/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,7 @@ def media_content_id(self):
@property
def media_content_type(self):
"""Content type of current playing media."""
if (
self._receiver.state == STATE_PLAYING
or self._receiver.state == STATE_PAUSED
):
if self._receiver.state in (STATE_PLAYING, STATE_PAUSED):
return MEDIA_TYPE_MUSIC
return MEDIA_TYPE_CHANNEL

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/doorbird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ 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/ecobee/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def set_temp_hold(self, temp):
heatCoolMinDelta property.
https://www.ecobee.com/home/developer/api/examples/ex5.shtml
"""
if self.hvac_mode == HVAC_MODE_HEAT or self.hvac_mode == HVAC_MODE_COOL:
if self.hvac_mode in (HVAC_MODE_HEAT, HVAC_MODE_COOL):
heat_temp = temp
cool_temp = temp
else:
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/elkm1/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def current_temperature(self):
@property
def target_temperature(self):
"""Return the temperature we are trying to reach."""
if (self._element.mode == ThermostatMode.HEAT.value) or (
self._element.mode == ThermostatMode.EMERGENCY_HEAT.value
if self._element.mode in (
ThermostatMode.HEAT.value,
ThermostatMode.EMERGENCY_HEAT.value,
):
return self._element.heat_setpoint
if self._element.mode == ThermostatMode.COOL.value:
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/esphome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ def esphome_state_property(func: _PropT) -> _PropT:
@property # type: ignore[misc]
@functools.wraps(func)
def _wrapper(self): # type: ignore[no-untyped-def]
# pylint: disable=protected-access
if not self._has_state:
return None
val = func(self)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/fibaro/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(self, fibaro_device):
"value" in device.properties
or "heatingThermostatSetpoint" in device.properties
)
and (device.properties.unit == "C" or device.properties.unit == "F")
and device.properties.unit in ("C", "F")
):
self._temp_sensor_device = FibaroDevice(device)
tempunit = device.properties.unit
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/fritzbox/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
@property
def hvac_mode(self) -> str:
"""Return the current operation mode."""
if (
self.device.target_temperature == OFF_REPORT_SET_TEMPERATURE
or self.device.target_temperature == OFF_API_TEMPERATURE
if self.device.target_temperature in (
OFF_REPORT_SET_TEMPERATURE,
OFF_API_TEMPERATURE,
):
return HVAC_MODE_OFF

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/homekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ class HomeKitPairingQRView(HomeAssistantView):

async def get(self, request):
"""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: 1 addition & 0 deletions homeassistant/components/homematicip_cloud/hap.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ 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: 1 addition & 0 deletions homeassistant/components/huisbaasje/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ 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: 1 addition & 0 deletions homeassistant/components/limitlessled/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def decorator(function):

def wrapper(self, **kwargs):
"""Wrap a group state change."""
# pylint: disable=protected-access

pipeline = Pipeline()
transition_time = DEFAULT_TRANSITION
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/lovelace/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ 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
7 changes: 2 additions & 5 deletions homeassistant/components/manual/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def _validate_code(self, code, state):
@property
def extra_state_attributes(self):
"""Return the state attributes."""
if self.state == STATE_ALARM_PENDING or self.state == STATE_ALARM_ARMING:
if self.state in (STATE_ALARM_PENDING, STATE_ALARM_ARMING):
return {
ATTR_PREVIOUS_STATE: self._previous_state,
ATTR_NEXT_STATE: self._state,
Expand All @@ -430,10 +430,7 @@ async def async_added_to_hass(self):
state = await self.async_get_last_state()
if state:
if (
(
state.state == STATE_ALARM_PENDING
or state.state == STATE_ALARM_ARMING
)
state.state in (STATE_ALARM_PENDING, STATE_ALARM_ARMING)
and hasattr(state, "attributes")
and state.attributes[ATTR_PREVIOUS_STATE]
):
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/media_player/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ async def async_get_browse_image(
Must be implemented by integration.
"""
# pylint: disable=no-self-use
return None, None

@property
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/melcloud/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def _create_client(
self.hass.helpers.aiohttp_client.async_get_clientsession(),
)
except ClientResponseError as err:
if err.status == HTTP_UNAUTHORIZED or err.status == HTTP_FORBIDDEN:
if err.status in (HTTP_UNAUTHORIZED, HTTP_FORBIDDEN):
return self.async_abort(reason="invalid_auth")
return self.async_abort(reason="cannot_connect")
except (asyncio.TimeoutError, ClientError):
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/nest/camera_sdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ async def _async_fetch_active_event_image(
self, trait: EventImageGenerator
) -> bytes | None:
"""Return image bytes for an active event."""
# pylint: disable=no-self-use
try:
event_image = await trait.generate_active_event_image()
except GoogleNestException as err:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ async def _async_update_data(self):

async def _get_owm_weather(self):
"""Poll weather data from OWM."""
if (
self._forecast_mode == FORECAST_MODE_ONECALL_HOURLY
or self._forecast_mode == FORECAST_MODE_ONECALL_DAILY
if self._forecast_mode in (
FORECAST_MODE_ONECALL_HOURLY,
FORECAST_MODE_ONECALL_DAILY,
):
weather = await self.hass.async_add_executor_job(
self._owm_client.one_call, self._latitude, self._longitude
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/ozw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ async def async_handle_node_update(hass: HomeAssistant, node: OZWNode):
return
# update device in device registry with (updated) info
for item in dev_registry.devices.values():
if item.id != device.id and item.via_device_id != device.id:
if device.id not in (item.id, item.via_device_id):
continue
dev_name = create_device_name(node)
dev_registry.async_update_device(
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/plex/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ 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
6 changes: 5 additions & 1 deletion homeassistant/components/sensehat/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@

def get_cpu_temp():
"""Get CPU temperature."""
t_cpu = Path("/sys/class/thermal/thermal_zone0/temp").read_text().strip()
t_cpu = (
Path("/sys/class/thermal/thermal_zone0/temp")
.read_text(encoding="utf-8")
.strip()
)
return float(t_cpu) * 0.001


Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/smarttub/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ 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
5 changes: 1 addition & 4 deletions homeassistant/components/sonos/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,7 @@ def _restore_groups(
for speaker in (s for s in speakers if s.snapshot_group):
assert speaker.snapshot_group is not None
if speaker.snapshot_group[0] == speaker:
if (
speaker.snapshot_group != speaker.sonos_group
and speaker.snapshot_group != [speaker]
):
if speaker.snapshot_group not in (speaker.sonos_group, [speaker]):
speaker.join(speaker.snapshot_group)
groups.append(speaker.snapshot_group.copy())

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/spotify/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def spotify_exception_handler(func):
"""

def wrapper(self, *args, **kwargs):
# pylint: disable=protected-access
try:
result = func(self, *args, **kwargs)
self._attr_available = True
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/stream/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def render_hls(
# Preload hints help save round trips by informing the client about the next part.
# The next part will usually be in this segment but will be first part of the next
# segment if this segment is already complete.
# pylint: disable=undefined-loop-variable
if self.complete: # Next part belongs to next segment
sequence = self.sequence + 1
part_num = 0
Expand Down
8 changes: 3 additions & 5 deletions homeassistant/components/tank_utility/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ def get_data(self):
try:
data = tank_monitor.get_device_data(self._token, self.device)
except requests.exceptions.HTTPError as http_error:
if (
http_error.response.status_code
== requests.codes.unauthorized # pylint: disable=no-member
or http_error.response.status_code
== requests.codes.bad_request # pylint: disable=no-member
if http_error.response.status_code in (
requests.codes.unauthorized, # pylint: disable=no-member
requests.codes.bad_request, # pylint: disable=no-member
):
_LOGGER.info("Getting new token")
self._token = auth.get_token(self._email, self._password, force=True)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/timer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def async_start(self, duration: timedelta):
newduration = duration

event = EVENT_TIMER_STARTED
if self._state == STATUS_ACTIVE or self._state == STATUS_PAUSED:
if self._state in (STATUS_ACTIVE, STATUS_PAUSED):
event = EVENT_TIMER_RESTARTED

self._state = STATUS_ACTIVE
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/webhook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class WebhookView(HomeAssistantView):

async def _handle(self, request: Request, webhook_id):
"""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
4 changes: 1 addition & 3 deletions homeassistant/components/webostv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ def supported_features(self):
"""Flag media player features that are supported."""
supported = SUPPORT_WEBOSTV

if (self._client.sound_output == "external_arc") or (
self._client.sound_output == "external_speaker"
):
if self._client.sound_output in ("external_arc", "external_speaker"):
supported = supported | SUPPORT_WEBOSTV_VOLUME
elif self._client.sound_output != "lineout":
supported = supported | SUPPORT_WEBOSTV_VOLUME | SUPPORT_VOLUME_SET
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/websocket_api/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ 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
2 changes: 1 addition & 1 deletion homeassistant/components/whirlpool/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from homeassistant import config_entries, core, exceptions
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME

from .const import DOMAIN # pylint: disable=unused-import
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit 48bada5

Please sign in to comment.