Stricter pylint message control (#86154)

This commit is contained in:
Franck Nijhof 2023-01-20 13:47:55 +01:00 committed by GitHub
parent 29b2b6727e
commit 79b52a2b41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 112 additions and 133 deletions

View file

@ -35,7 +35,7 @@ def validate_python() -> None:
def ensure_config_path(config_dir: str) -> None:
"""Validate the configuration directory."""
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from . import config as config_util
lib_dir = os.path.join(config_dir, "deps")
@ -77,7 +77,7 @@ def ensure_config_path(config_dir: str) -> None:
def get_arguments() -> argparse.Namespace:
"""Get parsed passed in arguments."""
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from . import config as config_util
parser = argparse.ArgumentParser(
@ -184,7 +184,7 @@ def main() -> int:
validate_os()
if args.script is not None:
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from . import scripts
return scripts.run(args.script)
@ -192,7 +192,7 @@ def main() -> int:
config_dir = os.path.abspath(os.path.join(os.getcwd(), args.config))
ensure_config_path(config_dir)
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from . import runner
runtime_conf = runner.RuntimeConfig(

View file

@ -346,7 +346,7 @@ def async_enable_logging(
if not log_no_color:
try:
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from colorlog import ColoredFormatter
# basicConfig must be called after importing colorlog in order to

View file

@ -170,7 +170,6 @@ def adb_decorator(
self: _ADBDeviceT, *args: _P.args, **kwargs: _P.kwargs
) -> _R | None:
"""Call an ADB-related method and catch exceptions."""
# pylint: disable=protected-access
if not self.available and not override_available:
return None
@ -192,12 +191,14 @@ def adb_decorator(
err,
)
await self.aftv.adb_close()
# pylint: disable-next=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()
# pylint: disable-next=protected-access
self._attr_available = False
raise

View file

@ -15,7 +15,7 @@ SERVICE_BROWSE_URL = "browse_url"
SERVICE_BROWSE_URL_SCHEMA = vol.Schema(
{
# pylint: disable=no-value-for-parameter
# pylint: disable-next=no-value-for-parameter
vol.Required(ATTR_URL, default=ATTR_URL_DEFAULT): vol.Url()
}
)

View file

@ -375,7 +375,7 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
tts_base_url = None
url_description = ""
if "tts" in self.hass.config.components:
# pylint: disable=[import-outside-toplevel]
# pylint: disable-next=[import-outside-toplevel]
from homeassistant.components import tts
with suppress(KeyError): # base_url not configured

View file

@ -219,8 +219,7 @@ class Configurator:
if not self._validate_request_id(request_id):
return
# pylint: disable=unused-variable
entity_id, fields, callback = self._requests[request_id]
_, _, callback = self._requests[request_id]
# field validation goes here?
if callback:

View file

@ -82,7 +82,7 @@ def retry(
"Decora connect error for device %s. Reconnecting",
device.name,
)
# pylint: disable=protected-access
# pylint: disable-next=protected-access
device._switch.connect()
return wrapper_retry

View file

@ -134,7 +134,7 @@ async def async_setup(hass: HomeAssistant, yaml_config: ConfigType) -> bool:
# We misunderstood the startup signal. You're not allowed to change
# anything during startup. Temp workaround.
# pylint: disable=protected-access
# pylint: disable-next=protected-access
app._on_startup.freeze()
await app.startup()

View file

@ -134,7 +134,7 @@ class EufyHomeLight(LightEntity):
"""Turn the specified light on."""
brightness = kwargs.get(ATTR_BRIGHTNESS)
colortemp = kwargs.get(ATTR_COLOR_TEMP)
# pylint: disable=invalid-name
# pylint: disable-next=invalid-name
hs = kwargs.get(ATTR_HS_COLOR)
if brightness is not None:

View file

@ -313,7 +313,7 @@ def _frontend_root(dev_repo_path: str | None) -> pathlib.Path:
if dev_repo_path is not None:
return pathlib.Path(dev_repo_path) / "hass_frontend"
# Keep import here so that we can import frontend without installing reqs
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
import hass_frontend
return hass_frontend.where()

View file

@ -221,7 +221,7 @@ async def async_test_stream(
return {}
# Import from stream.worker as stream cannot reexport from worker
# without forcing the av dependency on default_config
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.components.stream.worker import StreamWorkerError
if not isinstance(stream_source, template_helper.Template):

View file

@ -197,7 +197,7 @@ class AbstractConfig(ABC):
def async_enable_report_state(self):
"""Enable proactive mode."""
# Circular dep
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .report_state import async_enable_report_state
if self._unsub_report_state is None:
@ -338,7 +338,7 @@ class AbstractConfig(ABC):
async def _handle_local_webhook(self, hass, webhook_id, request):
"""Handle an incoming local SDK message."""
# Circular dep
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from . import smart_home
self._local_last_active = utcnow()

View file

@ -243,8 +243,7 @@ class OptionsFlowHandler(BaseMultiPanFlow, config_entries.OptionsFlow):
},
)
# pylint: disable=unreachable
# pylint: disable-next=unreachable
return await self.async_step_on_supervisor() # type: ignore[unreachable]
async def async_step_on_supervisor(

View file

@ -459,7 +459,7 @@ class HomeAssistantHTTP:
# However in Home Assistant components can be discovered after boot.
# This will now raise a RunTimeError.
# To work around this we now prevent the router from getting frozen
# pylint: disable=protected-access
# pylint: disable-next=protected-access
self.app._router.freeze = lambda: None # type: ignore[assignment]
self.runner = web.AppRunner(self.app)

View file

@ -99,7 +99,7 @@ def async_user_not_allowed_do_auth(
return "No request available to validate local access"
if "cloud" in hass.config.components:
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from hass_nabucasa import remote
if remote.is_cloud_request.get():

View file

@ -141,7 +141,7 @@ async def process_wrong_login(request: Request) -> None:
# Supervisor IP should never be banned
if "hassio" in hass.config.components:
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.components import hassio
if hassio.get_supervisor_ip() == str(remote_addr):

View file

@ -31,7 +31,7 @@ def setup_cors(app: Application, origins: list[str]) -> None:
"""Set up CORS."""
# This import should remain here. That way the HTTP integration can always
# be imported by other integrations without it's requirements being installed.
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
import aiohttp_cors
cors = aiohttp_cors.setup(

View file

@ -434,7 +434,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
):
profiles.apply_default(light.entity_id, light.is_on, params)
# pylint: disable=protected-access
# pylint: disable-next=protected-access
legacy_supported_color_modes = light._light_internal_supported_color_modes
supported_color_modes = light.supported_color_modes

View file

@ -44,7 +44,7 @@ def get_minio_notification_response(
):
"""Start listening to minio events. Copied from minio-py."""
query = {"prefix": prefix, "suffix": suffix, "events": events}
# pylint: disable=protected-access
# pylint: disable-next=protected-access
return minio_client._url_open(
"GET", bucket_name=bucket_name, query=query, preload_content=False
)
@ -159,7 +159,7 @@ class MinioEventThread(threading.Thread):
presigned_url = minio_client.presigned_get_object(bucket, key)
# Fail gracefully. If for whatever reason this stops working,
# it shouldn't prevent it from firing events.
# pylint: disable=broad-except
# pylint: disable-next=broad-except
except Exception as error:
_LOGGER.error("Failed to generate presigned url: %s", error)

View file

@ -486,7 +486,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entity.async_remove()
for mqtt_platform in mqtt_platforms
for entity in mqtt_platform.entities.values()
# pylint: disable=protected-access
# pylint: disable-next=protected-access
if not entity._discovery_data # type: ignore[attr-defined]
if mqtt_platform.config_entry
and mqtt_platform.domain in RELOADABLE_PLATFORMS

View file

@ -166,7 +166,7 @@ class UserOnboardingView(_BaseOnboardingView):
# Return authorization code for fetching tokens and connect
# during onboarding.
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.components.auth import create_auth_code
auth_code = create_auth_code(hass, data["client_id"], credentials)
@ -195,7 +195,7 @@ class CoreConfigOnboardingView(_BaseOnboardingView):
# Integrations to set up when finishing onboarding
onboard_integrations = ["met", "radio_browser"]
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.components import hassio
if (
@ -255,7 +255,7 @@ class IntegrationOnboardingView(_BaseOnboardingView):
)
# Return authorization code so we can redirect user and log them in
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.components.auth import create_auth_code
auth_code = create_auth_code(

View file

@ -103,7 +103,7 @@ class PushoverNotificationService(BaseNotificationService):
if self._hass.config.is_allowed_path(data[ATTR_ATTACHMENT]):
# try to open it as a normal file.
try:
# pylint: disable=consider-using-with
# pylint: disable-next=consider-using-with
file_handle = open(data[ATTR_ATTACHMENT], "rb")
# Replace the attachment identifier with file object.
image = file_handle

View file

@ -220,7 +220,7 @@ def execute(hass, filename, source, data=None):
try:
_LOGGER.info("Executing %s: %s", filename, data)
# pylint: disable=exec-used
# pylint: disable-next=exec-used
exec(compiled.code, restricted_globals)
except ScriptError as err:
logger.error("Error executing script: %s", err)

View file

@ -20,7 +20,6 @@ def setup_platform(
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the QR code image processing platform."""
# pylint: disable=unused-argument
entities = []
for camera in config[CONF_SOURCE]:
entities.append(QrEntity(camera[CONF_ENTITY_ID], camera.get(CONF_NAME)))

View file

@ -404,8 +404,6 @@ def build_mysqldb_conv() -> dict:
# Late imports since we only call this if they are using mysqldb
# pylint: disable=import-outside-toplevel,import-error
from MySQLdb.constants import FIELD_TYPE
# pylint: disable=import-outside-toplevel,import-error
from MySQLdb.converters import conversions
return {**conversions, FIELD_TYPE.DATETIME: _datetime_or_none}

View file

@ -522,7 +522,7 @@ class SamsungTVWSBridge(
return RESULT_AUTH_MISSING
except (ConnectionFailure, OSError, AsyncioTimeoutError) as err:
LOGGER.debug("Failing config: %s, %s error: %s", config, type(err), err)
# pylint: disable=useless-else-on-loop
# pylint: disable-next=useless-else-on-loop
else:
if result:
return result

View file

@ -91,7 +91,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
with suppress(TypeError):
process.kill()
# https://bugs.python.org/issue43884
# pylint: disable=protected-access
# pylint: disable-next=protected-access
process._transport.close() # type: ignore[attr-defined]
del process

View file

@ -158,7 +158,7 @@ class Monitor(threading.Thread, SensorEntity):
)
if SKIP_HANDLE_LOOKUP:
# HACK: inject handle mapping collected offline
# pylint: disable=protected-access
# pylint: disable-next=protected-access
device._characteristics[UUID(BLE_TEMP_UUID)] = cached_char
# Magic: writing this makes device happy
device.char_write_handle(0x1B, bytearray([255]), False)

View file

@ -220,7 +220,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
filter_libav_logging()
# Keep import here so that we can import stream integration without installing reqs
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .recorder import async_setup_recorder
hass.data[DOMAIN] = {}
@ -405,7 +405,7 @@ class Stream:
def _run_worker(self) -> None:
"""Handle consuming streams and restart keepalive streams."""
# Keep import here so that we can import stream integration without installing reqs
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .worker import StreamState, StreamWorkerError, stream_worker
stream_state = StreamState(self.hass, self.outputs, self._diagnostics)
@ -501,7 +501,7 @@ class Stream:
"""Make a .mp4 recording from a provided stream."""
# Keep import here so that we can import stream integration without installing reqs
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .recorder import RecorderOutput
# Check for file access

View file

@ -438,7 +438,7 @@ class KeyFrameConverter:
"""Initialize."""
# Keep import here so that we can import stream integration without installing reqs
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.components.camera.img_util import TurboJPEGSingleton
self.packet: Packet = None
@ -461,7 +461,7 @@ class KeyFrameConverter:
return
# Keep import here so that we can import stream integration without installing reqs
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from av import CodecContext
self._codec_context = CodecContext.create(codec_context.name, "r")

View file

@ -73,7 +73,7 @@ async def async_attach_trigger(
return
if delay_cancel:
# pylint: disable=not-callable
# pylint: disable-next=not-callable
delay_cancel()
delay_cancel = None
@ -149,7 +149,7 @@ async def async_attach_trigger(
"""Remove state listeners async."""
unsub()
if delay_cancel:
# pylint: disable=not-callable
# pylint: disable-next=not-callable
delay_cancel()
return async_remove

View file

@ -246,9 +246,8 @@ class UnifiVideoCamera(Camera):
(
uri
for i, uri in enumerate(channel["rtspUris"])
# pylint: disable=protected-access
# pylint: disable-next=protected-access
if re.search(self._nvr._host, uri)
# pylint: enable=protected-access
)
)
return uri

View file

@ -94,7 +94,7 @@ def handle_subscribe_events(
) -> None:
"""Handle subscribe events command."""
# Circular dep
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .permissions import SUBSCRIBE_ALLOWLIST
event_type = msg["event_type"]
@ -561,7 +561,7 @@ async def handle_subscribe_trigger(
) -> None:
"""Handle subscribe trigger command."""
# Circular dep
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.helpers import trigger
trigger_config = await trigger.async_validate_trigger_config(hass, msg["trigger"])
@ -612,7 +612,7 @@ async def handle_test_condition(
) -> None:
"""Handle test condition command."""
# Circular dep
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.helpers import condition
# Do static + dynamic validation of the condition
@ -638,7 +638,7 @@ async def handle_execute_script(
) -> None:
"""Handle execute script command."""
# Circular dep
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.helpers.script import Script
context = connection.context(msg)
@ -680,7 +680,7 @@ async def handle_validate_config(
) -> None:
"""Handle validate config command."""
# Circular dep
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.helpers import condition, script, trigger
result = {}

View file

@ -976,7 +976,7 @@ async def async_check_ha_config_file(hass: HomeAssistant) -> str | None:
This method is a coroutine.
"""
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .helpers import check_config
res = await check_config.async_check_ha_config_file(hass)
@ -994,7 +994,7 @@ def async_notify_setup_error(
This method must be run in the event loop.
"""
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .components import persistent_notification
if (errors := hass.data.get(DATA_PERSISTENT_ERRORS)) is None:

View file

@ -627,7 +627,7 @@ class ConfigEntry:
)
return False
if result:
# pylint: disable=protected-access
# pylint: disable-next=protected-access
hass.config_entries._async_schedule_save()
# https://github.com/python/mypy/issues/11839
return result # type: ignore[no-any-return]

View file

@ -335,7 +335,7 @@ class HomeAssistant:
await self.async_start()
if attach_signals:
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .helpers.signal import async_register_signal_handling
async_register_signal_handling(self)

View file

@ -123,7 +123,7 @@ def _async_create_clientsession(
# It's important that we identify as Home Assistant
# If a package requires a different user agent, override it by passing a headers
# dictionary to the request method.
# pylint: disable=protected-access
# pylint: disable-next=protected-access
clientsession._default_headers = MappingProxyType( # type: ignore[assignment]
{USER_AGENT: SERVER_SOFTWARE},
)

View file

@ -1074,7 +1074,7 @@ def make_entity_service_schema(
SCRIPT_VARIABLES_SCHEMA = vol.All(
vol.Schema({str: template_complex}),
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
lambda val: script_variables_helper.ScriptVariables(val),
)
@ -1267,7 +1267,7 @@ AND_CONDITION_SCHEMA = vol.Schema(
vol.Required(CONF_CONDITION): "and",
vol.Required(CONF_CONDITIONS): vol.All(
ensure_list,
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
[lambda value: CONDITION_SCHEMA(value)],
),
}
@ -1278,7 +1278,7 @@ AND_CONDITION_SHORTHAND_SCHEMA = vol.Schema(
**CONDITION_BASE_SCHEMA,
vol.Required("and"): vol.All(
ensure_list,
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
[lambda value: CONDITION_SCHEMA(value)],
),
}
@ -1290,7 +1290,7 @@ OR_CONDITION_SCHEMA = vol.Schema(
vol.Required(CONF_CONDITION): "or",
vol.Required(CONF_CONDITIONS): vol.All(
ensure_list,
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
[lambda value: CONDITION_SCHEMA(value)],
),
}
@ -1301,7 +1301,7 @@ OR_CONDITION_SHORTHAND_SCHEMA = vol.Schema(
**CONDITION_BASE_SCHEMA,
vol.Required("or"): vol.All(
ensure_list,
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
[lambda value: CONDITION_SCHEMA(value)],
),
}
@ -1313,7 +1313,7 @@ NOT_CONDITION_SCHEMA = vol.Schema(
vol.Required(CONF_CONDITION): "not",
vol.Required(CONF_CONDITIONS): vol.All(
ensure_list,
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
[lambda value: CONDITION_SCHEMA(value)],
),
}
@ -1324,7 +1324,7 @@ NOT_CONDITION_SHORTHAND_SCHEMA = vol.Schema(
**CONDITION_BASE_SCHEMA,
vol.Required("not"): vol.All(
ensure_list,
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
[lambda value: CONDITION_SCHEMA(value)],
),
}
@ -1356,7 +1356,7 @@ CONDITION_SHORTHAND_SCHEMA = vol.Schema(
**CONDITION_BASE_SCHEMA,
vol.Required(CONF_CONDITION): vol.All(
ensure_list,
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
[lambda value: CONDITION_SCHEMA(value)],
),
}

View file

@ -450,7 +450,7 @@ class DeviceRegistry:
) -> DeviceEntry | None:
"""Update device attributes."""
# Circular dep
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from . import area_registry as ar
old = self.devices[device_id]

View file

@ -375,7 +375,7 @@ class _ScriptRun:
self._script._changed() # pylint: disable=protected-access
async def _async_get_condition(self, config):
# pylint: disable=protected-access
# pylint: disable-next=protected-access
return await self._script._async_get_condition(config)
def _log(
@ -786,7 +786,7 @@ class _ScriptRun:
repeat_vars["item"] = item
self._variables["repeat"] = repeat_vars
# pylint: disable=protected-access
# pylint: disable-next=protected-access
script = self._script._get_repeat_script(self._step)
async def async_run_sequence(iteration, extra_msg=""):

View file

@ -1085,7 +1085,7 @@ def integration_entities(hass: HomeAssistant, entry_name: str) -> Iterable[str]:
return [entry.entity_id for entry in entries]
# fallback to just returning all entities for a domain
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .entity import entity_sources
return [

View file

@ -229,7 +229,7 @@ async def async_get_config_flows(
type_filter: Literal["device", "helper", "hub", "service"] | None = None,
) -> set[str]:
"""Return cached list of config flows."""
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from .generated.config_flows import FLOWS
integrations = await async_get_custom_components(hass)

View file

@ -112,7 +112,7 @@ async def setup_and_run_hass(runtime_config: RuntimeConfig) -> int:
return 1
# threading._shutdown can deadlock forever
# pylint: disable=protected-access
# pylint: disable-next=protected-access
threading._shutdown = deadlock_safe_shutdown # type: ignore[attr-defined]
return await hass.async_run()

View file

@ -353,7 +353,7 @@ def _create_state_changed_event_from_old_new(
row.old_state_id = old_state and 1
row.state_id = new_state and 1
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from homeassistant.components import logbook
return logbook.LazyEventPartialState(row, {})

View file

@ -40,7 +40,7 @@ ERROR_STR = "General Errors"
def color(the_color, *args, reset=None):
"""Color helper."""
# pylint: disable=import-outside-toplevel
# pylint: disable-next=import-outside-toplevel
from colorlog.escape_codes import escape_codes, parse_colors
try:

View file

@ -170,7 +170,7 @@ class Throttle:
else:
host = args[0] if args else wrapper
# pylint: disable=protected-access # to _throttle
# pylint: disable=protected-access
if not hasattr(host, "_throttle"):
host._throttle = {}

View file

@ -84,7 +84,7 @@ def serialize_response(response: web.Response) -> dict[str, Any]:
if (body := response.body) is None:
body_decoded = None
elif isinstance(body, payload.StringPayload):
# pylint: disable=protected-access
# pylint: disable-next=protected-access
body_decoded = body._value.decode(body.encoding)
elif isinstance(body, bytes):
body_decoded = body.decode(response.charset or "utf-8")

View file

@ -39,7 +39,7 @@ def printc(the_color, *args):
def validate_requirements_ok():
"""Validate requirements, returns True of ok."""
# pylint: disable=import-error,import-outside-toplevel
# pylint: disable-next=import-error,import-outside-toplevel
from gen_requirements_all import main as req_main
return req_main(True) == 0

View file

@ -140,7 +140,7 @@ def get_test_home_assistant():
def run_loop():
"""Run event loop."""
# pylint: disable=protected-access
# pylint: disable-next=protected-access
loop._thread_ident = threading.get_ident()
loop.run_forever()
loop_stop_event.set()

View file

@ -86,9 +86,8 @@ 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=protected-access
# pylint: disable-next=protected-access
flow._ecobee = mock_ecobee
# pylint: enable=protected-access
result = await flow.async_step_authorize(user_input={})
@ -110,9 +109,8 @@ 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=protected-access
# pylint: disable-next=protected-access
flow._ecobee = mock_ecobee
# pylint: enable=protected-access
result = await flow.async_step_authorize(user_input={})

View file

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

View file

@ -897,7 +897,6 @@ async def test_raising_error_trait(hass):
async def test_serialize_input_boolean(hass):
"""Test serializing an input boolean entity."""
state = State("input_boolean.bla", "on")
# pylint: disable=protected-access
entity = sh.GoogleEntity(hass, BASIC_CONFIG, state)
result = entity.sync_serialize(None, "mock-uuid")
assert result == {

View file

@ -114,7 +114,6 @@ def reload_core_config(hass):
class TestComponentsCore(unittest.TestCase):
"""Test homeassistant.components module."""
# pylint: disable=invalid-name
def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()

View file

@ -151,7 +151,7 @@ async def setup_test_config_entry(
config_entry = config_entry or add_test_config_entry(hass, options=options)
hyperion_client = hyperion_client or create_mock_client()
# pylint: disable=attribute-defined-outside-init
# pylint: disable-next=attribute-defined-outside-init
hyperion_client.instances = [TEST_INSTANCE_1]
with patch(

View file

@ -765,7 +765,7 @@ async def test_options_priority(hass: HomeAssistant) -> None:
{ATTR_ENTITY_ID: TEST_ENTITY_ID_1},
blocking=True,
)
# pylint: disable=unsubscriptable-object
# pylint: disable-next=unsubscriptable-object
assert client.async_send_set_color.call_args[1][CONF_PRIORITY] == new_priority

View file

@ -72,7 +72,7 @@ def get_mock_call_fixture(request):
if request.param == influxdb.API_VERSION_2:
return lambda body, precision=None: v2_call(body, precision)
# pylint: disable=unnecessary-lambda
# pylint: disable-next=unnecessary-lambda
return lambda body, precision=None: call(body, time_precision=precision)

View file

@ -73,7 +73,7 @@ async def test_setup_entry(hass: HomeAssistant):
await hass.async_block_till_done()
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
await hass.async_block_till_done()
# pylint: disable=no-member
# pylint: disable-next=no-member
assert insteon.devices.async_save.call_count == 1
assert mock_close.called

View file

@ -135,12 +135,10 @@ async def test_create_and_setup(hass, mock_panel):
await device.update_switch("1", 0)
# confirm the correct api is used
# pylint: disable=no-member
assert mock_panel.put_device.call_count == 1
assert mock_panel.put_zone.call_count == 0
# confirm the settings are sent to the panel
# pylint: disable=no-member
assert mock_panel.put_settings.call_args_list[0][1] == {
"sensors": [{"pin": "1"}, {"pin": "2"}, {"pin": "5"}],
"actuators": [{"trigger": 0, "pin": "8"}, {"trigger": 1, "pin": "9"}],
@ -288,12 +286,10 @@ async def test_create_and_setup_pro(hass, mock_panel):
await device.update_switch("2", 1)
# confirm the correct api is used
# pylint: disable=no-member
assert mock_panel.put_device.call_count == 0
assert mock_panel.put_zone.call_count == 1
# confirm the settings are sent to the panel
# pylint: disable=no-member
assert mock_panel.put_settings.call_args_list[0][1] == {
"sensors": [{"zone": "2"}, {"zone": "6"}, {"zone": "10"}, {"zone": "11"}],
"actuators": [
@ -483,12 +479,10 @@ async def test_default_options(hass, mock_panel):
await device.update_switch("1", 0)
# confirm the correct api is used
# pylint: disable=no-member
assert mock_panel.put_device.call_count == 1
assert mock_panel.put_zone.call_count == 0
# confirm the settings are sent to the panel
# pylint: disable=no-member
assert mock_panel.put_settings.call_args_list[0][1] == {
"sensors": [{"pin": "1"}, {"pin": "2"}, {"pin": "5"}],
"actuators": [{"trigger": 0, "pin": "8"}, {"trigger": 1, "pin": "9"}],

View file

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

View file

@ -120,7 +120,7 @@ async def test_reauthentication_flow(
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
# pylint: disable=protected-access
# 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=protected-access
# 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=protected-access
# 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=protected-access
# 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=protected-access
# 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=protected-access
# pylint: disable-next=protected-access
assert not switch._target_state

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=protected-access
# 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=protected-access
# pylint: disable-next=protected-access
assert device._api.post_device_command.call_count == 0 # type: ignore

View file

@ -37,7 +37,6 @@ async def test_scene_activate(hass, scene):
assert state.attributes["icon"] == scene.icon
assert state.attributes["color"] == scene.color
assert state.attributes["location_id"] == scene.location_id
# pylint: disable=protected-access
assert scene.execute.call_count == 1 # type: ignore

View file

@ -5,7 +5,6 @@ from unittest.mock import Mock
class AsyncMock(Mock):
"""Implements Mock async."""
# pylint: disable=useless-super-delegation
async def __call__(self, *args, **kwargs):
"""Hack for async support for Mock."""
return super().__call__(*args, **kwargs)

View file

@ -84,7 +84,7 @@ async def test_full_flow(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable=protected-access
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -151,7 +151,7 @@ async def test_abort_if_spotify_error(
DOMAIN, context={"source": SOURCE_USER}
)
# pylint: disable=protected-access
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -213,7 +213,7 @@ async def test_reauthentication(
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
# pylint: disable=protected-access
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{
@ -279,7 +279,7 @@ 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=protected-access
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View file

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

View file

@ -12,7 +12,6 @@ from tests.common import async_fire_time_changed
async def test_subscription_registry(hass: HomeAssistant) -> None:
"""Test subscription registry polling."""
subscription_registry = SubscriptionRegistry(hass)
# pylint: disable=protected-access
subscription_registry.poll_server_once = poll_server_once_mock = MagicMock()
poll_server_once_mock.return_value = True

View file

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

View file

@ -166,6 +166,7 @@ async def test_data_manager_webhook_subscription(
# 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,7 @@ async def test_config_reauth_profile(
{},
)
# pylint: disable=protected-access
# pylint: disable-next=protected-access
state = config_entry_oauth2_flow._encode_jwt(
hass,
{

View file

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

View file

@ -130,8 +130,6 @@ async def test_check_available_success(
hass, device_with_basic_channel, zha_device_restored
):
"""Check device availability success on 1st try."""
# pylint: disable=protected-access
zha_device = await zha_device_restored(device_with_basic_channel)
await async_enable_traffic(hass, [zha_device])
basic_ch = device_with_basic_channel.endpoints[3].basic
@ -185,7 +183,6 @@ async def test_check_available_unsuccessful(
):
"""Check device availability all tries fail."""
# pylint: disable=protected-access
zha_device = await zha_device_restored(device_with_basic_channel)
await async_enable_traffic(hass, [zha_device])
basic_ch = device_with_basic_channel.endpoints[3].basic
@ -228,7 +225,6 @@ async def test_check_available_no_basic_channel(
):
"""Check device availability for a device without basic cluster."""
# pylint: disable=protected-access
zha_device = await zha_device_restored(device_without_basic_channel)
await async_enable_traffic(hass, [zha_device])