mirror of
https://github.com/esphome/esphome.git
synced 2024-11-29 02:04:13 +01:00
Remove a bunch of unnecessary pylint disabling (#4079)
This commit is contained in:
parent
81b4078871
commit
b184b01600
16 changed files with 24 additions and 54 deletions
|
@ -24,7 +24,6 @@ AUTO_LOAD = ["modbus"]
|
||||||
|
|
||||||
MULTI_CONF = True
|
MULTI_CONF = True
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
modbus_controller_ns = cg.esphome_ns.namespace("modbus_controller")
|
modbus_controller_ns = cg.esphome_ns.namespace("modbus_controller")
|
||||||
ModbusController = modbus_controller_ns.class_(
|
ModbusController = modbus_controller_ns.class_(
|
||||||
"ModbusController", cg.PollingComponent, modbus.ModbusDevice
|
"ModbusController", cg.PollingComponent, modbus.ModbusDevice
|
||||||
|
|
|
@ -14,7 +14,6 @@ from esphome.core import CORE, coroutine_with_priority
|
||||||
|
|
||||||
IS_PLATFORM_COMPONENT = True
|
IS_PLATFORM_COMPONENT = True
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
stepper_ns = cg.esphome_ns.namespace("stepper")
|
stepper_ns = cg.esphome_ns.namespace("stepper")
|
||||||
Stepper = stepper_ns.class_("Stepper")
|
Stepper = stepper_ns.class_("Stepper")
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ from esphome.util import Registry
|
||||||
|
|
||||||
IS_PLATFORM_COMPONENT = True
|
IS_PLATFORM_COMPONENT = True
|
||||||
|
|
||||||
# pylint: disable=invalid-name
|
|
||||||
text_sensor_ns = cg.esphome_ns.namespace("text_sensor")
|
text_sensor_ns = cg.esphome_ns.namespace("text_sensor")
|
||||||
TextSensor = text_sensor_ns.class_("TextSensor", cg.EntityBase)
|
TextSensor = text_sensor_ns.class_("TextSensor", cg.EntityBase)
|
||||||
TextSensorPtr = TextSensor.operator("ptr")
|
TextSensorPtr = TextSensor.operator("ptr")
|
||||||
|
|
|
@ -4,7 +4,8 @@ import heapq
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# pylint: disable=unused-import, wrong-import-order
|
from typing import Optional, Union
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -23,7 +24,6 @@ from esphome.core import CORE, EsphomeError
|
||||||
from esphome.helpers import indent
|
from esphome.helpers import indent
|
||||||
from esphome.util import safe_print, OrderedDict
|
from esphome.util import safe_print, OrderedDict
|
||||||
|
|
||||||
from typing import Optional, Union
|
|
||||||
from esphome.loader import get_component, get_platform, ComponentManifest
|
from esphome.loader import get_component, get_platform, ComponentManifest
|
||||||
from esphome.yaml_util import is_secret, ESPHomeDataBase, ESPForceValue
|
from esphome.yaml_util import is_secret, ESPHomeDataBase, ESPForceValue
|
||||||
from esphome.voluptuous_schema import ExtraKeysInvalid
|
from esphome.voluptuous_schema import ExtraKeysInvalid
|
||||||
|
|
|
@ -26,7 +26,6 @@ def read_config_file(path: str) -> str:
|
||||||
|
|
||||||
def merge_config(full_old, full_new):
|
def merge_config(full_old, full_new):
|
||||||
def merge(old, new):
|
def merge(old, new):
|
||||||
# pylint: disable=no-else-return
|
|
||||||
if isinstance(new, dict):
|
if isinstance(new, dict):
|
||||||
if not isinstance(old, dict):
|
if not isinstance(old, dict):
|
||||||
return new
|
return new
|
||||||
|
@ -34,11 +33,11 @@ def merge_config(full_old, full_new):
|
||||||
for k, v in new.items():
|
for k, v in new.items():
|
||||||
res[k] = merge(old[k], v) if k in old else v
|
res[k] = merge(old[k], v) if k in old else v
|
||||||
return res
|
return res
|
||||||
elif isinstance(new, list):
|
if isinstance(new, list):
|
||||||
if not isinstance(old, list):
|
if not isinstance(old, list):
|
||||||
return new
|
return new
|
||||||
return old + new
|
return old + new
|
||||||
elif new is None:
|
if new is None:
|
||||||
return old
|
return old
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
|
@ -1053,9 +1053,8 @@ def mqtt_qos(value):
|
||||||
|
|
||||||
def requires_component(comp):
|
def requires_component(comp):
|
||||||
"""Validate that this option can only be specified when the component `comp` is loaded."""
|
"""Validate that this option can only be specified when the component `comp` is loaded."""
|
||||||
# pylint: disable=unsupported-membership-test
|
|
||||||
def validator(value):
|
def validator(value):
|
||||||
# pylint: disable=unsupported-membership-test
|
|
||||||
if comp not in CORE.loaded_integrations:
|
if comp not in CORE.loaded_integrations:
|
||||||
raise Invalid(f"This option requires component {comp}")
|
raise Invalid(f"This option requires component {comp}")
|
||||||
return value
|
return value
|
||||||
|
@ -1482,7 +1481,6 @@ class OnlyWith(Optional):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default(self):
|
def default(self):
|
||||||
# pylint: disable=unsupported-membership-test
|
|
||||||
if self._component in CORE.loaded_integrations:
|
if self._component in CORE.loaded_integrations:
|
||||||
return self._default
|
return self._default
|
||||||
return vol.UNDEFINED
|
return vol.UNDEFINED
|
||||||
|
|
|
@ -443,7 +443,7 @@ class Library:
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-instance-attributes,too-many-public-methods
|
# pylint: disable=too-many-public-methods
|
||||||
class EsphomeCore:
|
class EsphomeCore:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# True if command is run from dashboard
|
# True if command is run from dashboard
|
||||||
|
@ -553,7 +553,6 @@ class EsphomeCore:
|
||||||
return os.path.basename(self.config_path)
|
return os.path.basename(self.config_path)
|
||||||
|
|
||||||
def relative_config_path(self, *path):
|
def relative_config_path(self, *path):
|
||||||
# pylint: disable=no-value-for-parameter
|
|
||||||
path_ = os.path.expanduser(os.path.join(*path))
|
path_ = os.path.expanduser(os.path.join(*path))
|
||||||
return os.path.join(self.config_dir, path_)
|
return os.path.join(self.config_dir, path_)
|
||||||
|
|
||||||
|
@ -561,7 +560,6 @@ class EsphomeCore:
|
||||||
return self.relative_config_path(".esphome", *path)
|
return self.relative_config_path(".esphome", *path)
|
||||||
|
|
||||||
def relative_build_path(self, *path):
|
def relative_build_path(self, *path):
|
||||||
# pylint: disable=no-value-for-parameter
|
|
||||||
path_ = os.path.expanduser(os.path.join(*path))
|
path_ = os.path.expanduser(os.path.join(*path))
|
||||||
return os.path.join(self.build_path, path_)
|
return os.path.join(self.build_path, path_)
|
||||||
|
|
||||||
|
|
|
@ -2,34 +2,26 @@ import abc
|
||||||
import inspect
|
import inspect
|
||||||
import math
|
import math
|
||||||
import re
|
import re
|
||||||
from esphome.yaml_util import ESPHomeDataBase
|
|
||||||
|
|
||||||
# pylint: disable=unused-import, wrong-import-order
|
|
||||||
from typing import (
|
|
||||||
Any,
|
|
||||||
Callable,
|
|
||||||
Optional,
|
|
||||||
Union,
|
|
||||||
)
|
|
||||||
from collections.abc import Generator, Sequence
|
from collections.abc import Generator, Sequence
|
||||||
|
from typing import Any, Callable, Optional, Union
|
||||||
|
|
||||||
from esphome.core import ( # noqa
|
from esphome.core import (
|
||||||
CORE,
|
CORE,
|
||||||
HexInt,
|
|
||||||
ID,
|
ID,
|
||||||
|
Define,
|
||||||
|
EnumValue,
|
||||||
|
HexInt,
|
||||||
Lambda,
|
Lambda,
|
||||||
|
Library,
|
||||||
TimePeriod,
|
TimePeriod,
|
||||||
TimePeriodMicroseconds,
|
TimePeriodMicroseconds,
|
||||||
TimePeriodMilliseconds,
|
TimePeriodMilliseconds,
|
||||||
TimePeriodMinutes,
|
TimePeriodMinutes,
|
||||||
TimePeriodSeconds,
|
TimePeriodSeconds,
|
||||||
coroutine,
|
|
||||||
Library,
|
|
||||||
Define,
|
|
||||||
EnumValue,
|
|
||||||
)
|
)
|
||||||
from esphome.helpers import cpp_string_escape, indent_all_but_first_and_last
|
from esphome.helpers import cpp_string_escape, indent_all_but_first_and_last
|
||||||
from esphome.util import OrderedDict
|
from esphome.util import OrderedDict
|
||||||
|
from esphome.yaml_util import ESPHomeDataBase
|
||||||
|
|
||||||
|
|
||||||
class Expression(abc.ABC):
|
class Expression(abc.ABC):
|
||||||
|
|
|
@ -11,7 +11,6 @@ from esphome.const import (
|
||||||
CONF_TYPE_ID,
|
CONF_TYPE_ID,
|
||||||
)
|
)
|
||||||
|
|
||||||
# pylint: disable=unused-import
|
|
||||||
from esphome.core import coroutine, ID, CORE
|
from esphome.core import coroutine, ID, CORE
|
||||||
from esphome.types import ConfigType, ConfigFragmentType
|
from esphome.types import ConfigType, ConfigFragmentType
|
||||||
from esphome.cpp_generator import add, get_variable
|
from esphome.cpp_generator import add, get_variable
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
# pylint: disable=wrong-import-position
|
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import codecs
|
import codecs
|
||||||
import collections
|
import collections
|
||||||
|
@ -10,11 +8,12 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
|
||||||
import secrets
|
import secrets
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import tornado
|
import tornado
|
||||||
import tornado.concurrent
|
import tornado.concurrent
|
||||||
|
@ -22,15 +21,15 @@ import tornado.gen
|
||||||
import tornado.httpserver
|
import tornado.httpserver
|
||||||
import tornado.ioloop
|
import tornado.ioloop
|
||||||
import tornado.iostream
|
import tornado.iostream
|
||||||
from tornado.log import access_log
|
|
||||||
import tornado.netutil
|
import tornado.netutil
|
||||||
import tornado.process
|
import tornado.process
|
||||||
import tornado.web
|
import tornado.web
|
||||||
import tornado.websocket
|
import tornado.websocket
|
||||||
|
from tornado.log import access_log
|
||||||
|
|
||||||
from esphome import const, platformio_api, util, yaml_util
|
from esphome import const, platformio_api, util, yaml_util
|
||||||
from esphome.core import EsphomeError
|
from esphome.core import EsphomeError
|
||||||
from esphome.helpers import mkdir_p, get_bool_env, run_system_command
|
from esphome.helpers import get_bool_env, mkdir_p, run_system_command
|
||||||
from esphome.storage_json import (
|
from esphome.storage_json import (
|
||||||
EsphomeStorageJSON,
|
EsphomeStorageJSON,
|
||||||
StorageJSON,
|
StorageJSON,
|
||||||
|
@ -38,14 +37,11 @@ from esphome.storage_json import (
|
||||||
ext_storage_path,
|
ext_storage_path,
|
||||||
trash_storage_path,
|
trash_storage_path,
|
||||||
)
|
)
|
||||||
from esphome.util import shlex_quote, get_serial_ports
|
from esphome.util import get_serial_ports, shlex_quote
|
||||||
from .util import password_hash
|
|
||||||
|
|
||||||
# pylint: disable=unused-import, wrong-import-order
|
|
||||||
from typing import Optional # noqa
|
|
||||||
|
|
||||||
from esphome.zeroconf import DashboardImportDiscovery, DashboardStatus, EsphomeZeroconf
|
from esphome.zeroconf import DashboardImportDiscovery, DashboardStatus, EsphomeZeroconf
|
||||||
|
|
||||||
|
from .util import password_hash
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ENV_DEV = "ESPHOME_DASHBOARD_DEV"
|
ENV_DEV = "ESPHOME_DASHBOARD_DEV"
|
||||||
|
@ -190,7 +186,6 @@ def websocket_method(name):
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=abstract-method, arguments-differ
|
|
||||||
@websocket_class
|
@websocket_class
|
||||||
class EsphomeCommandWebSocket(tornado.websocket.WebSocketHandler):
|
class EsphomeCommandWebSocket(tornado.websocket.WebSocketHandler):
|
||||||
def __init__(self, application, request, **kwargs):
|
def __init__(self, application, request, **kwargs):
|
||||||
|
@ -797,7 +792,6 @@ class EditRequestHandler(BaseHandler):
|
||||||
filename = settings.rel_path(configuration)
|
filename = settings.rel_path(configuration)
|
||||||
content = ""
|
content = ""
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
# pylint: disable=no-value-for-parameter
|
|
||||||
with open(file=filename, encoding="utf-8") as f:
|
with open(file=filename, encoding="utf-8") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
self.write(content)
|
self.write(content)
|
||||||
|
@ -805,7 +799,6 @@ class EditRequestHandler(BaseHandler):
|
||||||
@authenticated
|
@authenticated
|
||||||
@bind_config
|
@bind_config
|
||||||
def post(self, configuration=None):
|
def post(self, configuration=None):
|
||||||
# pylint: disable=no-value-for-parameter
|
|
||||||
with open(file=settings.rel_path(configuration), mode="wb") as f:
|
with open(file=settings.rel_path(configuration), mode="wb") as f:
|
||||||
f.write(self.request.body)
|
f.write(self.request.body)
|
||||||
self.set_status(200)
|
self.set_status(200)
|
||||||
|
|
|
@ -37,7 +37,6 @@ def patch_structhash():
|
||||||
if not isdir(build_dir):
|
if not isdir(build_dir):
|
||||||
makedirs(build_dir)
|
makedirs(build_dir)
|
||||||
|
|
||||||
# pylint: disable=protected-access
|
|
||||||
helpers.clean_build_dir = patched_clean_build_dir
|
helpers.clean_build_dir = patched_clean_build_dir
|
||||||
cli.clean_build_dir = patched_clean_build_dir
|
cli.clean_build_dir = patched_clean_build_dir
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ def trash_storage_path(base_path: str) -> str:
|
||||||
return os.path.join(base_path, ".esphome", "trash")
|
return os.path.join(base_path, ".esphome", "trash")
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-many-instance-attributes
|
|
||||||
class StorageJSON:
|
class StorageJSON:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -204,7 +204,6 @@ class _Schema(vol.Schema):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@schema_extractor_extended
|
@schema_extractor_extended
|
||||||
# pylint: disable=signature-differs
|
|
||||||
def extend(self, *schemas, **kwargs):
|
def extend(self, *schemas, **kwargs):
|
||||||
extra = kwargs.pop("extra", None)
|
extra = kwargs.pop("extra", None)
|
||||||
if kwargs:
|
if kwargs:
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# pylint: disable=unused-import
|
from typing import Optional
|
||||||
|
|
||||||
from esphome.config import load_config, _format_vol_invalid, Config
|
from esphome.config import load_config, _format_vol_invalid, Config
|
||||||
from esphome.core import CORE, DocumentRange
|
from esphome.core import CORE, DocumentRange
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
|
|
||||||
# pylint: disable=unused-import, wrong-import-order
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
|
|
||||||
def _get_invalid_range(res: Config, invalid: cv.Invalid) -> Optional[DocumentRange]:
|
def _get_invalid_range(res: Config, invalid: cv.Invalid) -> Optional[DocumentRange]:
|
||||||
return res.get_deepest_document_range_for_path(
|
return res.get_deepest_document_range_for_path(
|
||||||
|
|
|
@ -9,7 +9,6 @@ import esphome.config_validation as cv
|
||||||
from esphome.helpers import get_bool_env, write_file
|
from esphome.helpers import get_bool_env, write_file
|
||||||
from esphome.log import color, Fore
|
from esphome.log import color, Fore
|
||||||
|
|
||||||
# pylint: disable=anomalous-backslash-in-string
|
|
||||||
from esphome.storage_json import StorageJSON, ext_storage_path
|
from esphome.storage_json import StorageJSON, ext_storage_path
|
||||||
from esphome.util import safe_print
|
from esphome.util import safe_print
|
||||||
from esphome.const import ALLOWED_NAME_CHARS, ENV_QUICKWIZARD
|
from esphome.const import ALLOWED_NAME_CHARS, ENV_QUICKWIZARD
|
||||||
|
|
|
@ -88,7 +88,7 @@ def _add_data_ref(fn):
|
||||||
return wrapped
|
return wrapped
|
||||||
|
|
||||||
|
|
||||||
class ESPHomeLoader(yaml.SafeLoader): # pylint: disable=too-many-ancestors
|
class ESPHomeLoader(yaml.SafeLoader):
|
||||||
"""Loader class that keeps track of line numbers."""
|
"""Loader class that keeps track of line numbers."""
|
||||||
|
|
||||||
@_add_data_ref
|
@_add_data_ref
|
||||||
|
@ -419,7 +419,7 @@ def is_secret(value):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class ESPHomeDumper(yaml.SafeDumper): # pylint: disable=too-many-ancestors
|
class ESPHomeDumper(yaml.SafeDumper):
|
||||||
def represent_mapping(self, tag, mapping, flow_style=None):
|
def represent_mapping(self, tag, mapping, flow_style=None):
|
||||||
value = []
|
value = []
|
||||||
node = yaml.MappingNode(tag, value, flow_style=flow_style)
|
node = yaml.MappingNode(tag, value, flow_style=flow_style)
|
||||||
|
|
Loading…
Reference in a new issue