mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Update pylint to 2.9.5 (#53496)
This commit is contained in:
parent
af8f594939
commit
46c3495ae0
@ -1,7 +1,7 @@
|
|||||||
"""Auth provider that validates credentials via an external command."""
|
"""Auth provider that validates credentials via an external command."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio.subprocess
|
import asyncio
|
||||||
import collections
|
import collections
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
import logging
|
import logging
|
||||||
@ -64,7 +64,7 @@ class CommandLineAuthProvider(AuthProvider):
|
|||||||
"""Validate a username and password."""
|
"""Validate a username and password."""
|
||||||
env = {"username": username, "password": password}
|
env = {"username": username, "password": password}
|
||||||
try:
|
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_COMMAND],
|
||||||
*self.config[CONF_ARGS],
|
*self.config[CONF_ARGS],
|
||||||
env=env,
|
env=env,
|
||||||
|
@ -376,13 +376,13 @@ def adb_decorator(override_available=False):
|
|||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
await self.aftv.adb_close()
|
await self.aftv.adb_close()
|
||||||
self._attr_available = False # pylint: disable=protected-access
|
self._attr_available = False
|
||||||
return None
|
return None
|
||||||
except Exception:
|
except Exception:
|
||||||
# An unforeseen exception occurred. Close the ADB connection so that
|
# An unforeseen exception occurred. Close the ADB connection so that
|
||||||
# it doesn't happen over and over again, then raise the exception.
|
# it doesn't happen over and over again, then raise the exception.
|
||||||
await self.aftv.adb_close()
|
await self.aftv.adb_close()
|
||||||
self._attr_available = False # pylint: disable=protected-access
|
self._attr_available = False
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return _adb_exception_catcher
|
return _adb_exception_catcher
|
||||||
|
@ -134,7 +134,7 @@ def get_data(hass: HomeAssistant, config: dict) -> CO2SignalResponse:
|
|||||||
|
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
raise UnknownError from err
|
raise UnknownError from err
|
||||||
except Exception as err: # pylint: disable=broad-except
|
except Exception as err:
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
raise UnknownError from err
|
raise UnknownError from err
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ class TurboJPEGSingleton:
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Try to create TurboJPEG only once."""
|
"""Try to create TurboJPEG only once."""
|
||||||
|
# pylint: disable=unused-private-member
|
||||||
|
# https://github.com/PyCQA/pylint/issues/4681
|
||||||
try:
|
try:
|
||||||
# TurboJPEG checks for libturbojpeg
|
# TurboJPEG checks for libturbojpeg
|
||||||
# when its created, but it imports
|
# when its created, but it imports
|
||||||
|
@ -117,7 +117,6 @@ class PlugwiseConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
_version = _properties.get("version", "n/a")
|
_version = _properties.get("version", "n/a")
|
||||||
_name = f"{ZEROCONF_MAP.get(_product, _product)} v{_version}"
|
_name = f"{ZEROCONF_MAP.get(_product, _product)} v{_version}"
|
||||||
|
|
||||||
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
|
|
||||||
self.context["title_placeholders"] = {
|
self.context["title_placeholders"] = {
|
||||||
CONF_HOST: self.discovery_info[CONF_HOST],
|
CONF_HOST: self.discovery_info[CONF_HOST],
|
||||||
CONF_NAME: _name,
|
CONF_NAME: _name,
|
||||||
|
@ -60,8 +60,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
if rendered_args == args:
|
if rendered_args == args:
|
||||||
# No template used. default behavior
|
# No template used. default behavior
|
||||||
|
|
||||||
# pylint: disable=no-member
|
create_process = asyncio.create_subprocess_shell(
|
||||||
create_process = asyncio.subprocess.create_subprocess_shell(
|
|
||||||
cmd,
|
cmd,
|
||||||
stdin=None,
|
stdin=None,
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
@ -72,8 +71,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
# (which uses shell=False) for security
|
# (which uses shell=False) for security
|
||||||
shlexed_cmd = [prog] + shlex.split(rendered_args)
|
shlexed_cmd = [prog] + shlex.split(rendered_args)
|
||||||
|
|
||||||
# pylint: disable=no-member
|
create_process = asyncio.create_subprocess_exec(
|
||||||
create_process = asyncio.subprocess.create_subprocess_exec(
|
|
||||||
*shlexed_cmd,
|
*shlexed_cmd,
|
||||||
stdin=None,
|
stdin=None,
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
@ -382,14 +382,14 @@ class HomeAssistant:
|
|||||||
self.loop.call_soon_threadsafe(self.async_create_task, target)
|
self.loop.call_soon_threadsafe(self.async_create_task, target)
|
||||||
|
|
||||||
@callback
|
@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.
|
"""Create a task from within the eventloop.
|
||||||
|
|
||||||
This method must be run in the event loop.
|
This method must be run in the event loop.
|
||||||
|
|
||||||
target: target to call.
|
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:
|
if self._track_task:
|
||||||
self._pending_tasks.append(task)
|
self._pending_tasks.append(task)
|
||||||
|
@ -504,7 +504,7 @@ class _ScriptRun:
|
|||||||
task.cancel()
|
task.cancel()
|
||||||
unsub()
|
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."""
|
"""Run a long task while monitoring for stop request."""
|
||||||
|
|
||||||
async def async_cancel_long_task() -> None:
|
async def async_cancel_long_task() -> None:
|
||||||
|
@ -10,7 +10,7 @@ jsonpickle==1.4.1
|
|||||||
mock-open==1.4.0
|
mock-open==1.4.0
|
||||||
mypy==0.902
|
mypy==0.902
|
||||||
pre-commit==2.13.0
|
pre-commit==2.13.0
|
||||||
pylint==2.9.3
|
pylint==2.9.5
|
||||||
pipdeptree==1.0.0
|
pipdeptree==1.0.0
|
||||||
pylint-strict-informational==0.1
|
pylint-strict-informational==0.1
|
||||||
pytest-aiohttp==0.3.0
|
pytest-aiohttp==0.3.0
|
||||||
|
@ -61,10 +61,7 @@ async def test_config_not_valid_service_names(hass):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@patch(
|
@patch("homeassistant.components.shell_command.asyncio.create_subprocess_shell")
|
||||||
"homeassistant.components.shell_command.asyncio.subprocess"
|
|
||||||
".create_subprocess_shell"
|
|
||||||
)
|
|
||||||
async def test_template_render_no_template(mock_call, hass):
|
async def test_template_render_no_template(mock_call, hass):
|
||||||
"""Ensure shell_commands without templates get rendered properly."""
|
"""Ensure shell_commands without templates get rendered properly."""
|
||||||
mock_call.return_value = mock_process_creator(error=False)
|
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"
|
assert cmd == "ls /bin"
|
||||||
|
|
||||||
|
|
||||||
@patch(
|
@patch("homeassistant.components.shell_command.asyncio.create_subprocess_exec")
|
||||||
"homeassistant.components.shell_command.asyncio.subprocess"
|
|
||||||
".create_subprocess_exec"
|
|
||||||
)
|
|
||||||
async def test_template_render(mock_call, hass):
|
async def test_template_render(mock_call, hass):
|
||||||
"""Ensure shell_commands with templates get rendered properly."""
|
"""Ensure shell_commands with templates get rendered properly."""
|
||||||
hass.states.async_set("sensor.test_state", "Works")
|
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
|
assert ("ls", "/bin", "Works") == cmd
|
||||||
|
|
||||||
|
|
||||||
@patch(
|
@patch("homeassistant.components.shell_command.asyncio.create_subprocess_shell")
|
||||||
"homeassistant.components.shell_command.asyncio.subprocess"
|
|
||||||
".create_subprocess_shell"
|
|
||||||
)
|
|
||||||
@patch("homeassistant.components.shell_command._LOGGER.error")
|
@patch("homeassistant.components.shell_command._LOGGER.error")
|
||||||
async def test_subprocess_error(mock_error, mock_call, hass):
|
async def test_subprocess_error(mock_error, mock_call, hass):
|
||||||
"""Test subprocess that returns an error."""
|
"""Test subprocess that returns an error."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user