Skip to content

Commit

Permalink
Have pylint warn when user visible log messages do not start with cap…
Browse files Browse the repository at this point in the history
…ital letter or end with a period (home-assistant#48064)

Co-authored-by: Martin Hjelmare <[email protected]>
  • Loading branch information
bdraco and MartinHjelmare authored Mar 19, 2021
1 parent 3742f17 commit c820dd4
Show file tree
Hide file tree
Showing 107 changed files with 243 additions and 157 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/abode/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async def async_step_reauth_confirm(self, user_input=None):
async def async_step_import(self, import_config):
"""Import a config entry from configuration.yaml."""
if self._async_current_entries():
LOGGER.warning("Already configured. Only a single configuration possible.")
LOGGER.warning("Already configured; Only a single configuration possible")
return self.async_abort(reason="single_instance_allowed")

self._polling = import_config.get(CONF_POLLING, False)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/actiontec/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, config):
self.last_results = []
data = self.get_actiontec_data()
self.success_init = data is not None
_LOGGER.info("canner initialized")
_LOGGER.info("Scanner initialized")

def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/aemet/weather_update_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def format_condition(condition: str) -> str:
for key, value in CONDITIONS_MAP.items():
if condition in value:
return key
_LOGGER.error('condition "%s" not found in CONDITIONS_MAP', condition)
_LOGGER.error('Condition "%s" not found in CONDITIONS_MAP', condition)
return condition


Expand Down Expand Up @@ -175,14 +175,14 @@ def _get_weather_town(self):
)
if self._town:
_LOGGER.debug(
"town found for coordinates [%s, %s]: %s",
"Town found for coordinates [%s, %s]: %s",
self._latitude,
self._longitude,
self._town,
)
if not self._town:
_LOGGER.error(
"town not found for coordinates [%s, %s]",
"Town not found for coordinates [%s, %s]",
self._latitude,
self._longitude,
)
Expand All @@ -197,15 +197,15 @@ def _get_weather_and_forecast(self):
daily = self._aemet.get_specific_forecast_town_daily(self._town[AEMET_ATTR_ID])
if not daily:
_LOGGER.error(
'error fetching daily data for town "%s"', self._town[AEMET_ATTR_ID]
'Error fetching daily data for town "%s"', self._town[AEMET_ATTR_ID]
)

hourly = self._aemet.get_specific_forecast_town_hourly(
self._town[AEMET_ATTR_ID]
)
if not hourly:
_LOGGER.error(
'error fetching hourly data for town "%s"', self._town[AEMET_ATTR_ID]
'Error fetching hourly data for town "%s"', self._town[AEMET_ATTR_ID]
)

station = None
Expand All @@ -215,7 +215,7 @@ def _get_weather_and_forecast(self):
)
if not station:
_LOGGER.error(
'error fetching data for station "%s"',
'Error fetching data for station "%s"',
self._station[AEMET_ATTR_IDEMA],
)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/amcrest/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async def async_camera_image(self):
# and before initiating shapshot.
while self._snapshot_task:
self._check_snapshot_ok()
_LOGGER.debug("Waiting for previous snapshot from %s ...", self._name)
_LOGGER.debug("Waiting for previous snapshot from %s", self._name)
await self._snapshot_task
self._check_snapshot_ok()
# Run snapshot command in separate Task that can't be cancelled so
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/awair/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Import Awair configuration from YAML."""
LOGGER.warning(
"Loading Awair via platform setup is deprecated. Please remove it from your configuration."
"Loading Awair via platform setup is deprecated; Please remove it from your configuration"
)
hass.async_create_task(
hass.config_entries.flow.async_init(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/axis/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ async def get_device(hass, host, port, username, password):
return device

except axis.Unauthorized as err:
LOGGER.warning("Connected to device at %s but not registered.", host)
LOGGER.warning("Connected to device at %s but not registered", host)
raise AuthenticationRequired from err

except (asyncio.TimeoutError, axis.RequestError) as err:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/azure_devops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def async_update(self) -> None:
else:
if self._available:
_LOGGER.debug(
"An error occurred while updating Azure DevOps sensor.",
"An error occurred while updating Azure DevOps sensor",
exc_info=True,
)
self._available = False
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bbox/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _update_info(self):
Returns boolean if scanning successful.
"""
_LOGGER.info("Scanning...")
_LOGGER.info("Scanning")

box = pybbox.Bbox(ip=self.host)
result = box.get_all_connected_devices()
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/bloomsky/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, api_key, is_metric):
self._endpoint_argument = "unit=intl" if is_metric else ""
self.devices = {}
self.is_metric = is_metric
_LOGGER.debug("Initial BloomSky device load...")
_LOGGER.debug("Initial BloomSky device load")
self.refresh_devices()

@Throttle(MIN_TIME_BETWEEN_UPDATES)
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/buienradar/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _load_data(self, data):
try:
condition = data.get(FORECAST)[fcday].get(CONDITION)
except IndexError:
_LOGGER.warning("No forecast for fcday=%s...", fcday)
_LOGGER.warning("No forecast for fcday=%s", fcday)
return False

