From 983a76a91ce5ae2ada276886bb5876530761d09d Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 6 Jun 2022 21:43:47 +0200 Subject: [PATCH] Update pylint to 2.14.0 (#73119) --- homeassistant/components/hassio/http.py | 2 ++ homeassistant/components/hassio/websocket_api.py | 2 ++ homeassistant/components/sentry/__init__.py | 1 - homeassistant/helpers/update_coordinator.py | 2 +- pylint/plugins/hass_constructor.py | 5 +---- pylint/plugins/hass_enforce_type_hints.py | 7 ++----- pylint/plugins/hass_imports.py | 7 ++----- pylint/plugins/hass_logger.py | 7 ++----- pyproject.toml | 4 +--- requirements_test.txt | 2 +- 10 files changed, 14 insertions(+), 25 deletions(-) diff --git a/homeassistant/components/hassio/http.py b/homeassistant/components/hassio/http.py index 63ac1521cc5..497e246ea77 100644 --- a/homeassistant/components/hassio/http.py +++ b/homeassistant/components/hassio/http.py @@ -28,6 +28,7 @@ _LOGGER = logging.getLogger(__name__) MAX_UPLOAD_SIZE = 1024 * 1024 * 1024 +# pylint: disable=implicit-str-concat NO_TIMEOUT = re.compile( r"^(?:" r"|homeassistant/update" @@ -48,6 +49,7 @@ NO_AUTH = re.compile( ) NO_STORE = re.compile(r"^(?:" r"|app/entrypoint.js" r")$") +# pylint: enable=implicit-str-concat class HassIOView(HomeAssistantView): diff --git a/homeassistant/components/hassio/websocket_api.py b/homeassistant/components/hassio/websocket_api.py index 4af090d7154..7eb037d8432 100644 --- a/homeassistant/components/hassio/websocket_api.py +++ b/homeassistant/components/hassio/websocket_api.py @@ -38,9 +38,11 @@ SCHEMA_WEBSOCKET_EVENT = vol.Schema( ) # Endpoints needed for ingress can't require admin because addons can set `panel_admin: false` +# pylint: disable=implicit-str-concat WS_NO_ADMIN_ENDPOINTS = re.compile( r"^(?:" r"|/ingress/(session|validate_session)" r"|/addons/[^/]+/info" r")$" ) +# pylint: enable=implicit-str-concat _LOGGER: logging.Logger = logging.getLogger(__package__) diff --git a/homeassistant/components/sentry/__init__.py b/homeassistant/components/sentry/__init__.py index 3037f1dc374..092358e82f6 100644 --- a/homeassistant/components/sentry/__init__.py +++ b/homeassistant/components/sentry/__init__.py @@ -80,7 +80,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ), } - # pylint: disable-next=abstract-class-instantiated sentry_sdk.init( dsn=entry.data[CONF_DSN], environment=entry.options.get(CONF_ENVIRONMENT), diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index f671e1b973a..fc619469500 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable, Generator from datetime import datetime, timedelta import logging from time import monotonic -from typing import Any, Generic, TypeVar # pylint: disable=unused-import +from typing import Any, Generic, TypeVar import urllib.error import aiohttp diff --git a/pylint/plugins/hass_constructor.py b/pylint/plugins/hass_constructor.py index 525dcfed2e2..23496b68de3 100644 --- a/pylint/plugins/hass_constructor.py +++ b/pylint/plugins/hass_constructor.py @@ -3,19 +3,16 @@ from __future__ import annotations from astroid import nodes from pylint.checkers import BaseChecker -from pylint.interfaces import IAstroidChecker from pylint.lint import PyLinter class HassConstructorFormatChecker(BaseChecker): # type: ignore[misc] """Checker for __init__ definitions.""" - __implements__ = IAstroidChecker - name = "hass_constructor" priority = -1 msgs = { - "W0006": ( + "W7411": ( '__init__ should have explicit return type "None"', "hass-constructor-return", "Used when __init__ has all arguments typed " diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 05a52faab17..d8d3c76a028 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -6,7 +6,6 @@ import re from astroid import nodes from pylint.checkers import BaseChecker -from pylint.interfaces import IAstroidChecker from pylint.lint import PyLinter from homeassistant.const import Platform @@ -540,17 +539,15 @@ def _get_module_platform(module_name: str) -> str | None: class HassTypeHintChecker(BaseChecker): # type: ignore[misc] """Checker for setup type hints.""" - __implements__ = IAstroidChecker - name = "hass_enforce_type_hints" priority = -1 msgs = { - "W0020": ( + "W7431": ( "Argument %d should be of type %s", "hass-argument-type", "Used when method argument type is incorrect", ), - "W0021": ( + "W7432": ( "Return type should be %s", "hass-return-type", "Used when method return type is incorrect", diff --git a/pylint/plugins/hass_imports.py b/pylint/plugins/hass_imports.py index a8b3fa8fc76..cc160c1cfbd 100644 --- a/pylint/plugins/hass_imports.py +++ b/pylint/plugins/hass_imports.py @@ -6,7 +6,6 @@ import re from astroid import nodes from pylint.checkers import BaseChecker -from pylint.interfaces import IAstroidChecker from pylint.lint import PyLinter @@ -233,17 +232,15 @@ _OBSOLETE_IMPORT: dict[str, list[ObsoleteImportMatch]] = { class HassImportsFormatChecker(BaseChecker): # type: ignore[misc] """Checker for imports.""" - __implements__ = IAstroidChecker - name = "hass_imports" priority = -1 msgs = { - "W0011": ( + "W7421": ( "Relative import should be used", "hass-relative-import", "Used when absolute import should be replaced with relative import", ), - "W0012": ( + "W7422": ( "%s is deprecated, %s", "hass-deprecated-import", "Used when import is deprecated", diff --git a/pylint/plugins/hass_logger.py b/pylint/plugins/hass_logger.py index 125c927ec42..0135720a792 100644 --- a/pylint/plugins/hass_logger.py +++ b/pylint/plugins/hass_logger.py @@ -3,7 +3,6 @@ from __future__ import annotations from astroid import nodes from pylint.checkers import BaseChecker -from pylint.interfaces import IAstroidChecker from pylint.lint import PyLinter LOGGER_NAMES = ("LOGGER", "_LOGGER") @@ -13,17 +12,15 @@ LOG_LEVEL_ALLOWED_LOWER_START = ("debug",) class HassLoggerFormatChecker(BaseChecker): # type: ignore[misc] """Checker for logger invocations.""" - __implements__ = IAstroidChecker - name = "hass_logger" priority = -1 msgs = { - "W0001": ( + "W7401": ( "User visible logger messages must not end with a period", "hass-logger-period", "Periods are not permitted at the end of logger messages", ), - "W0002": ( + "W7402": ( "User visible logger messages must start with a capital letter or downgrade to debug", "hass-logger-capital", "All logger messages must start with a capital letter", diff --git a/pyproject.toml b/pyproject.toml index cc745f58ad6..cf5ac7a37c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ forced_separate = [ ] combine_as_imports = true -[tool.pylint.MASTER] +[tool.pylint.MAIN] py-version = "3.9" ignore = [ "tests", @@ -152,7 +152,6 @@ good-names = [ # too-many-ancestors - it's too strict. # wrong-import-order - isort guards this # consider-using-f-string - str.format sometimes more readable -# no-self-use - little added value with too many false-positives # --- # Enable once current issues are fixed: # consider-using-namedtuple-or-dataclass (Pylint CodeStyle extension) @@ -179,7 +178,6 @@ disable = [ "unused-argument", "wrong-import-order", "consider-using-f-string", - "no-self-use", "consider-using-namedtuple-or-dataclass", "consider-using-assignment-expr", ] diff --git a/requirements_test.txt b/requirements_test.txt index e888d715cd4..406ce96d50d 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -13,7 +13,7 @@ freezegun==1.2.1 mock-open==1.4.0 mypy==0.960 pre-commit==2.19.0 -pylint==2.13.9 +pylint==2.14.0 pipdeptree==2.2.1 pylint-strict-informational==0.1 pytest-aiohttp==0.3.0