diff --git a/esphome/components/modbus_controller/__init__.py b/esphome/components/modbus_controller/__init__.py index 41beb67e1c..46bb2c4233 100644 --- a/esphome/components/modbus_controller/__init__.py +++ b/esphome/components/modbus_controller/__init__.py @@ -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 diff --git a/esphome/components/stepper/__init__.py b/esphome/components/stepper/__init__.py index 54f6aa4205..f2367fd62a 100644 --- a/esphome/components/stepper/__init__.py +++ b/esphome/components/stepper/__init__.py @@ -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") diff --git a/esphome/components/text_sensor/__init__.py b/esphome/components/text_sensor/__init__.py index dd3dbddc43..3ed6b72d8f 100644 --- a/esphome/components/text_sensor/__init__.py +++ b/esphome/components/text_sensor/__init__.py @@ -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") diff --git a/esphome/config.py b/esphome/config.py index 0bf4ec8df3..e63cddf347 100644 --- a/esphome/config.py +++ b/esphome/config.py @@ -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 diff --git a/esphome/config_helpers.py b/esphome/config_helpers.py index bfb0f65417..d36a2f1e7f 100644 --- a/esphome/config_helpers.py +++ b/esphome/config_helpers.py @@ -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 diff --git a/esphome/config_validation.py b/esphome/config_validation.py index 90018b4d56..910d624552 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -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 diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index ef44b31fa3..09115c2791 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -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_) diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index a0f60e1ff8..a423554d10 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -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): diff --git a/esphome/cpp_helpers.py b/esphome/cpp_helpers.py index 0ab4b75a16..02d339441f 100644 --- a/esphome/cpp_helpers.py +++ b/esphome/cpp_helpers.py @@ -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 diff --git a/esphome/dashboard/dashboard.py b/esphome/dashboard/dashboard.py index b7c24f9e2e..d38eb0027e 100644 --- a/esphome/dashboard/dashboard.py +++ b/esphome/dashboard/dashboard.py @@ -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) diff --git a/esphome/platformio_api.py b/esphome/platformio_api.py index 70576bec11..ef62e62ce7 100644 --- a/esphome/platformio_api.py +++ b/esphome/platformio_api.py @@ -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 diff --git a/esphome/storage_json.py b/esphome/storage_json.py index 1cc2180747..c2c8b91a36 100644 --- a/esphome/storage_json.py +++ b/esphome/storage_json.py @@ -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, diff --git a/esphome/voluptuous_schema.py b/esphome/voluptuous_schema.py index f4ed2fe03b..281ef10964 100644 --- a/esphome/voluptuous_schema.py +++ b/esphome/voluptuous_schema.py @@ -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: diff --git a/esphome/vscode.py b/esphome/vscode.py index 32a6b524f6..cb2f51976f 100644 --- a/esphome/vscode.py +++ b/esphome/vscode.py @@ -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( diff --git a/esphome/wizard.py b/esphome/wizard.py index 6273eec25d..0fcccfc3f6 100644 --- a/esphome/wizard.py +++ b/esphome/wizard.py @@ -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 diff --git a/esphome/yaml_util.py b/esphome/yaml_util.py index 75aec0edc8..2689ce9245 100644 --- a/esphome/yaml_util.py +++ b/esphome/yaml_util.py @@ -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)