From 46c3495ae06a589bf76c1f6dfe9dee7975ccba79 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 26 Jul 2021 16:17:15 +0200 Subject: [PATCH] Update pylint to 2.9.5 (#53496) --- homeassistant/auth/providers/command_line.py | 4 ++-- .../components/androidtv/media_player.py | 4 ++-- homeassistant/components/co2signal/__init__.py | 2 +- homeassistant/components/homekit/img_util.py | 2 ++ homeassistant/components/plugwise/config_flow.py | 1 - .../components/shell_command/__init__.py | 6 ++---- homeassistant/core.py | 4 ++-- homeassistant/helpers/script.py | 2 +- requirements_test.txt | 2 +- tests/components/shell_command/test_init.py | 15 +++------------ 10 files changed, 16 insertions(+), 26 deletions(-) diff --git a/homeassistant/auth/providers/command_line.py b/homeassistant/auth/providers/command_line.py index 65d553d4eb2..f462ad4be9d 100644 --- a/homeassistant/auth/providers/command_line.py +++ b/homeassistant/auth/providers/command_line.py @@ -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 @@ -64,7 +64,7 @@ class CommandLineAuthProvider(AuthProvider): """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, diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index 7b901e7ab37..98d1ac0ae18 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -376,13 +376,13 @@ def adb_decorator(override_available=False): 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 diff --git a/homeassistant/components/co2signal/__init__.py b/homeassistant/components/co2signal/__init__.py index 734eb9f1ae0..26f41ac2e67 100644 --- a/homeassistant/components/co2signal/__init__.py +++ b/homeassistant/components/co2signal/__init__.py @@ -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 diff --git a/homeassistant/components/homekit/img_util.py b/homeassistant/components/homekit/img_util.py index 860d798f113..7d7a45081a6 100644 --- a/homeassistant/components/homekit/img_util.py +++ b/homeassistant/components/homekit/img_util.py @@ -53,6 +53,8 @@ class TurboJPEGSingleton: 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 diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 5f32aca13a0..450388b6f42 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -117,7 +117,6 @@ class PlugwiseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): _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, diff --git a/homeassistant/components/shell_command/__init__.py b/homeassistant/components/shell_command/__init__.py index 48744b4fea2..a0dfd3388b4 100644 --- a/homeassistant/components/shell_command/__init__.py +++ b/homeassistant/components/shell_command/__init__.py @@ -60,8 +60,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: 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, @@ -72,8 +71,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # (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, diff --git a/homeassistant/core.py b/homeassistant/core.py index 0c2658952ce..aba4483f192 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -382,14 +382,14 @@ class HomeAssistant: 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) diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index addd2ae046d..e5e8ef4fd52 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -504,7 +504,7 @@ class _ScriptRun: 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: diff --git a/requirements_test.txt b/requirements_test.txt index 8b6ab238037..aceec3229a9 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -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 diff --git a/tests/components/shell_command/test_init.py b/tests/components/shell_command/test_init.py index b86fe12516d..196e47351bc 100644 --- a/tests/components/shell_command/test_init.py +++ b/tests/components/shell_command/test_init.py @@ -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) @@ -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") @@ -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."""