Lint exclusions (#28655)

* Remove malformed pylint disable markers

* Remove some unused imports

* Remove some unneeded lint exclusions

* Remove more unneeded lint exclusions

* Add specific codes to all noqa's
pull/28810/head
Ville Skyttä 2019-11-16 11:22:07 +02:00 committed by Fabian Affolter
parent 2aee366a1f
commit d88ca0f5cb
73 changed files with 113 additions and 142 deletions

View File

@ -1,18 +1,6 @@
"""Permissions for Home Assistant."""
import logging
from typing import ( # noqa: F401
cast,
Any,
Callable,
Dict,
List,
Mapping,
Optional,
Set,
Tuple,
Union,
TYPE_CHECKING,
)
from typing import Any, Callable, Optional
import voluptuous as vol
@ -20,7 +8,7 @@ from .const import CAT_ENTITIES
from .models import PermissionLookup
from .types import PolicyType
from .entities import ENTITY_POLICY_SCHEMA, compile_entities
from .merge import merge_policies # noqa
from .merge import merge_policies # noqa: F401
from .util import test_all

View File

@ -5,8 +5,8 @@ import attr
if TYPE_CHECKING:
# pylint: disable=unused-import
from homeassistant.helpers import entity_registry as ent_reg # noqa
from homeassistant.helpers import device_registry as dev_reg # noqa
from homeassistant.helpers import entity_registry as ent_reg # noqa: F401
from homeassistant.helpers import device_registry as dev_reg # noqa: F401
@attr.s(slots=True)

View File

@ -21,8 +21,9 @@ def lookup_all(
def compile_policy(
policy: CategoryType, subcategories: SubCatLookupType, perm_lookup: PermissionLookup
) -> Callable[[str, str], bool]: # noqa
) -> Callable[[str, str], bool]:
"""Compile policy into a function that tests policy.
Subcategories are mapping key -> lookup function, ordered by highest
priority first.
"""
@ -80,7 +81,7 @@ def compile_policy(
def _gen_dict_test_func(
perm_lookup: PermissionLookup, lookup_func: LookupFunc, lookup_dict: SubCategoryDict
) -> Callable[[str, str], Optional[bool]]: # noqa
) -> Callable[[str, str], Optional[bool]]:
"""Generate a lookup function."""
def test_value(object_id: str, key: str) -> Optional[bool]:

View File

@ -3,7 +3,7 @@ from datetime import timedelta
import logging
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -14,7 +14,7 @@ from homeassistant.const import (
SERVICE_ALARM_ARM_NIGHT,
SERVICE_ALARM_ARM_CUSTOM_BYPASS,
)
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
ENTITY_SERVICE_SCHEMA,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,

View File

@ -12,7 +12,7 @@ from homeassistant.const import ATTR_CREDENTIALS, CONF_NAME, CONF_PROFILE_NAME
from homeassistant.helpers import config_validation as cv, discovery
# Loading the config flow file will register the flow
from . import config_flow # noqa
from . import config_flow # noqa: F401
from .const import (
CONF_ACCESS_KEY_ID,
CONF_CONTEXT,

View File

@ -8,7 +8,7 @@ import voluptuous as vol
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import Entity
from homeassistant.const import STATE_ON, STATE_OFF
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -7,7 +7,7 @@ from aiohttp import web
from homeassistant.components import http
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
time_period_str,

View File

@ -24,7 +24,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.loader import bind_hass
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -17,7 +17,7 @@ from homeassistant.const import (
TEMP_CELSIUS,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
ENTITY_SERVICE_SCHEMA,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,

View File

@ -9,7 +9,7 @@ import voluptuous as vol
from homeassistant.loader import bind_hass
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -15,7 +15,7 @@ from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util import Throttle
from . import config_flow # noqa pylint_disable=unused-import
from . import config_flow # noqa: F401
_LOGGER = logging.getLogger(__name__)

View File

@ -13,11 +13,11 @@ from homeassistant.helpers.event import async_track_utc_time_change
from homeassistant.const import ATTR_GPS_ACCURACY, STATE_HOME
from . import legacy, setup
from .config_entry import ( # noqa # pylint: disable=unused-import
from .config_entry import ( # noqa: F401 pylint: disable=unused-import
async_setup_entry,
async_unload_entry,
)
from .legacy import DeviceScanner # noqa # pylint: disable=unused-import
from .legacy import DeviceScanner # noqa: F401 pylint: disable=unused-import
from .const import (
ATTR_ATTRIBUTES,
ATTR_BATTERY,

View File

@ -12,7 +12,7 @@ from homeassistant.components.image_processing import (
)
# pylint: disable=unused-import
from homeassistant.components.image_processing import PLATFORM_SCHEMA # noqa
from homeassistant.components.image_processing import PLATFORM_SCHEMA # noqa: F401
from homeassistant.core import split_entity_id
_LOGGER = logging.getLogger(__name__)

View File

@ -14,10 +14,10 @@ from homeassistant.const import (
CONF_TEMPERATURE_UNIT,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant, callback # noqa
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, discovery
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType # noqa
from homeassistant.helpers.typing import ConfigType
DOMAIN = "elkm1"

View File

@ -38,7 +38,7 @@ from homeassistant.helpers.template import Template
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
# Import config flow so that it's added to the registry
from .config_flow import EsphomeFlowHandler # noqa
from .config_flow import EsphomeFlowHandler # noqa: F401
from .entry_data import (
DATA_KEY,
DISPATCHER_ON_DEVICE_UPDATE,

View File

@ -11,7 +11,7 @@ from homeassistant.const import SERVICE_TURN_ON, SERVICE_TOGGLE, SERVICE_TURN_OF
from homeassistant.loader import bind_hass
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
ENTITY_SERVICE_SCHEMA,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,

View File

@ -4,7 +4,7 @@ import logging
from typing import Optional
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -363,7 +363,7 @@ class HomeKit:
self.status = STATUS_WAIT
# pylint: disable=unused-import
from . import ( # noqa F401
from . import ( # noqa: F401
type_covers,
type_fans,
type_lights,

View File

@ -13,7 +13,7 @@ from homeassistant.helpers import device_registry as dr
from .config_flow import HomekitControllerFlowHandler # noqa: F401
from .connection import get_accessory_information, HKDevice
from .const import CONTROLLER, ENTITY_MAP, KNOWN_DEVICES
from .const import DOMAIN # noqa: pylint: disable=unused-import
from .const import DOMAIN
from .storage import EntityMapStorage
_LOGGER = logging.getLogger(__name__)

View File

@ -20,11 +20,11 @@ from homeassistant.util import ssl as ssl_util
from .auth import setup_auth
from .ban import setup_bans
from .const import KEY_AUTHENTICATED, KEY_HASS, KEY_HASS_USER, KEY_REAL_IP # noqa
from .const import KEY_AUTHENTICATED, KEY_HASS, KEY_HASS_USER, KEY_REAL_IP # noqa: F401
from .cors import setup_cors
from .real_ip import setup_real_ip
from .static import CACHE_HEADERS, CachingStaticResource
from .view import HomeAssistantView # noqa
from .view import HomeAssistantView # noqa: F401
# mypy: allow-untyped-defs, no-check-untyped-defs

View File

@ -1,7 +1,7 @@
"""Component for the Portuguese weather service - IPMA."""
from homeassistant.core import Config, HomeAssistant
from .config_flow import IpmaFlowHandler # noqa
from .const import DOMAIN # noqa
from .config_flow import IpmaFlowHandler # noqa: F401
from .const import DOMAIN # noqa: F401
DEFAULT_NAME = "ipma"

View File

@ -19,7 +19,7 @@ from homeassistant.const import (
)
from homeassistant.exceptions import UnknownUser, Unauthorized
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
ENTITY_SERVICE_SCHEMA,

View File

@ -8,7 +8,7 @@ import voluptuous as vol
from homeassistant.loader import bind_hass
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
ENTITY_SERVICE_SCHEMA,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,

View File

@ -7,7 +7,7 @@ config_entry_flow.register_webhook_flow(
DOMAIN,
"Mailgun Webhook",
{
"mailgun_url": "https://documentation.mailgun.com/en/latest/user_manual.html#webhooks", # noqa: E501 pylint: disable=line-too-long
"mailgun_url": "https://documentation.mailgun.com/en/latest/user_manual.html#webhooks",
"docs_url": "https://www.home-assistant.io/integrations/mailgun/",
},
)

View File

@ -39,7 +39,7 @@ from homeassistant.const import (
)
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
ENTITY_SERVICE_SCHEMA,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,

View File

@ -1,7 +1,7 @@
"""The met component."""
from homeassistant.core import Config, HomeAssistant
from .config_flow import MetFlowHandler # noqa
from .const import DOMAIN # noqa
from .config_flow import MetFlowHandler # noqa: F401
from .const import DOMAIN # noqa: F401
async def async_setup(hass: HomeAssistant, config: Config) -> bool:

View File

@ -111,7 +111,7 @@ def error_response(
def supports_encryption() -> bool:
"""Test if we support encryption."""
try:
import nacl # noqa pylint: disable=unused-import
import nacl # noqa: F401 pylint: disable=unused-import
return True
except OSError:

View File

@ -47,7 +47,7 @@ from homeassistant.util.async_ import run_callback_threadsafe
from homeassistant.util.logging import catch_log_exception
# Loading the config flow file will register the flow
from . import config_flow, discovery, server # noqa pylint: disable=unused-import
from . import config_flow, discovery, server # noqa: F401 pylint: disable=unused-import
from .const import (
CONF_BROKER,
CONF_DISCOVERY,

View File

@ -12,7 +12,7 @@ CONF_CLOUDHOOK = "cloudhook"
def supports_encryption():
"""Test if we support encryption."""
try:
import nacl # noqa pylint: disable=unused-import
import nacl # noqa: F401 pylint: disable=unused-import
return True
except OSError:

View File

@ -17,7 +17,7 @@ from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util.dt import as_local, parse_datetime, utc_from_timestamp
from . import config_flow # noqa pylint_disable=unused-import
from . import config_flow
from .const import (
CONF_WEBHOOK_URL,
DOMAIN,

View File

@ -16,7 +16,7 @@ from homeassistant.const import (
SERVICE_TOGGLE,
)
from homeassistant.components import group
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
ENTITY_SERVICE_SCHEMA,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,

View File

@ -15,7 +15,7 @@ from homeassistant.const import (
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
)
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -20,7 +20,7 @@ from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from .config_flow import SmartThingsFlowHandler # noqa
from .config_flow import SmartThingsFlowHandler # noqa: F401
from .const import (
CONF_APP_ID,
CONF_INSTALLED_APP_ID,

View File

@ -7,7 +7,7 @@ import voluptuous as vol
from homeassistant.loader import bind_hass
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -10,7 +10,7 @@ from homeassistant import config_entries
from homeassistant.const import CONF_SCAN_INTERVAL
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_call_later
from . import config_flow # noqa pylint_disable=unused-import
from . import config_flow # noqa: F401
from .const import (
CONF_HOST,
DOMAIN,

View File

@ -1,7 +1,7 @@
"""Consts used by TelldusLive."""
from datetime import timedelta
from homeassistant.const import ( # noqa pylint: disable=unused-import
from homeassistant.const import ( # noqa: F401 pylint: disable=unused-import
ATTR_BATTERY_LEVEL,
CONF_HOST,
CONF_TOKEN,

View File

@ -89,25 +89,23 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
try:
# Verify that the TensorFlow Object Detection API is pre-installed
# pylint: disable=unused-import,unused-variable
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
# These imports shouldn't be moved to the top, because they depend on code from the model_dir.
# (The model_dir is created during the manual setup process. See integration docs.)
import tensorflow as tf # noqa
from object_detection.utils import label_map_util # noqa
import tensorflow as tf
from object_detection.utils import label_map_util
except ImportError:
# pylint: disable=line-too-long
_LOGGER.error(
"No TensorFlow Object Detection library found! Install or compile "
"for your system following instructions here: "
"https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md"
) # noqa
)
return
try:
# Display warning that PIL will be used if no OpenCV is found.
# pylint: disable=unused-import,unused-variable
import cv2 # noqa
import cv2 # noqa: F401
except ImportError:
_LOGGER.warning(
"No OpenCV library found. TensorFlow will process image with "

View File

@ -13,7 +13,7 @@ from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.dispatcher import dispatcher_send, async_dispatcher_connect
from . import config_flow # noqa pylint_disable=unused-import
from . import config_flow # noqa: F401
from .const import (
CONF_CLIENT_ID,
CONF_CLIENT_SECRET,
@ -139,7 +139,7 @@ class ToonData:
"""Update all Toon data and notify entities."""
# Ignore the TTL meganism from client library
# It causes a lots of issues, hence we take control over caching
self._toon._clear_cache() # noqa pylint: disable=W0212
self._toon._clear_cache() # pylint: disable=W0212
# Gather data from client library (single API call)
self.gas = self._toon.gas

View File

@ -10,7 +10,7 @@ from homeassistant import config_entries
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.util.json import load_json
from . import config_flow # noqa pylint_disable=unused-import
from . import config_flow # noqa: F401
from .const import (
DOMAIN,
CONFIG_FILE,

View File

@ -1,6 +1,6 @@
"""Consts used by Tradfri."""
from homeassistant.components.light import SUPPORT_TRANSITION, SUPPORT_BRIGHTNESS
from homeassistant.const import CONF_HOST # noqa pylint: disable=unused-import
from homeassistant.const import CONF_HOST # noqa: F401 pylint: disable=unused-import
ATTR_DIMMER = "dimmer"
ATTR_HUE = "hue"

View File

@ -18,7 +18,7 @@ from homeassistant.const import ( # noqa: F401 # STATE_PAUSED/IDLE are API
)
from homeassistant.loader import bind_hass
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
ENTITY_SERVICE_SCHEMA,
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,

View File

@ -9,7 +9,7 @@ from homeassistant.helpers.temperature import display_temp as show_temp
from homeassistant.util.temperature import convert as convert_temperature
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -3,7 +3,7 @@ from datetime import timedelta
import logging
from homeassistant.const import PRECISION_TENTHS, PRECISION_WHOLE, TEMP_CELSIUS
from homeassistant.helpers.config_validation import ( # noqa
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)

View File

@ -8,7 +8,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE
# Loading the config flow file will register the flow
from . import config_flow # noqa # pylint: disable=unused-import
from . import config_flow # noqa: F401 pylint: disable=unused-import
from . import api
from .core import ZHAGateway
from .core.const import (
@ -101,7 +101,7 @@ async def async_setup_entry(hass, config_entry):
# needs to be done here so that the ZHA module is finished loading
# before zhaquirks is imported
# pylint: disable=W0611, W0612
import zhaquirks # noqa
import zhaquirks # noqa: F401
zha_gateway = ZHAGateway(hass, config, config_entry)
await zha_gateway.async_initialize()

View File

@ -395,14 +395,14 @@ class EventRelayChannel(ZigbeeChannel):
# pylint: disable=wrong-import-position
from . import closures # noqa
from . import general # noqa
from . import homeautomation # noqa
from . import hvac # noqa
from . import lighting # noqa
from . import lightlink # noqa
from . import manufacturerspecific # noqa
from . import measurement # noqa
from . import protocol # noqa
from . import security # noqa
from . import smartenergy # noqa
from . import closures # noqa: F401
from . import general # noqa: F401
from . import homeautomation # noqa: F401
from . import hvac # noqa: F401
from . import lighting # noqa: F401
from . import lightlink # noqa: F401
from . import manufacturerspecific # noqa: F401
from . import measurement # noqa: F401
from . import protocol # noqa: F401
from . import security # noqa: F401
from . import smartenergy # noqa: F401

View File

@ -1,7 +1,7 @@
"""Decorators for ZHA core registries."""
from typing import Callable, TypeVar, Union
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # noqa pylint: disable=invalid-name
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name
class DictRegistry(dict):

View File

@ -27,7 +27,7 @@ from homeassistant.components.sensor import DOMAIN as SENSOR
from homeassistant.components.switch import DOMAIN as SWITCH
# importing channels updates registries
from . import channels # noqa pylint: disable=wrong-import-position,unused-import
from . import channels # noqa: F401 pylint: disable=wrong-import-position,unused-import
from .const import (
CONTROLLER,
SENSOR_ACCELERATION,

View File

@ -35,7 +35,7 @@ from homeassistant.helpers.dispatcher import (
)
from . import const
from . import config_flow # noqa pylint: disable=unused-import
from . import config_flow # noqa: F401 pylint: disable=unused-import
from . import websocket_api as wsapi
from .const import (
CONF_AUTOHEAL,

View File

@ -68,7 +68,7 @@ from homeassistant.util.async_ import run_callback_threadsafe, fire_coroutine_th
from homeassistant import util
import homeassistant.util.dt as dt_util
from homeassistant.util import location, slugify
from homeassistant.util.unit_system import ( # NOQA
from homeassistant.util.unit_system import (
UnitSystem,
IMPERIAL_SYSTEM,
METRIC_SYSTEM,

View File

@ -5,7 +5,7 @@ import jinja2
# pylint: disable=using-constant-test
if TYPE_CHECKING:
# pylint: disable=unused-import
from .core import Context # noqa
from .core import Context # noqa: F401
class HomeAssistantError(Exception):

View File

@ -28,9 +28,9 @@ from typing import (
# Typing imports that create a circular dependency
# pylint: disable=using-constant-test,unused-import
if TYPE_CHECKING:
from homeassistant.core import HomeAssistant # noqa
from homeassistant.core import HomeAssistant
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # noqa pylint: disable=invalid-name
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name
DEPENDENCY_BLACKLIST = {"config"}

View File

@ -68,6 +68,6 @@ def disable_c_asyncio() -> None:
sys.path.insert(0, AsyncioImportFinder.PATH_TRIGGER)
try:
import _asyncio # noqa
import _asyncio # noqa: F401
except ImportError:
pass

View File

@ -15,7 +15,7 @@ from typing import (
TypeVar,
Callable,
KeysView,
Union, # noqa
Union,
Iterable,
Coroutine,
)

View File

@ -1,7 +1,7 @@
"""Decorator utility functions."""
from typing import Callable, TypeVar
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # noqa pylint: disable=invalid-name
CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable) # pylint: disable=invalid-name
class Registry(dict):

View File

@ -76,14 +76,14 @@ def _add_reference(
...
@overload # noqa: F811
@overload
def _add_reference(
obj: Union[str, NodeStrClass], loader: yaml.SafeLoader, node: yaml.nodes.Node
) -> NodeStrClass:
...
@overload # noqa: F811
@overload
def _add_reference(
obj: DICT_T, loader: yaml.SafeLoader, node: yaml.nodes.Node
) -> DICT_T:
@ -93,7 +93,7 @@ def _add_reference(
# pylint: enable=pointless-statement
def _add_reference( # type: ignore # noqa: F811
def _add_reference( # type: ignore
obj, loader: SafeLineLoader, node: yaml.nodes.Node
):
"""Add file reference information to an object."""

View File

@ -56,7 +56,7 @@ from homeassistant.helpers.json import JSONEncoder
from homeassistant.setup import async_setup_component, setup_component
from homeassistant.util.unit_system import METRIC_SYSTEM
from homeassistant.util.async_ import run_callback_threadsafe
from homeassistant.components.device_automation import ( # noqa
from homeassistant.components.device_automation import ( # noqa: F401
_async_get_device_automations as async_get_device_automations,
_async_get_device_automation_capabilities as async_get_device_automation_capabilities,
)
@ -1084,7 +1084,7 @@ class hashdict(dict):
"""
def __key(self): # noqa: D105 no docstring
def __key(self):
return tuple(sorted(self.items()))
def __repr__(self): # noqa: D105 no docstring

View File

@ -14,7 +14,7 @@ from homeassistant.setup import setup_component
from tests.common import get_test_home_assistant, assert_setup_component, mock_service
from tests.components.tts.test_init import mutagen_mock # noqa
from tests.components.tts.test_init import mutagen_mock # noqa: F401
class TestTTSGooglePlatform:

View File

@ -76,7 +76,7 @@ async def test_step_import(hass, mock_logi_circle): # pylint: disable=W0621
async def test_full_flow_implementation(
hass, mock_logi_circle
): # noqa pylint: disable=W0621
): # pylint: disable=W0621
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(
hass,
@ -154,7 +154,7 @@ async def test_abort_if_already_setup(hass):
)
async def test_abort_if_authorize_fails(
hass, mock_logi_circle, side_effect, error
): # noqa pylint: disable=W0621
): # pylint: disable=W0621
"""Test we abort if authorizing fails."""
flow = init_config_flow(hass)
mock_logi_circle.LogiCircle().authorize.side_effect = side_effect
@ -206,7 +206,7 @@ async def test_callback_view_rejects_missing_code(hass):
async def test_callback_view_accepts_code(
hass, mock_logi_circle
): # noqa pylint: disable=W0621
): # pylint: disable=W0621
"""Test the auth callback view handles requests with auth code."""
init_config_flow(hass)
view = LogiCircleAuthCallbackView()

View File

@ -12,7 +12,7 @@ from homeassistant.components.media_player.const import (
from tests.common import get_test_home_assistant, assert_setup_component, mock_service
from tests.components.tts.test_init import mutagen_mock # noqa
from tests.components.tts.test_init import mutagen_mock # noqa: F401
class TestTTSMaryTTSPlatform:

View File

@ -1,13 +1,11 @@
"""Entity tests for mobile_app."""
# pylint: disable=redefined-outer-name,unused-import
import logging
_LOGGER = logging.getLogger(__name__)
async def test_sensor(
hass, create_registrations, webhook_client
): # noqa: F401, F811, E501
async def test_sensor(hass, create_registrations, webhook_client):
"""Test that sensors can be registered and updated."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = "/api/webhook/{}".format(webhook_id)
@ -67,9 +65,7 @@ async def test_sensor(
assert updated_entity.state == "123"
async def test_sensor_must_register(
hass, create_registrations, webhook_client # noqa: F401, F811, E501
): # noqa: F401, F811, E501
async def test_sensor_must_register(hass, create_registrations, webhook_client):
"""Test that sensors must be registered before updating."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = "/api/webhook/{}".format(webhook_id)
@ -88,9 +84,7 @@ async def test_sensor_must_register(
assert json["battery_state"]["error"]["code"] == "not_registered"
async def test_sensor_id_no_dupes(
hass, create_registrations, webhook_client # noqa: F401, F811, E501
): # noqa: F401, F811, E501
async def test_sensor_id_no_dupes(hass, create_registrations, webhook_client):
"""Test that sensors must have a unique ID."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = "/api/webhook/{}".format(webhook_id)

View File

@ -12,9 +12,8 @@ from .const import REGISTER, RENDER_TEMPLATE
async def test_registration(hass, hass_client):
"""Test that registrations happen."""
try:
# pylint: disable=unused-import
from nacl.secret import SecretBox # noqa: F401
from nacl.encoding import Base64Encoder # noqa: F401
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder
except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed")
return

View File

@ -1,5 +1,5 @@
"""Webhook tests for mobile_app."""
# pylint: disable=redefined-outer-name,unused-import
import logging
import pytest
@ -29,9 +29,7 @@ async def test_webhook_handle_render_template(create_registrations, webhook_clie
assert json == {"one": "Hello world"}
async def test_webhook_handle_call_services(
hass, create_registrations, webhook_client
): # noqa: E501 F811
async def test_webhook_handle_call_services(hass, create_registrations, webhook_client):
"""Test that we call services properly."""
calls = async_mock_service(hass, "test", "mobile_app")
@ -68,9 +66,7 @@ async def test_webhook_handle_fire_event(hass, create_registrations, webhook_cli
assert events[0].data["hello"] == "yo world"
async def test_webhook_update_registration(
webhook_client, hass_client
): # noqa: E501 F811
async def test_webhook_update_registration(webhook_client, hass_client):
"""Test that a we can update an existing registration via webhook."""
authed_api_client = await hass_client()
register_resp = await authed_api_client.post(
@ -156,7 +152,7 @@ async def test_webhook_handle_get_config(hass, create_registrations, webhook_cli
async def test_webhook_returns_error_incorrect_json(
webhook_client, create_registrations, caplog
): # noqa: E501 F811
):
"""Test that an error is returned when JSON is invalid."""
resp = await webhook_client.post(
"/api/webhook/{}".format(create_registrations[1]["webhook_id"]), data="not json"
@ -171,9 +167,8 @@ async def test_webhook_returns_error_incorrect_json(
async def test_webhook_handle_decryption(webhook_client, create_registrations):
"""Test that we can encrypt/decrypt properly."""
try:
# pylint: disable=unused-import
from nacl.secret import SecretBox # noqa: F401
from nacl.encoding import Base64Encoder # noqa: F401
from nacl.secret import SecretBox
from nacl.encoding import Base64Encoder
except (ImportError, OSError):
pytest.skip("libnacl/libsodium is not installed")
return

View File

@ -9,13 +9,13 @@ from homeassistant.components import onboarding
from homeassistant.components.onboarding import const, views
from tests.common import CLIENT_ID, register_auth_provider
from tests.components.met.conftest import mock_weather # noqa
from tests.components.met.conftest import mock_weather # noqa: F401
from . import mock_storage
@pytest.fixture(autouse=True)
def always_mock_weather(mock_weather): # noqa
def always_mock_weather(mock_weather): # noqa: F811
"""Mock the Met weather provider."""
pass

View File

@ -66,9 +66,7 @@ async def test_abort_if_already_setup(hass):
assert result["reason"] == "already_setup"
async def test_full_flow_implementation(
hass, mock_pypoint
): # noqa pylint: disable=W0621
async def test_full_flow_implementation(hass, mock_pypoint): # pylint: disable=W0621
"""Test registering an implementation and finishing flow works."""
config_flow.register_flow_implementation(hass, "test-other", None, None)
flow = init_config_flow(hass)
@ -106,7 +104,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
): # noqa pylint: disable=W0621
): # pylint: disable=W0621
"""Test wrong code."""
flow = init_config_flow(hass)

View File

@ -57,7 +57,7 @@ def aioclient_mock():
yield mock_session
async def test_binary_sensor_device(hass, aioclient_mock): # noqa
async def test_binary_sensor_device(hass, aioclient_mock): # noqa: F811
"""Test a binary sensor device."""
config = {
"qwikswitch": {
@ -86,7 +86,7 @@ async def test_binary_sensor_device(hass, aioclient_mock): # noqa
assert state_obj.state == "off"
async def test_sensor_device(hass, aioclient_mock): # noqa
async def test_sensor_device(hass, aioclient_mock): # noqa: F811
"""Test a sensor device."""
config = {
"qwikswitch": {

View File

@ -13,7 +13,7 @@ from homeassistant.setup import setup_component
from tests.common import get_test_home_assistant, assert_setup_component, mock_service
from tests.components.tts.test_init import mutagen_mock # noqa
from tests.components.tts.test_init import mutagen_mock # noqa: F401
class TestTTSVoiceRSSPlatform:

View File

@ -11,7 +11,7 @@ from homeassistant.components.media_player.const import (
)
from tests.common import get_test_home_assistant, assert_setup_component, mock_service
from tests.components.tts.test_init import mutagen_mock # noqa
from tests.components.tts.test_init import mutagen_mock # noqa: F401
class TestTTSYandexPlatform:

View File

@ -1,6 +1,5 @@
"""Test check_config helper."""
import logging
import os # noqa: F401 pylint: disable=unused-import
from unittest.mock import patch
from homeassistant.helpers.check_config import (

View File

@ -9,7 +9,7 @@ import voluptuous as vol
import pytest
# To prevent circular import when running just this file
import homeassistant.components # noqa
import homeassistant.components # noqa: F401
from homeassistant import core as ha, exceptions
from homeassistant.const import STATE_ON, STATE_OFF, ATTR_ENTITY_ID
from homeassistant.setup import async_setup_component

View File

@ -1,6 +1,5 @@
"""Test check_config script."""
import logging
import os # noqa: F401 pylint: disable=unused-import
from unittest.mock import patch
import homeassistant.scripts.check_config as check_config

View File

@ -1,5 +1,5 @@
"""Provide a mock package component."""
from .const import TEST # noqa
from .const import TEST # noqa: F401
DOMAIN = "test_package"

View File

@ -165,7 +165,7 @@ class RunThreadsafeTests(TestCase):
def test_run_callback_threadsafe_with_invalid(self):
"""Test callback submission from thread to event loop on invalid."""
callback = lambda: self.target_callback(invalid=True) # noqa
callback = lambda: self.target_callback(invalid=True) # noqa: E731
future = self.loop.run_in_executor(None, callback)
with self.assertRaises(ValueError) as exc_context:
self.loop.run_until_complete(future)