if condition:
Expand Down Expand Up @@ -339,15 +339,15 @@ def _load_data(self, data):
self._state = round(self._state * 3.6, 1)
return True
except IndexError:
_LOGGER.warning("No forecast for fcday=%s...", fcday)
_LOGGER.warning("No forecast for fcday=%s", fcday)
return False

# update all other sensors
try:
self._state = data.get(FORECAST)[fcday].get(self.type[:-3])
return True
except IndexError:
_LOGGER.warning("No forecast for fcday=%s...", fcday)
_LOGGER.warning("No forecast for fcday=%s", fcday)
return False

if self.type == SYMBOL or self.type.startswith(CONDITION):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/buienradar/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def schedule_update(self, minute=1):

async def get_data(self, url):
"""Load data from specified url."""
_LOGGER.debug("Calling url: %s...", url)
_LOGGER.debug("Calling url: %s", url)
result = {SUCCESS: False, MESSAGE: None}
resp = None
try:
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/cisco_ios/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, config):
self.last_results = {}

self.success_init = self._update_info()
_LOGGER.info("cisco_ios scanner initialized")
_LOGGER.info("Initialized cisco_ios scanner")

def get_device_name(self, device):
"""Get the firmware doesn't save the name of the wireless device."""
Expand Down Expand Up @@ -131,8 +131,7 @@ def _get_arp_data(self):

return devices_result.decode("utf-8")
except pxssh.ExceptionPxssh as px_e:
_LOGGER.error("pxssh failed on login")
_LOGGER.error(px_e)
_LOGGER.error("Failed to login via pxssh: %s", px_e)

return None

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/decora/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def wrapper_retry(device, *args, **kwargs):
return method(device, *args, **kwargs)
except (decora.decoraException, AttributeError, BTLEException):
_LOGGER.warning(
"Decora connect error for device %s. Reconnecting...",
"Decora connect error for device %s. Reconnecting",
device.name,
)
# pylint: disable=protected-access
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/downloader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def do_download():

if req.status_code != HTTP_OK:
_LOGGER.warning(
"downloading '%s' failed, status_code=%d", url, req.status_code
"Downloading '%s' failed, status_code=%d", url, req.status_code
)
hass.bus.fire(
f"{DOMAIN}_{DOWNLOAD_FAILED_EVENT}",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/duckdns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def _update_duckdns(session, domain, token, *, txt=_SENTINEL, clear=False)
def async_track_time_interval_backoff(hass, action, intervals) -> CALLBACK_TYPE:
"""Add a listener that fires repetitively at every timedelta interval."""
if not iscoroutinefunction:
_LOGGER.error("action needs to be a coroutine and return True/False")
_LOGGER.error("Action needs to be a coroutine and return True/False")
return

if not isinstance(intervals, (list, tuple)):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/eddystone_temperature/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def process_packet(self, namespace, instance, temperature):
def stop(self):
"""Signal runner to stop and join thread."""
if self.scanning:
_LOGGER.debug("Stopping...")
_LOGGER.debug("Stopping")
self.scanner.stop()
_LOGGER.debug("Stopped")
self.scanning = False
Expand Down
8 changes: 3 additions & 5 deletions homeassistant/components/envisalink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ def login_fail_callback(data):
@callback
def connection_fail_callback(data):
"""Network failure callback."""
_LOGGER.error(
"Could not establish a connection with the Envisalink- retrying..."
)
_LOGGER.error("Could not establish a connection with the Envisalink- retrying")
if not sync_connect.done():
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_envisalink)
sync_connect.set_result(True)
Expand All @@ -162,13 +160,13 @@ def connection_success_callback(data):
@callback
def zones_updated_callback(data):
"""Handle zone timer updates."""
_LOGGER.debug("Envisalink sent a zone update event. Updating zones...")
_LOGGER.debug("Envisalink sent a zone update event. Updating zones")
async_dispatcher_send(hass, SIGNAL_ZONE_UPDATE, data)

@callback
def alarm_data_updated_callback(data):
"""Handle non-alarm based info updates."""
_LOGGER.debug("Envisalink sent new alarm info. Updating alarms...")
_LOGGER.debug("Envisalink sent new alarm info. Updating alarms")
async_dispatcher_send(hass, SIGNAL_KEYPAD_UPDATE, data)

@callback
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def set_speed(self, speed: str) -> None:
async def async_set_speed_deprecated(self, speed: str):
"""Set the speed of the fan."""
_LOGGER.warning(
"fan.set_speed is deprecated, use fan.set_percentage or fan.set_preset_mode instead."
"The fan.set_speed service is deprecated, use fan.set_percentage or fan.set_preset_mode instead"
)
await self.async_set_speed(speed)

