Add per-file-ignore to pylint (#86289)

pull/86391/head
epenet 2023-01-22 17:26:24 +01:00 committed by GitHub
parent a0810053f1
commit 30bf0634fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
114 changed files with 123 additions and 226 deletions

View File

@ -117,6 +117,7 @@ load-plugins = [
"hass_enforce_type_hints",
"hass_imports",
"hass_logger",
"pylint_per_file_ignores",
]
persistent = false
extension-pkg-allow-list = [
@ -219,6 +220,9 @@ runtime-typing = false
[tool.pylint.CODE_STYLE]
max-line-length-suggestions = 72
[tool.pylint-per-file-ignores]
"/tests/"="protected-access,redefined-outer-name"
[tool.pytest.ini_options]
testpaths = [
"tests",

View File

@ -15,6 +15,7 @@ mock-open==1.4.0
mypy==0.991
pre-commit==2.21.0
pylint==2.15.10
pylint-per-file-ignores==1.1.0
pipdeptree==2.3.1
pytest-asyncio==0.20.2
pytest-aiohttp==1.0.4

View File

@ -140,7 +140,7 @@ def get_test_home_assistant():
def run_loop():
"""Run event loop."""
# pylint: disable-next=protected-access
loop._thread_ident = threading.get_ident()
loop.run_forever()
loop_stop_event.set()
@ -166,7 +166,6 @@ def get_test_home_assistant():
return hass
# pylint: disable=protected-access
async def async_test_home_assistant(event_loop, load_registries=True):
"""Return a Home Assistant object pointing at test config dir."""
hass = HomeAssistant()

View File

@ -1,5 +1,5 @@
"""The tests for the Alert component."""
# pylint: disable=protected-access
from copy import deepcopy
import pytest

View File

@ -1,5 +1,5 @@
"""The tests for the Alexa component."""
# pylint: disable=protected-access
import datetime
from http import HTTPStatus

View File

@ -1,5 +1,5 @@
"""The tests for the Alexa component."""
# pylint: disable=protected-access
from http import HTTPStatus
import json

View File

@ -1,5 +1,5 @@
"""The tests for the Home Assistant API component."""
# pylint: disable=protected-access
from http import HTTPStatus
import json
from unittest.mock import patch

View File

@ -10,8 +10,6 @@ from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.setup import async_setup_component
from homeassistant.util import dt
# pylint: disable=redefined-outer-name
DEVICE_DATA = {"name": "Private Calendar", "device_id": "Private Calendar"}
EVENTS = [

View File

@ -1,5 +1,5 @@
"""Test fixtures for the cast integration."""
# pylint: disable=protected-access
from unittest.mock import AsyncMock, MagicMock, patch
import pychromecast

View File

@ -1,5 +1,5 @@
"""The tests for the Cast Media player platform."""
# pylint: disable=protected-access
from __future__ import annotations
import asyncio

View File

@ -312,7 +312,6 @@ async def test_ws_api(hass, hass_ws_client, payload):
}
# pylint: disable=protected-access
async def test_ws_prepare(hass, hass_ws_client):
"""Test the Websocket prepare conversation API."""
assert await async_setup_component(hass, "conversation", {})
@ -429,7 +428,6 @@ async def test_custom_sentences_config(hass, hass_client, hass_admin_user):
}
# pylint: disable=protected-access
async def test_prepare_reload(hass):
"""Test calling the reload service."""
language = hass.config.language
@ -451,7 +449,6 @@ async def test_prepare_reload(hass):
assert not agent._lang_intents.get(language)
# pylint: disable=protected-access
async def test_prepare_fail(hass):
"""Test calling prepare with a non-existent language."""
assert await async_setup_component(hass, "conversation", {})

View File

@ -1,5 +1,5 @@
"""The tests for the counter component."""
# pylint: disable=protected-access
import logging
import pytest

View File

@ -1,4 +1,3 @@
# pylint: disable=redefined-outer-name
"""Tests for the Daikin config flow."""
import asyncio
from unittest.mock import PropertyMock, patch

View File

@ -1,5 +1,5 @@
"""The tests device sun light trigger component."""
# pylint: disable=protected-access
from datetime import datetime
from unittest.mock import patch

View File

@ -7,8 +7,6 @@ from . import setup_integration
from tests.test_util.aiohttp import AiohttpClientMocker
# pylint: disable=redefined-outer-name
async def test_config_entry_not_ready(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker

View File

@ -61,8 +61,6 @@ RESTRICTED_ENTITY_ID = f"{MP_DOMAIN}.restricted_client"
STANDBY_ENTITY_ID = f"{MP_DOMAIN}.standby_client"
UNAVAILABLE_ENTITY_ID = f"{MP_DOMAIN}.unavailable_client"
# pylint: disable=redefined-outer-name
@fixture
def mock_now() -> datetime:

View File

@ -19,8 +19,6 @@ CLIENT_ENTITY_ID = f"{REMOTE_DOMAIN}.client"
MAIN_ENTITY_ID = f"{REMOTE_DOMAIN}.host"
UNAVAILABLE_ENTITY_ID = f"{REMOTE_DOMAIN}.unavailable_client"
# pylint: disable=redefined-outer-name
async def test_setup(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) -> None:
"""Test setup with basic config."""

View File

@ -86,7 +86,7 @@ async def test_token_request_succeeds(hass):
mock_ecobee.request_tokens.return_value = True
mock_ecobee.api_key = "test-api-key"
mock_ecobee.refresh_token = "test-token"
# pylint: disable-next=protected-access
flow._ecobee = mock_ecobee
result = await flow.async_step_authorize(user_input={})
@ -109,7 +109,7 @@ async def test_token_request_fails(hass):
mock_ecobee = mock_ecobee.return_value
mock_ecobee.request_tokens.return_value = False
mock_ecobee.pin = "test-pin"
# pylint: disable-next=protected-access
flow._ecobee = mock_ecobee
result = await flow.async_step_authorize(user_input={})

View File

@ -53,7 +53,6 @@ async def test_full_flow(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -109,7 +108,7 @@ async def test_existing_entry(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -150,7 +149,6 @@ async def test_oauth_error(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -207,7 +205,6 @@ async def test_reauthentication(
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View File

@ -1,7 +1,5 @@
"""The tests for the Geofency device tracker platform."""
from http import HTTPStatus
# pylint: disable=redefined-outer-name
from unittest.mock import patch
import pytest

View File

@ -1,7 +1,5 @@
"""The tests for the Google Assistant component."""
from http import HTTPStatus
# pylint: disable=protected-access
import json
from aiohttp.hdrs import AUTHORIZATION
@ -127,9 +125,6 @@ def hass_fixture(event_loop, hass):
return hass
# pylint: disable=redefined-outer-name
async def test_sync_request(hass_fixture, assistant_client, auth_header):
"""Test a sync request."""

View File

@ -228,7 +228,6 @@ async def test_sync_message(hass, registries):
assert events[0].data == {"request_id": REQ_ID, "source": "cloud"}
# pylint: disable=redefined-outer-name
@pytest.mark.parametrize("area_on_device", [True, False])
async def test_sync_in_area(area_on_device, hass, registries):
"""Test a sync message where room hint comes from area."""
@ -921,7 +920,7 @@ async def test_unavailable_state_does_sync(hass):
)
light.hass = hass
light.entity_id = "light.demo_light"
light._available = False # pylint: disable=protected-access
light._available = False
await light.async_update_ha_state()
events = async_capture_events(hass, EVENT_SYNC_RECEIVED)

View File

@ -17,8 +17,6 @@ from homeassistant.setup import async_setup_component
HOME_LATITUDE = 37.239622
HOME_LONGITUDE = -115.815811
# pylint: disable=redefined-outer-name
@pytest.fixture(autouse=True)
def mock_dev_track(mock_device_tracker_conf):

View File

@ -1,5 +1,5 @@
"""The tests for the Group components."""
# pylint: disable=protected-access
from __future__ import annotations
from collections import OrderedDict

View File

@ -1,5 +1,5 @@
"""The tests the History component."""
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
from datetime import timedelta
from http import HTTPStatus
import json

View File

@ -1,7 +1,7 @@
"""The tests the History component."""
from __future__ import annotations
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
from datetime import timedelta
from http import HTTPStatus
import importlib

View File

@ -1,5 +1,5 @@
"""The test for the History Statistics sensor platform."""
# pylint: disable=protected-access
from datetime import timedelta
import unittest
from unittest.mock import patch

View File

@ -36,7 +36,7 @@ async def test_full_flow(
"home_plus_control", context={"source": config_entries.SOURCE_USER}
)
state = config_entry_oauth2_flow._encode_jwt( # pylint: disable=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
"flow_id": result["flow_id"],
@ -154,7 +154,7 @@ async def test_abort_if_invalid_token(
"home_plus_control", context={"source": config_entries.SOURCE_USER}
)
state = config_entry_oauth2_flow._encode_jwt( # pylint: disable=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
"flow_id": result["flow_id"],

View File

@ -1,5 +1,5 @@
"""The tests for Core components."""
# pylint: disable=protected-access
import asyncio
import unittest
from unittest.mock import Mock, patch

View File

@ -20,7 +20,6 @@ from tests.common import (
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa: F401
# pylint: disable=redefined-outer-name
@pytest.fixture
def calls(hass):
"""Track calls to a mock service."""

View File

@ -37,9 +37,7 @@ def mock_connection_fixture() -> AsyncConnection:
def _rest_call_side_effect(path, body=None):
return path, body
connection._restCall.side_effect = ( # pylint: disable=protected-access
_rest_call_side_effect
)
connection._restCall.side_effect = _rest_call_side_effect
connection.api_call = AsyncMock(return_value=True)
connection.init = AsyncMock(side_effect=True)

View File

@ -62,9 +62,7 @@ async def async_manipulate_test_data(
fire_target = hmip_device if fire_device is None else fire_device
if isinstance(fire_target, AsyncHome):
fire_target.fire_update_event(
fire_target._rawJSONData # pylint: disable=protected-access
)
fire_target.fire_update_event(fire_target._rawJSONData)
else:
fire_target.fire_update_event()
@ -206,9 +204,7 @@ class HomeTemplate(Home):
def _get_mock(instance):
"""Create a mock and copy instance attributes over mock."""
if isinstance(instance, Mock):
instance.__dict__.update(
instance._mock_wraps.__dict__ # pylint: disable=protected-access
)
instance.__dict__.update(instance._mock_wraps.__dict__)
return instance
mock = Mock(spec=instance, wraps=instance)

View File

@ -18,7 +18,7 @@ async def _async_manipulate_security_zones(
hass, home, internal_active=False, external_active=False, alarm_triggered=False
):
"""Set new values on hmip security zones."""
json = home._rawJSONData # pylint: disable=protected-access
json = home._rawJSONData
json["functionalHomes"]["SECURITY_AND_ALARM"]["alarmActive"] = alarm_triggered
external_zone_id = json["functionalHomes"]["SECURITY_AND_ALARM"]["securityZones"][
"EXTERNAL"

View File

@ -408,7 +408,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_absence_with_duration"
assert home.mock_calls[-1][1] == (60,)
assert len(home._connection.mock_calls) == 1 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 1
await hass.services.async_call(
"homematicip_cloud",
@ -418,7 +418,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_absence_with_duration"
assert home.mock_calls[-1][1] == (60,)
assert len(home._connection.mock_calls) == 2 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 2
await hass.services.async_call(
"homematicip_cloud",
@ -428,7 +428,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_absence_with_period"
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0),)
assert len(home._connection.mock_calls) == 3 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 3
await hass.services.async_call(
"homematicip_cloud",
@ -438,7 +438,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_absence_with_period"
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0),)
assert len(home._connection.mock_calls) == 4 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 4
await hass.services.async_call(
"homematicip_cloud",
@ -448,7 +448,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_vacation"
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0), 18.5)
assert len(home._connection.mock_calls) == 5 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 5
await hass.services.async_call(
"homematicip_cloud",
@ -458,7 +458,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "activate_vacation"
assert home.mock_calls[-1][1] == (datetime.datetime(2019, 2, 17, 14, 0), 18.5)
assert len(home._connection.mock_calls) == 6 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 6
await hass.services.async_call(
"homematicip_cloud",
@ -468,14 +468,14 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "deactivate_absence"
assert home.mock_calls[-1][1] == ()
assert len(home._connection.mock_calls) == 7 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 7
await hass.services.async_call(
"homematicip_cloud", "deactivate_eco_mode", blocking=True
)
assert home.mock_calls[-1][0] == "deactivate_absence"
assert home.mock_calls[-1][1] == ()
assert len(home._connection.mock_calls) == 8 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 8
await hass.services.async_call(
"homematicip_cloud",
@ -485,14 +485,14 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
)
assert home.mock_calls[-1][0] == "deactivate_vacation"
assert home.mock_calls[-1][1] == ()
assert len(home._connection.mock_calls) == 9 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 9
await hass.services.async_call(
"homematicip_cloud", "deactivate_vacation", blocking=True
)
assert home.mock_calls[-1][0] == "deactivate_vacation"
assert home.mock_calls[-1][1] == ()
assert len(home._connection.mock_calls) == 10 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 10
not_existing_hap_id = "5555F7110000000000000001"
await hass.services.async_call(
@ -504,7 +504,7 @@ async def test_hmip_climate_services(hass, mock_hap_with_service):
assert home.mock_calls[-1][0] == "deactivate_vacation"
assert home.mock_calls[-1][1] == ()
# There is no further call on connection.
assert len(home._connection.mock_calls) == 10 # pylint: disable=protected-access
assert len(home._connection.mock_calls) == 10
async def test_hmip_heating_group_services(hass, default_mock_hap_factory):
@ -529,9 +529,7 @@ async def test_hmip_heating_group_services(hass, default_mock_hap_factory):
)
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
assert hmip_device.mock_calls[-1][1] == (1,)
assert (
len(hmip_device._connection.mock_calls) == 2 # pylint: disable=protected-access
)
assert len(hmip_device._connection.mock_calls) == 2
await hass.services.async_call(
"homematicip_cloud",
@ -541,6 +539,4 @@ async def test_hmip_heating_group_services(hass, default_mock_hap_factory):
)
assert hmip_device.mock_calls[-1][0] == "set_active_profile"
assert hmip_device.mock_calls[-1][1] == (1,)
assert (
len(hmip_device._connection.mock_calls) == 4 # pylint: disable=protected-access
)
assert len(hmip_device._connection.mock_calls) == 4

View File

@ -183,7 +183,7 @@ async def test_hap_reconnected(hass, default_mock_hap_factory):
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_UNAVAILABLE
mock_hap._accesspoint_connected = False # pylint: disable=protected-access
mock_hap._accesspoint_connected = False
await async_manipulate_test_data(hass, mock_hap.home, "connected", True)
await hass.async_block_till_done()
ha_state = hass.states.get(entity_id)

View File

@ -1,7 +1,5 @@
"""The tests for the Home Assistant HTTP component."""
from http import HTTPStatus
# pylint: disable=protected-access
from ipaddress import ip_address
import os
from unittest.mock import Mock, mock_open, patch

View File

@ -1,5 +1,5 @@
"""The tests for the input_boolean component."""
# pylint: disable=protected-access
import logging
from unittest.mock import patch

View File

@ -1,5 +1,5 @@
"""Tests for the Input slider component."""
# pylint: disable=protected-access
import datetime
from unittest.mock import patch

View File

@ -1,5 +1,5 @@
"""The tests for the Input number component."""
# pylint: disable=protected-access
from unittest.mock import patch
import pytest

View File

@ -1,5 +1,5 @@
"""The tests for the Input select component."""
# pylint: disable=protected-access
from unittest.mock import patch
import pytest

View File

@ -1,5 +1,5 @@
"""The tests for the Input text component."""
# pylint: disable=protected-access
from unittest.mock import patch
import pytest

View File

@ -66,7 +66,6 @@ async def test_full_cloud_import_flow_multiple_devices(
flow_id, user_input={"next_step_id": "pick_implementation"}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -147,7 +146,6 @@ async def test_full_cloud_import_flow_single_device(
flow_id, user_input={"next_step_id": "pick_implementation"}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -267,7 +265,6 @@ async def test_full_ssdp_with_cloud_import(
flow_id, user_input={"next_step_id": "pick_implementation"}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -411,7 +408,6 @@ async def test_cloud_import_updates_existing_entry(
flow_id, user_input={"next_step_id": "pick_implementation"}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -518,7 +514,6 @@ async def test_cloud_abort_no_devices(
flow_id, user_input={"next_step_id": "pick_implementation"}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -637,7 +632,6 @@ async def test_cloud_errors(
flow_id, user_input={"next_step_id": "pick_implementation"}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -769,7 +763,6 @@ async def test_reauth_cloud_import(
flow_id, user_input={"next_step_id": "pick_implementation"}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -835,7 +828,6 @@ async def test_reauth_cloud_abort_device_not_found(
flow_id, user_input={"next_step_id": "pick_implementation"}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View File

@ -62,9 +62,7 @@ async def test_on_off_commands(
for service, new_state, new_value in services:
count += 1
await hass.services.async_call(PLATFORM_DOMAIN, service, data, blocking=True)
robot._update_data( # pylint:disable=protected-access
{updated_field: new_value}, partial=True
)
robot._update_data({updated_field: new_value}, partial=True)
assert getattr(robot, robot_command).call_count == count
assert (state := hass.states.get(entity_id))

View File

@ -93,9 +93,7 @@ async def test_robot_with_update_already_in_progress(
):
"""Tests the update entity was set up."""
robot: LitterRobot4 = mock_account_with_litterrobot_4.robots[0]
robot._update_data( # pylint:disable=protected-access
{"isFirmwareUpdateTriggered": True}, partial=True
)
robot._update_data({"isFirmwareUpdateTriggered": True}, partial=True)
entry = await setup_integration(
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN

View File

@ -12,8 +12,6 @@ from homeassistant.config import async_process_ha_core_config
from homeassistant.helpers.dispatcher import DATA_DISPATCHER
from homeassistant.setup import async_setup_component
# pylint: disable=redefined-outer-name
@pytest.fixture(autouse=True)
def mock_dev_track(mock_device_tracker_conf):

View File

@ -1,5 +1,5 @@
"""The tests for the logbook component."""
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
import asyncio
import collections
from datetime import datetime, timedelta

View File

@ -38,9 +38,7 @@ def init_config_flow(hass):
sensors=None,
)
flow = config_flow.LogiCircleFlowHandler()
flow._get_authorization_url = Mock( # pylint: disable=protected-access
return_value="http://example.com"
)
flow._get_authorization_url = Mock(return_value="http://example.com")
flow.hass = hass
return flow
@ -59,9 +57,7 @@ def mock_logi_circle():
yield LogiCircle
async def test_step_import(
hass, mock_logi_circle # pylint: disable=redefined-outer-name
):
async def test_step_import(hass, mock_logi_circle):
"""Test that we trigger import when configuring with client."""
flow = init_config_flow(hass)
@ -70,9 +66,7 @@ async def test_step_import(
assert result["step_id"] == "auth"
async def test_full_flow_implementation(
hass, mock_logi_circle # pylint: disable=redefined-outer-name
):
async def test_full_flow_implementation(hass, mock_logi_circle):
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(
hass,
@ -153,9 +147,7 @@ async def test_abort_if_already_setup(hass):
(AuthorizationFailed, "invalid_auth"),
],
)
async def test_abort_if_authorize_fails(
hass, mock_logi_circle, side_effect, error
): # pylint: disable=redefined-outer-name
async def test_abort_if_authorize_fails(hass, mock_logi_circle, side_effect, error):
"""Test we abort if authorizing fails."""
flow = init_config_flow(hass)
mock_logi_circle.authorize.side_effect = side_effect
@ -177,9 +169,7 @@ async def test_not_pick_implementation_if_only_one(hass):
assert result["step_id"] == "auth"
async def test_gen_auth_url(
hass, mock_logi_circle
): # pylint: disable=redefined-outer-name
async def test_gen_auth_url(hass, mock_logi_circle):
"""Test generating authorize URL from Logi Circle API."""
config_flow.register_flow_implementation(
hass,
@ -195,7 +185,7 @@ async def test_gen_auth_url(
flow.flow_impl = "test-auth-url"
await async_setup_component(hass, "http", {})
result = flow._get_authorization_url() # pylint: disable=protected-access
result = flow._get_authorization_url()
assert result == "http://authorize.url"
@ -207,9 +197,7 @@ async def test_callback_view_rejects_missing_code(hass):
assert resp.status == HTTPStatus.BAD_REQUEST
async def test_callback_view_accepts_code(
hass, mock_logi_circle
): # pylint: disable=redefined-outer-name
async def test_callback_view_accepts_code(hass, mock_logi_circle):
"""Test the auth callback view handles requests with auth code."""
init_config_flow(hass)
view = LogiCircleAuthCallbackView()

View File

@ -120,7 +120,6 @@ async def test_reauthentication_flow(
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View File

@ -47,7 +47,7 @@ async def test_minutes_remaining_sensor(hass):
end_time = now + dt_util.dt.timedelta(minutes=10)
# we control this mock
# pylint: disable-next=protected-access
device.zone1._end_time = (end_time).timestamp()
with freeze_time(now), patch_async_ble_device_from_address(), patch_melnor_device(

View File

@ -74,13 +74,13 @@ async def test_update(port, switch):
async def test_update_with_target_state(port, switch):
"""Test update with target state."""
# pylint: disable-next=protected-access
switch._target_state = True
port.data = {}
port.data["output"] = "stale"
switch.update()
assert port.data["output"] == 1.0
# pylint: disable-next=protected-access
assert switch._target_state is None
port.data["output"] = "untouched"
switch.update()
@ -92,7 +92,7 @@ async def test_turn_on(port, switch):
switch.turn_on()
assert port.control.call_count == 1
assert port.control.call_args == mock.call(True)
# pylint: disable-next=protected-access
assert switch._target_state
@ -101,5 +101,5 @@ async def test_turn_off(port, switch):
switch.turn_off()
assert port.control.call_count == 1
assert port.control.call_args == mock.call(False)
# pylint: disable-next=protected-access
assert not switch._target_state

View File

@ -1,7 +1,7 @@
"""Tests for mobile_app component."""
from http import HTTPStatus
# pylint: disable=redefined-outer-name,unused-import
# pylint: disable=unused-import
import pytest
from homeassistant.components.mobile_app.const import DOMAIN

View File

@ -277,7 +277,7 @@ BAD_MESSAGE = {"_type": "unsupported", "tst": 1}
BAD_JSON_PREFIX = "--$this is bad json#--"
BAD_JSON_SUFFIX = "** and it ends here ^^"
# pylint: disable=invalid-name, len-as-condition, redefined-outer-name
# pylint: disable=invalid-name, len-as-condition
@pytest.fixture

View File

@ -13,7 +13,7 @@ def init_config_flow(hass, side_effect=None):
"""Init a configuration flow."""
config_flow.register_flow_implementation(hass, DOMAIN, "id", "secret")
flow = config_flow.PointFlowHandler()
flow._get_authorization_url = AsyncMock( # pylint: disable=protected-access
flow._get_authorization_url = AsyncMock(
return_value="https://example.com", side_effect=side_effect
)
flow.hass = hass
@ -27,7 +27,7 @@ def is_authorized():
@pytest.fixture
def mock_pypoint(is_authorized): # pylint: disable=redefined-outer-name
def mock_pypoint(is_authorized):
"""Mock pypoint."""
with patch(
"homeassistant.components.point.config_flow.PointSession"
@ -67,9 +67,7 @@ async def test_abort_if_already_setup(hass):
assert result["reason"] == "already_setup"
async def test_full_flow_implementation(
hass, mock_pypoint # pylint: disable=redefined-outer-name
):
async def test_full_flow_implementation(hass, mock_pypoint):
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(hass, "test-other", None, None)
flow = init_config_flow(hass)
@ -95,7 +93,7 @@ async def test_full_flow_implementation(
assert result["data"]["token"] == {"access_token": "boo"}
async def test_step_import(hass, mock_pypoint): # pylint: disable=redefined-outer-name
async def test_step_import(hass, mock_pypoint):
"""Test that we trigger import when configuring with client."""
flow = init_config_flow(hass)
@ -105,9 +103,7 @@ async def test_step_import(hass, mock_pypoint): # pylint: disable=redefined-out
@pytest.mark.parametrize("is_authorized", [False])
async def test_wrong_code_flow_implementation(
hass, mock_pypoint
): # pylint: disable=redefined-outer-name
async def test_wrong_code_flow_implementation(hass, mock_pypoint):
"""Test wrong code."""
flow = init_config_flow(hass)

View File

@ -1,7 +1,7 @@
"""The tests the History component."""
from __future__ import annotations
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
from copy import copy
from datetime import datetime, timedelta
import json

View File

@ -1,7 +1,7 @@
"""The tests the History component."""
from __future__ import annotations
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
from copy import copy
from datetime import datetime, timedelta
import importlib

View File

@ -1,7 +1,6 @@
"""The tests for the Recorder component."""
from __future__ import annotations
# pylint: disable=protected-access
import asyncio
from datetime import datetime, timedelta
import sqlite3
@ -505,7 +504,7 @@ def test_setup_without_migration(hass_recorder):
assert recorder.get_instance(hass).schema_version == SCHEMA_VERSION
# pylint: disable=redefined-outer-name,invalid-name
# pylint: disable=invalid-name
def test_saving_state_include_domains(hass_recorder):
"""Test saving and restoring a state."""
hass = hass_recorder({"include": {"domains": "test2"}})

View File

@ -1,5 +1,5 @@
"""The tests for the Recorder component."""
# pylint: disable=protected-access
import datetime
import importlib
import sqlite3

View File

@ -1,5 +1,5 @@
"""The tests for sensor recorder platform."""
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
from datetime import datetime, timedelta
import importlib
import sys

View File

@ -3,7 +3,7 @@
The v23 schema used for these tests has been slightly modified to add the
EventData table to allow the recorder to startup successfully.
"""
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
import importlib
import json
import sys

View File

@ -1,5 +1,5 @@
"""The tests for recorder platform migrating data from v30."""
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
from datetime import timedelta
import importlib
import sys

View File

@ -1,5 +1,5 @@
"""The tests for sensor recorder platform."""
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
import datetime
from datetime import timedelta
from statistics import fmean

View File

@ -16,8 +16,6 @@ from tests.common import MockConfigEntry
MAIN_ENTITY_ID = f"{REMOTE_DOMAIN}.my_roku_3"
# pylint: disable=redefined-outer-name
async def test_setup(hass: HomeAssistant, init_integration: MockConfigEntry) -> None:
"""Test setup with basic config."""

View File

@ -1,5 +1,5 @@
"""The tests for the Script component."""
# pylint: disable=protected-access
import asyncio
from datetime import timedelta
from unittest.mock import Mock, patch

View File

@ -58,7 +58,7 @@ async def get_data_from_library(
client = SensiboClient("123467890", aioclient_mock.create_session(hass.loop))
with patch("pysensibo.SensiboClient.async_get_devices", return_value=load_json):
output = await client.async_get_devices_data()
await client._session.close() # pylint: disable=protected-access
await client._session.close()
return output

View File

@ -1,5 +1,5 @@
"""The tests for sensor recorder platform."""
# pylint: disable=protected-access,invalid-name
# pylint: disable=invalid-name
from datetime import datetime, timedelta
import math
from statistics import mean

View File

@ -83,7 +83,7 @@ class MockAyla(AylaApi):
"""Get the list of devices."""
shark = MockShark(self, SHARK_DEVICE_DICT)
shark.properties_full = deepcopy(SHARK_PROPERTIES_DICT)
shark._update_metadata(SHARK_METADATA_DICT) # pylint: disable=protected-access
shark._update_metadata(SHARK_METADATA_DICT)
return [shark]
async def async_request(self, http_method: str, url: str, **kwargs):

View File

@ -124,7 +124,7 @@ async def test_set_cover_position(hass, device_factory):
assert state.attributes[ATTR_BATTERY_LEVEL] == 95
assert state.attributes[ATTR_CURRENT_POSITION] == 10
# Ensure API called
# pylint: disable-next=protected-access
assert device._api.post_device_command.call_count == 1 # type: ignore
@ -147,7 +147,7 @@ async def test_set_cover_position_unsupported(hass, device_factory):
assert ATTR_CURRENT_POSITION not in state.attributes
# Ensure API was not called
# pylint: disable-next=protected-access
assert device._api.post_device_command.call_count == 0 # type: ignore

View File

@ -451,7 +451,6 @@ async def test_event_handler_dispatches_updated_devices(
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), Mock(), devices, [])
broker.connect()
# pylint:disable=protected-access
await broker._event_handler(request, None, None)
await hass.async_block_till_done()
@ -478,7 +477,6 @@ async def test_event_handler_ignores_other_installed_app(
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), Mock(), [device], [])
broker.connect()
# pylint:disable=protected-access
await broker._event_handler(request, None, None)
await hass.async_block_till_done()
@ -516,7 +514,6 @@ async def test_event_handler_fires_button_events(
broker = smartthings.DeviceBroker(hass, config_entry, Mock(), Mock(), [device], [])
broker.connect()
# pylint:disable=protected-access
await broker._event_handler(request, None, None)
await hass.async_block_till_done()

View File

@ -20,9 +20,6 @@ DEVICE_1_ENTITY_ID = f"{MEDIA_PLAYER_DOMAIN}.my_soundtouch_1"
DEVICE_2_ENTITY_ID = f"{MEDIA_PLAYER_DOMAIN}.my_soundtouch_2"
# pylint: disable=redefined-outer-name
@pytest.fixture
def device1_config() -> MockConfigEntry:
"""Mock SoundTouch device 1 config entry."""

View File

@ -1,7 +1,5 @@
"""The tests for the Home Assistant SpaceAPI component."""
from http import HTTPStatus
# pylint: disable=protected-access
from unittest.mock import patch
import pytest

View File

@ -84,7 +84,6 @@ async def test_full_flow(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -151,7 +150,6 @@ async def test_abort_if_spotify_error(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -213,7 +211,6 @@ async def test_reauthentication(
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -279,7 +276,6 @@ async def test_reauth_account_mismatch(
flows = hass.config_entries.flow.async_progress()
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View File

@ -1,5 +1,5 @@
"""Test the SSDP integration."""
# pylint: disable=protected-access
from datetime import datetime, timedelta
from ipaddress import IPv4Address

View File

@ -1,5 +1,4 @@
"""Tests for the Subaru component config flow."""
# pylint: disable=redefined-outer-name
from copy import deepcopy
from unittest import mock
from unittest.mock import PropertyMock, patch

View File

@ -5,7 +5,6 @@ import homeassistant.components.time_date.sensor as time_date
import homeassistant.util.dt as dt_util
# pylint: disable=protected-access
async def test_intervals(hass):
"""Test timing intervals of sensors."""
device = time_date.TimeDateSensor(hass, "time")

View File

@ -1,5 +1,5 @@
"""The tests for the timer component."""
# pylint: disable=protected-access
from datetime import timedelta
import logging
from unittest.mock import patch

View File

@ -54,7 +54,6 @@ async def test_full_flow_implementation(
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "pick_implementation"
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -114,7 +113,6 @@ async def test_no_agreements(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -154,7 +152,6 @@ async def test_multiple_agreements(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -205,7 +202,6 @@ async def test_agreement_already_set_up(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -244,7 +240,7 @@ async def test_toon_abort(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -306,7 +302,6 @@ async def test_import_migration(
assert len(flows) == 1
assert flows[0]["context"][CONF_MIGRATE] == old_entry.entry_id
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View File

@ -5,8 +5,6 @@ import pytest
from . import GATEWAY_ID, TRADFRI_PATH
# pylint: disable=protected-access
@pytest.fixture
def mock_gateway_info():

View File

@ -126,7 +126,7 @@ async def test_to_get_update(mock_sendline, mock_prompt, mock_login, mock_logout
scanner = get_scanner(hass, conf_dict)
# mock_sendline.side_effect = AssertionError("Test")
mock_prompt.side_effect = AssertionError("Test")
devices = scanner._get_update() # pylint: disable=protected-access
devices = scanner._get_update()
assert devices is None

View File

@ -1,5 +1,5 @@
"""Fixtures and test data for UniFi Protect methods."""
# pylint: disable=protected-access
from __future__ import annotations
from collections.abc import Callable

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect binary_sensor platform."""
# pylint: disable=protected-access
from __future__ import annotations
from datetime import datetime, timedelta

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect button platform."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock, Mock

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect camera platform."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock, Mock

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect setup flow."""
# pylint: disable=protected-access
from __future__ import annotations
from collections.abc import Awaitable, Callable

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect light platform."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock, Mock

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect lock platform."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock, Mock

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect media_player platform."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock, Mock, patch

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect setup flow."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect number platform."""
# pylint: disable=protected-access
from __future__ import annotations
from datetime import timedelta

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect select platform."""
# pylint: disable=protected-access
from __future__ import annotations
from copy import copy

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect sensor platform."""
# pylint: disable=protected-access
from __future__ import annotations
from datetime import datetime, timedelta

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect global services."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock, Mock

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect switch platform."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock, Mock

View File

@ -1,5 +1,5 @@
"""Test the UniFi Protect text platform."""
# pylint: disable=protected-access
from __future__ import annotations
from unittest.mock import AsyncMock, Mock

View File

@ -1,5 +1,5 @@
"""Test helpers for UniFi Protect."""
# pylint: disable=protected-access
from __future__ import annotations
from collections.abc import Sequence

View File

@ -198,7 +198,7 @@ class ComponentFactory:
const.DOMAIN, context={"source": SOURCE_USER}
)
assert result
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
self._hass,
{

View File

@ -163,10 +163,8 @@ async def test_data_manager_webhook_subscription(
WebhookConfig(id="1234", url="http://localhost/api/webhook/1234", enabled=True),
)
# pylint: disable=protected-access
data_manager._notify_subscribe_delay = datetime.timedelta(seconds=0)
data_manager._notify_unsubscribe_delay = datetime.timedelta(seconds=0)
# pylint: enable=protected-access
api.notify_list.return_value = NotifyListResponse(
profiles=(

View File

@ -80,7 +80,6 @@ async def test_config_reauth_profile(
{},
)
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View File

@ -172,7 +172,6 @@ async def test_reauthentication(
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View File

@ -245,7 +245,7 @@ def verify_cleanup(event_loop: asyncio.AbstractEventLoop):
if tasks:
event_loop.run_until_complete(asyncio.wait(tasks))
for handle in event_loop._scheduled: # pylint: disable=protected-access
for handle in event_loop._scheduled:
if not handle.cancelled():
_LOGGER.warning("Lingering timer after test %r", handle)
handle.cancel()

View File

@ -1,5 +1,5 @@
"""Test the entity helper."""
# pylint: disable=protected-access
import asyncio
import dataclasses
from datetime import timedelta

Some files were not shown because too many files have changed in this diff Show More