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