Expand Down Expand Up @@ -368,7 +368,7 @@ async def async_turn_on_compat(
percentage = None
elif speed is not None:
_LOGGER.warning(
"Calling fan.turn_on with the speed argument is deprecated, use percentage or preset_mode instead."
"Calling fan.turn_on with the speed argument is deprecated, use percentage or preset_mode instead"
)
if speed in self.preset_modes:
preset_mode = speed
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fints/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):

for account in balance_accounts:
if config[CONF_ACCOUNTS] and account.iban not in account_config:
_LOGGER.info("skipping account %s for bank %s", account.iban, fints_name)
_LOGGER.info("Skipping account %s for bank %s", account.iban, fints_name)
continue

account_name = account_config.get(account.iban)
Expand All @@ -87,7 +87,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
for account in holdings_accounts:
if config[CONF_HOLDINGS] and account.accountnumber not in holdings_config:
_LOGGER.info(
"skipping holdings %s for bank %s", account.accountnumber, fints_name
"Skipping holdings %s for bank %s", account.accountnumber, fints_name
)
continue

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/folder/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
path = config.get(CONF_FOLDER_PATHS)

if not hass.config.is_allowed_path(path):
_LOGGER.error("folder %s is not valid or allowed", path)
_LOGGER.error("Folder %s is not valid or allowed", path)
else:
folder = Folder(path, config.get(CONF_FILTER))
add_entities([folder], True)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/folder_watcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def setup(hass, config):
path = watcher[CONF_FOLDER]
patterns = watcher[CONF_PATTERNS]
if not hass.config.is_allowed_path(path):
_LOGGER.error("folder %s is not valid or allowed", path)
_LOGGER.error("Folder %s is not valid or allowed", path)
return False
Watcher(path, patterns, hass)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/foscam/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up a Foscam IP Camera."""
LOGGER.warning(
"Loading foscam via platform config is deprecated, it will be automatically imported. Please remove it afterwards."
"Loading foscam via platform config is deprecated, it will be automatically imported; Please remove it afterwards"
)

config_new = {
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/foscam/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ async def async_step_import(self, import_config):
return await self._validate_and_create(import_config)

except CannotConnect:
LOGGER.error("Error importing foscam platform config: cannot connect.")
LOGGER.error("Error importing foscam platform config: cannot connect")
return self.async_abort(reason="cannot_connect")

except InvalidAuth:
LOGGER.error("Error importing foscam platform config: invalid auth.")
LOGGER.error("Error importing foscam platform config: invalid auth")
return self.async_abort(reason="invalid_auth")

except InvalidResponse:
LOGGER.exception(
"Error importing foscam platform config: invalid response from camera."
"Error importing foscam platform config: invalid response from camera"
)
return self.async_abort(reason="invalid_response")

Expand All @@ -145,7 +145,7 @@ async def async_step_import(self, import_config):

except Exception: # pylint: disable=broad-except
LOGGER.exception(
"Error importing foscam platform config: unexpected exception."
"Error importing foscam platform config: unexpected exception"
)
return self.async_abort(reason="unknown")

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/gogogate2/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ async def async_setup_platform(
) -> None:
"""Convert old style file configs to new style configs."""
_LOGGER.warning(
"Loading gogogate2 via platform config is deprecated. The configuration"
" has been migrated to a config entry and can be safely removed."
"Loading gogogate2 via platform config is deprecated; The configuration"
" has been migrated to a config entry and can be safely removed"
)
hass.async_create_task(
hass.config_entries.flow.async_init(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/growatt_server/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
sensors = STORAGE_SENSOR_TYPES
else:
_LOGGER.debug(
"Device type %s was found but is not supported right now.",
"Device type %s was found but is not supported right now",
device["deviceType"],
)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/gstreamer/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def set_volume_level(self, volume):
def play_media(self, media_type, media_id, **kwargs):
"""Play media."""
if media_type != MEDIA_TYPE_MUSIC:
_LOGGER.error("invalid media type")
_LOGGER.error("Invalid media type")
return
self._player.queue(media_id)

Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/habitica/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ async def update(self):
except ClientResponseError as error:
if error.status == HTTP_TOO_MANY_REQUESTS:
_LOGGER.warning(
"Sensor data update for %s has too many API requests."
" Skipping the update.",
"Sensor data update for %s has too many API requests;"
" Skipping the update",
DOMAIN,
)
else:
Expand All @@ -113,8 +113,8 @@ async def update(self):
except ClientResponseError as error:
if error.status == HTTP_TOO_MANY_REQUESTS:
_LOGGER.warning(
"Sensor data update for %s has too many API requests."
" Skipping the update.",
"Sensor data update for %s has too many API requests;"
" Skipping the update",
DOMAIN,
)
else:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hangouts/hangouts_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _on_connect(self):
async def _on_disconnect(self):
"""Handle disconnecting."""
if self._connected:
_LOGGER.debug("Connection lost! Reconnect...")
_LOGGER.debug("Connection lost! Reconnect")
await self.async_connect()
else:
dispatcher.async_dispatcher_send(self.hass, EVENT_HANGOUTS_DISCONNECTED)
Expand Down
Loading

0 comments on commit c820dd4

Please sign in to comment.