Lint config cleanups (#28864)

* Remove bunch of unneeded lint exclusions

* Use symbolic names instead of identifiers in pylint disables

* Tighten scope of some pylint disables
This commit is contained in:
Ville Skyttä authored and Paulus Schoutsen committed 2019-11-25 22:40:08 -08:00
1 parent afaa464142
commit 99c7608fb4
77 files changed
+92 -126

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
# pylint: disable=W0621
# pylint: disable=redefined-outer-name
"""Tests for the Daikin config flow."""
import asyncio
@@ -27,7 +27,9 @@ def mock_connection_fixture() -> AsyncConnection:
def _rest_call_side_effect(path, body=None):
return path, body
connection._restCall.side_effect = _rest_call_side_effect # pylint: disable=W0212
connection._restCall.side_effect = ( # pylint: disable=protected-access
_rest_call_side_effect
)
connection.api_call.return_value = mock_coro(True)
connection.init.side_effect = mock_coro(True)
+6 -2
View File
@@ -58,7 +58,9 @@ 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=W0212
fire_target.fire_update_event(
fire_target._rawJSONData # pylint: disable=protected-access
)
else:
fire_target.fire_update_event()
@@ -136,7 +138,9 @@ 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=W0212
instance.__dict__.update(
instance._mock_wraps.__dict__ # pylint: disable=protected-access
)
return instance
mock = Mock(spec=instance, wraps=instance)
@@ -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=W0212
json = home._rawJSONData # pylint: disable=protected-access
json["functionalHomes"]["SECURITY_AND_ALARM"]["alarmActive"] = alarm_triggered
external_zone_id = json["functionalHomes"]["SECURITY_AND_ALARM"]["securityZones"][
"EXTERNAL"
@@ -367,7 +367,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=W0212
assert len(home._connection.mock_calls) == 1 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@@ -377,7 +377,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=W0212
assert len(home._connection.mock_calls) == 2 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@@ -387,7 +387,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=W0212
assert len(home._connection.mock_calls) == 3 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@@ -397,7 +397,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=W0212
assert len(home._connection.mock_calls) == 4 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@@ -407,7 +407,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=W0212
assert len(home._connection.mock_calls) == 5 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@@ -417,7 +417,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=W0212
assert len(home._connection.mock_calls) == 6 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@@ -427,14 +427,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=W0212
assert len(home._connection.mock_calls) == 7 # pylint: disable=protected-access
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=W0212
assert len(home._connection.mock_calls) == 8 # pylint: disable=protected-access
await hass.services.async_call(
"homematicip_cloud",
@@ -444,14 +444,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=W0212
assert len(home._connection.mock_calls) == 9 # pylint: disable=protected-access
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=W0212
assert len(home._connection.mock_calls) == 10 # pylint: disable=protected-access
not_existing_hap_id = "5555F7110000000000000001"
await hass.services.async_call(
@@ -463,7 +463,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=W0212
assert len(home._connection.mock_calls) == 10 # pylint: disable=protected-access
async def test_hmip_heating_group_services(hass, mock_hap_with_service):
@@ -485,7 +485,9 @@ async def test_hmip_heating_group_services(hass, mock_hap_with_service):
)
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=W0212
assert (
len(hmip_device._connection.mock_calls) == 2 # pylint: disable=protected-access
)
await hass.services.async_call(
"homematicip_cloud",
@@ -495,4 +497,7 @@ async def test_hmip_heating_group_services(hass, mock_hap_with_service):
)
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) == 12 # pylint: disable=W0212
assert (
len(hmip_device._connection.mock_calls) # pylint: disable=protected-access
== 12
)
@@ -105,7 +105,7 @@ async def test_hap_reconnected(hass, default_mock_hap):
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_UNAVAILABLE
default_mock_hap._accesspoint_connected = False # pylint: disable=W0212
default_mock_hap._accesspoint_connected = False # pylint: disable=protected-access
await async_manipulate_test_data(hass, default_mock_hap.home, "connected", True)
await hass.async_block_till_done()
ha_state = hass.states.get(entity_id)
@@ -40,7 +40,7 @@ def init_config_flow(hass):
sensors=None,
)
flow = config_flow.LogiCircleFlowHandler()
flow._get_authorization_url = Mock( # pylint: disable=W0212
flow._get_authorization_url = Mock( # pylint: disable=protected-access
return_value="http://example.com"
)
flow.hass = hass
@@ -65,7 +65,9 @@ def mock_logi_circle():
yield mock_logi_circle_
async def test_step_import(hass, mock_logi_circle): # pylint: disable=W0621
async def test_step_import(
hass, mock_logi_circle # pylint: disable=redefined-outer-name
):
"""Test that we trigger import when configuring with client."""
flow = init_config_flow(hass)
@@ -75,8 +77,8 @@ async def test_step_import(hass, mock_logi_circle): # pylint: disable=W0621
async def test_full_flow_implementation(
hass, mock_logi_circle
): # pylint: disable=W0621
hass, mock_logi_circle # pylint: disable=redefined-outer-name
):
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(
hass,
@@ -154,7 +156,7 @@ async def test_abort_if_already_setup(hass):
)
async def test_abort_if_authorize_fails(
hass, mock_logi_circle, side_effect, error
): # pylint: disable=W0621
): # pylint: disable=redefined-outer-name
"""Test we abort if authorizing fails."""
flow = init_config_flow(hass)
mock_logi_circle.LogiCircle().authorize.side_effect = side_effect
@@ -176,7 +178,9 @@ 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=W0621
async def test_gen_auth_url(
hass, mock_logi_circle
): # pylint: disable=redefined-outer-name
"""Test generating authorize URL from Logi Circle API."""
config_flow.register_flow_implementation(
hass,
@@ -192,7 +196,7 @@ async def test_gen_auth_url(hass, mock_logi_circle): # pylint: disable=W0621
flow.flow_impl = "test-auth-url"
await async_setup_component(hass, "http", {})
result = flow._get_authorization_url() # pylint: disable=W0212
result = flow._get_authorization_url() # pylint: disable=protected-access
assert result == "http://authorize.url"
@@ -206,7 +210,7 @@ async def test_callback_view_rejects_missing_code(hass):
async def test_callback_view_accepts_code(
hass, mock_logi_circle
): # pylint: disable=W0621
): # pylint: disable=redefined-outer-name
"""Test the auth callback view handles requests with auth code."""
init_config_flow(hass)
view = LogiCircleAuthCallbackView()
@@ -1495,8 +1495,7 @@ async def test_encrypted_payload_no_topic_key(hass, setup_comp):
async def test_encrypted_payload_libsodium(hass, setup_comp):
"""Test sending encrypted message payload."""
try:
# pylint: disable=unused-import
import nacl # noqa: F401
import nacl # noqa: F401 pylint: disable=unused-import
except (ImportError, OSError):
pytest.skip("PyNaCl/libsodium is not installed")
return
+7 -5
View File
@@ -14,7 +14,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 = Mock( # pylint: disable=W0212
flow._get_authorization_url = Mock( # pylint: disable=protected-access
return_value=mock_coro("https://example.com"), side_effect=side_effect
)
flow.hass = hass
@@ -28,7 +28,7 @@ def is_authorized():
@pytest.fixture
def mock_pypoint(is_authorized): # pylint: disable=W0621
def mock_pypoint(is_authorized): # pylint: disable=redefined-outer-name
"""Mock pypoint."""
with MockDependency("pypoint") as mock_pypoint_:
mock_pypoint_.PointSession().get_access_token.return_value = {
@@ -66,7 +66,9 @@ async def test_abort_if_already_setup(hass):
assert result["reason"] == "already_setup"
async def test_full_flow_implementation(hass, mock_pypoint): # pylint: disable=W0621
async def test_full_flow_implementation(
hass, mock_pypoint # pylint: disable=redefined-outer-name
):
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(hass, "test-other", None, None)
flow = init_config_flow(hass)
@@ -92,7 +94,7 @@ async def test_full_flow_implementation(hass, mock_pypoint): # pylint: disable=
assert result["data"]["token"] == {"access_token": "boo"}
async def test_step_import(hass, mock_pypoint): # pylint: disable=W0621
async def test_step_import(hass, mock_pypoint): # pylint: disable=redefined-outer-name
"""Test that we trigger import when configuring with client."""
flow = init_config_flow(hass)
@@ -104,7 +106,7 @@ async def test_step_import(hass, mock_pypoint): # pylint: disable=W0621
@pytest.mark.parametrize("is_authorized", [False])
async def test_wrong_code_flow_implementation(
hass, mock_pypoint
): # pylint: disable=W0621
): # pylint: disable=redefined-outer-name
"""Test wrong code."""
flow = init_config_flow(hass)
+1 -1
View File
@@ -5,7 +5,7 @@ from unittest.mock import Mock
class AsyncMock(Mock):
"""Implements Mock async."""
# pylint: disable=W0235
# pylint: disable=useless-super-delegation
async def __call__(self, *args, **kwargs):
"""Hack for async support for Mock."""
return super().__call__(*args, **kwargs)
+1 -1
View File
@@ -9,7 +9,7 @@ from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.components.smhi import config_flow
# pylint: disable=W0212
# pylint: disable=protected-access
async def test_homeassistant_location_exists() -> None:
"""Test if homeassistant location exists it should return True."""
hass = Mock()
+2 -2
View File
@@ -99,7 +99,7 @@ def test_properties_no_data(hass: HomeAssistant) -> None:
assert weather.temperature_unit == TEMP_CELSIUS
# pylint: disable=W0212
# pylint: disable=protected-access
def test_properties_unknown_symbol() -> None:
"""Test behaviour when unknown symbol from API."""
hass = Mock()
@@ -152,7 +152,7 @@ def test_properties_unknown_symbol() -> None:
assert forecast[ATTR_FORECAST_CONDITION] is None
# pylint: disable=W0212
# pylint: disable=protected-access
async def test_refresh_weather_forecast_exceeds_retries(hass) -> None:
"""Test the refresh weather forecast function."""
from smhi.smhi_lib import SmhiForecastException