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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pylint to 2.9.5 #53496

Merged
merged 6 commits into from
Jul 26, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/auth/providers/command_line.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Auth provider that validates credentials via an external command."""
from __future__ import annotations

import asyncio.subprocess
import asyncio
import collections
from collections.abc import Mapping
import logging
Expand Down Expand Up @@ -64,7 +64,7 @@ async def async_validate_login(self, username: str, password: str) -> None:
"""Validate a username and password."""
env = {"username": username, "password": password}
try:
process = await asyncio.subprocess.create_subprocess_exec( # pylint: disable=no-member
process = await asyncio.create_subprocess_exec(
self.config[CONF_COMMAND],
*self.config[CONF_ARGS],
env=env,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/androidtv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,13 @@ async def _adb_exception_catcher(self, *args, **kwargs):
err,
)
await self.aftv.adb_close()
self._attr_available = False # pylint: disable=protected-access
self._attr_available = False
return None
except Exception:
# An unforeseen exception occurred. Close the ADB connection so that
# it doesn't happen over and over again, then raise the exception.
await self.aftv.adb_close()
self._attr_available = False # pylint: disable=protected-access
self._attr_available = False
raise

return _adb_exception_catcher
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/co2signal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get_data(hass: HomeAssistant, config: dict) -> CO2SignalResponse:

_LOGGER.exception("Unexpected exception")
raise UnknownError from err
except Exception as err: # pylint: disable=broad-except
except Exception as err:
_LOGGER.exception("Unexpected exception")
raise UnknownError from err

Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/homekit/img_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def instance():

def __init__(self):
"""Try to create TurboJPEG only once."""
# pylint: disable=unused-private-member
# https://github.com/PyCQA/pylint/issues/4681
try:
# TurboJPEG checks for libturbojpeg
# when its created, but it imports
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/plugwise/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType):
_version = _properties.get("version", "n/a")
_name = f"{ZEROCONF_MAP.get(_product, _product)} v{_version}"

# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self.context["title_placeholders"] = {
CONF_HOST: self.discovery_info[CONF_HOST],
CONF_NAME: _name,
Expand Down
6 changes: 2 additions & 4 deletions homeassistant/components/shell_command/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ async def async_service_handler(service: ServiceCall) -> None:
if rendered_args == args:
# No template used. default behavior

# pylint: disable=no-member
create_process = asyncio.subprocess.create_subprocess_shell(
create_process = asyncio.create_subprocess_shell(
cmd,
stdin=None,
stdout=asyncio.subprocess.PIPE,
Expand All @@ -72,8 +71,7 @@ async def async_service_handler(service: ServiceCall) -> None:
# (which uses shell=False) for security
shlexed_cmd = [prog] + shlex.split(rendered_args)

# pylint: disable=no-member
create_process = asyncio.subprocess.create_subprocess_exec(
create_process = asyncio.create_subprocess_exec(
*shlexed_cmd,
stdin=None,
stdout=asyncio.subprocess.PIPE,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,14 @@ def create_task(self, target: Awaitable) -> None:
self.loop.call_soon_threadsafe(self.async_create_task, target)

@callback
def async_create_task(self, target: Awaitable) -> asyncio.tasks.Task:
def async_create_task(self, target: Awaitable) -> asyncio.Task:
"""Create a task from within the eventloop.

This method must be run in the event loop.

target: target to call.
"""
task: asyncio.tasks.Task = self.loop.create_task(target)
task: asyncio.Task = self.loop.create_task(target)

if self._track_task:
self._pending_tasks.append(task)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/helpers/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def async_script_wait(entity_id, from_s, to_s):
task.cancel()
unsub()

async def _async_run_long_action(self, long_task: asyncio.tasks.Task) -> None:
async def _async_run_long_action(self, long_task: asyncio.Task) -> None:
"""Run a long task while monitoring for stop request."""

async def async_cancel_long_task() -> None:
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jsonpickle==1.4.1
mock-open==1.4.0
mypy==0.902
pre-commit==2.13.0
pylint==2.9.3
pylint==2.9.5
pipdeptree==1.0.0
pylint-strict-informational==0.1
pytest-aiohttp==0.3.0
Expand Down
15 changes: 3 additions & 12 deletions tests/components/shell_command/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ async def test_config_not_valid_service_names(hass):
)


@patch(
"homeassistant.components.shell_command.asyncio.subprocess"
".create_subprocess_shell"
)
@patch("homeassistant.components.shell_command.asyncio.create_subprocess_shell")
async def test_template_render_no_template(mock_call, hass):
"""Ensure shell_commands without templates get rendered properly."""
mock_call.return_value = mock_process_creator(error=False)
Expand All @@ -84,10 +81,7 @@ async def test_template_render_no_template(mock_call, hass):
assert cmd == "ls /bin"


@patch(
"homeassistant.components.shell_command.asyncio.subprocess"
".create_subprocess_exec"
)
@patch("homeassistant.components.shell_command.asyncio.create_subprocess_exec")
async def test_template_render(mock_call, hass):
"""Ensure shell_commands with templates get rendered properly."""
hass.states.async_set("sensor.test_state", "Works")
Expand All @@ -111,10 +105,7 @@ async def test_template_render(mock_call, hass):
assert ("ls", "/bin", "Works") == cmd


@patch(
"homeassistant.components.shell_command.asyncio.subprocess"
".create_subprocess_shell"
)
@patch("homeassistant.components.shell_command.asyncio.create_subprocess_shell")
@patch("homeassistant.components.shell_command._LOGGER.error")
async def test_subprocess_error(mock_error, mock_call, hass):
"""Test subprocess that returns an error."""
Expand Down