Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cloneofghosts committed Jun 16, 2024
1 parent 4bbf015 commit 5dbdb50
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 37 deletions.
4 changes: 2 additions & 2 deletions custom_components/pirateweather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# _LOGGER.warning(forecast_days)
if isinstance(forecast_days, str):
# If empty, set to none
if forecast_days == "" or forecast_days == "None":
if forecast_days in {"", "None"}:
forecast_days = None
else:
if forecast_days[0] == "[":
Expand All @@ -72,7 +72,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

if isinstance(forecast_hours, str):
# If empty, set to none
if forecast_hours == "" or forecast_hours == "None":
if forecast_hours in {"", "None"}:
forecast_hours = None
else:
if forecast_hours[0] == "[":
Expand Down
6 changes: 2 additions & 4 deletions custom_components/pirateweather/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import aiohttp
import homeassistant.helpers.config_validation as cv
from httpx import HTTPError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import (
Expand All @@ -18,6 +17,7 @@
CONF_SCAN_INTERVAL,
)
from homeassistant.core import callback
from httpx import HTTPError

from .const import (
ALL_CONDITIONS,
Expand Down Expand Up @@ -298,6 +298,4 @@ async def _is_pw_api_online(hass, api_key, lat, lon):
aiohttp.ClientSession(raise_for_status=False) as session,
session.get(forecastString) as resp,
):
status = resp.status

return status
return resp.status
25 changes: 2 additions & 23 deletions custom_components/pirateweather/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,6 @@ def __init__(
"""Initialize the sensor."""
self.client_name = name

description = description
self.entity_description = description
self.description = description

Expand Down Expand Up @@ -976,10 +975,9 @@ def extra_state_attributes(self):
if self.type == "alerts":
extraATTR = self._alerts
extraATTR[ATTR_ATTRIBUTION] = ATTRIBUTION

return extraATTR
else:
return {ATTR_ATTRIBUTION: ATTRIBUTION}
extraATTR = {ATTR_ATTRIBUTION: ATTRIBUTION}
return extraATTR

@property
def native_value(self) -> StateType:
Expand Down Expand Up @@ -1125,25 +1123,6 @@ def get_state(self, data):
]:
state = state * 3.6

if self.type in [
"uv_index",
]:
if state < 0 or state > 20:
_LOGGER.warning(
"UV Index is reporting %s which is outside the expected range! Setting UV Index to -1! Please report this issue to https://github.com/Pirate-Weather/pirateweather if not already reported.",
state,
)
state = -1
if self.type in [
"cloud_cover",
]:
if state > 100:
_LOGGER.warning(
"Cloud cover is reporting %s which is above 100%! Please report this issue to https://github.com/Pirate-Weather/pirateweather if not already reported.",
state,
)
state = 100

if self.type in [
"dew_point",
"temperature",
Expand Down
15 changes: 7 additions & 8 deletions custom_components/pirateweather/weather_update_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import logging
from http.client import HTTPException

import aiohttp
import async_timeout
Expand Down Expand Up @@ -43,13 +44,12 @@ async def _async_update_data(self):
try:
data = await self._get_pw_weather()
_LOGGER.debug(
"Pirate Weather data update for "
+ str(self.latitude)
+ ","
+ str(self.longitude)
"Pirate Weather data update for %s, %s",
str(self.latitude),

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (private)
as clear text.
str(self.longitude),

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (private)
as clear text.
)
except Exception as err:
raise UpdateFailed(f"Error communicating with API: {err}")
except HTTPException as err:
raise UpdateFailed(f"Error communicating with API: {err}") from err
return data

async def _get_pw_weather(self):
Expand All @@ -76,5 +76,4 @@ async def _get_pw_weather(self):
headers = resp.headers
status = resp.raise_for_status()

data = Forecast(jsonText, status, headers)
return data
return Forecast(jsonText, status, headers)

0 comments on commit 5dbdb50

Please sign in to comment.