diff --git a/homeassistant/components/azure_event_hub/__init__.py b/homeassistant/components/azure_event_hub/__init__.py index 52e07063569..743463abda5 100644 --- a/homeassistant/components/azure_event_hub/__init__.py +++ b/homeassistant/components/azure_event_hub/__init__.py @@ -139,7 +139,7 @@ class AzureEventHub: self._max_delay = self._entry.options.get(CONF_MAX_DELAY, DEFAULT_MAX_DELAY) self._shutdown = False - self._queue: asyncio.PriorityQueue[ # pylint: disable=unsubscriptable-object + self._queue: asyncio.PriorityQueue[ tuple[int, tuple[datetime, State | None]] ] = asyncio.PriorityQueue() self._listener_remover: Callable[[], None] | None = None diff --git a/homeassistant/components/homewizard/config_flow.py b/homeassistant/components/homewizard/config_flow.py index 50a01980308..7544071a154 100644 --- a/homeassistant/components/homewizard/config_flow.py +++ b/homeassistant/components/homewizard/config_flow.py @@ -154,7 +154,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): _LOGGER.error("API disabled, API must be enabled in the app") raise AbortFlow("api_not_enabled") from ex - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: _LOGGER.error( "Error connecting with Energy Device at %s", ip_address, diff --git a/homeassistant/components/homewizard/coordinator.py b/homeassistant/components/homewizard/coordinator.py index bad24f11f1f..c5e8953b7f1 100644 --- a/homeassistant/components/homewizard/coordinator.py +++ b/homeassistant/components/homewizard/coordinator.py @@ -50,7 +50,7 @@ class HWEnergyDeviceUpdateCoordinator( "API disabled, API must be enabled in the app" ) from ex - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: raise UpdateFailed( f"Error connecting with Energy Device at {self.api.host}" ) from ex @@ -82,7 +82,7 @@ class HWEnergyDeviceUpdateCoordinator( except aiohwenergy.AiohwenergyException as ex: raise UpdateFailed("Unknown Energy API error occurred") from ex - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: raise UpdateFailed( f"Unknown error connecting with Energy Device at {self.api.host}" ) from ex diff --git a/homeassistant/components/lupusec/__init__.py b/homeassistant/components/lupusec/__init__.py index 25f8d0a0731..fd55f0b4d9a 100644 --- a/homeassistant/components/lupusec/__init__.py +++ b/homeassistant/components/lupusec/__init__.py @@ -1,5 +1,4 @@ """Support for Lupusec Home Security system.""" -# pylint: disable=import-error import logging import lupupy diff --git a/homeassistant/components/lupusec/binary_sensor.py b/homeassistant/components/lupusec/binary_sensor.py index 2734b9b4d0c..2c6e7b2fff8 100644 --- a/homeassistant/components/lupusec/binary_sensor.py +++ b/homeassistant/components/lupusec/binary_sensor.py @@ -1,7 +1,6 @@ """Support for Lupusec Security System binary sensors.""" from __future__ import annotations -# pylint: disable=import-error from datetime import timedelta import lupupy.constants as CONST diff --git a/homeassistant/components/lupusec/switch.py b/homeassistant/components/lupusec/switch.py index e58b53aac39..4b5f38a81b3 100644 --- a/homeassistant/components/lupusec/switch.py +++ b/homeassistant/components/lupusec/switch.py @@ -1,7 +1,6 @@ """Support for Lupusec Security System switches.""" from __future__ import annotations -# pylint: disable=import-error from datetime import timedelta import lupupy.constants as CONST diff --git a/homeassistant/core.py b/homeassistant/core.py index fb0b244c23b..3b0bac63815 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -240,7 +240,6 @@ class HomeAssistant: def __init__(self) -> None: """Initialize new Home Assistant object.""" self.loop = asyncio.get_running_loop() - # pylint: disable-next=unsubscriptable-object self._pending_tasks: list[asyncio.Future[Any]] = [] self._track_task = True self.bus = EventBus(self) @@ -363,21 +362,21 @@ class HomeAssistant: @callback def async_add_job( self, target: Callable[..., Awaitable[_R]], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @overload @callback def async_add_job( self, target: Callable[..., Awaitable[_R] | _R], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @overload @callback def async_add_job( self, target: Coroutine[Any, Any, _R], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @callback @@ -385,7 +384,7 @@ class HomeAssistant: self, target: Callable[..., Awaitable[_R] | _R] | Coroutine[Any, Any, _R], *args: Any, - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: """Add a job to be executed by the event loop or by an executor. If the job is either a coroutine or decorated with @callback, it will be @@ -409,27 +408,27 @@ class HomeAssistant: @callback def async_add_hass_job( self, hassjob: HassJob[Awaitable[_R]], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @overload @callback def async_add_hass_job( self, hassjob: HassJob[Awaitable[_R] | _R], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @callback def async_add_hass_job( self, hassjob: HassJob[Awaitable[_R] | _R], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: """Add a HassJob from within the event loop. This method must be run in the event loop. hassjob: HassJob to call. args: parameters for method to call. """ - task: asyncio.Future[_R] # pylint: disable=unsubscriptable-object + task: asyncio.Future[_R] if hassjob.job_type == HassJobType.Coroutinefunction: task = self.loop.create_task( cast(Callable[..., Awaitable[_R]], hassjob.target)(*args) @@ -473,7 +472,7 @@ class HomeAssistant: @callback def async_add_executor_job( self, target: Callable[..., T], *args: Any - ) -> asyncio.Future[T]: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[T]: """Add an executor job from within the event loop.""" task = self.loop.run_in_executor(None, target, *args) @@ -497,20 +496,20 @@ class HomeAssistant: @callback def async_run_hass_job( self, hassjob: HassJob[Awaitable[_R]], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @overload @callback def async_run_hass_job( self, hassjob: HassJob[Awaitable[_R] | _R], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @callback def async_run_hass_job( self, hassjob: HassJob[Awaitable[_R] | _R], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: """Run a HassJob from within the event loop. This method must be run in the event loop. @@ -528,21 +527,21 @@ class HomeAssistant: @callback def async_run_job( self, target: Callable[..., Awaitable[_R]], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @overload @callback def async_run_job( self, target: Callable[..., Awaitable[_R] | _R], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @overload @callback def async_run_job( self, target: Coroutine[Any, Any, _R], *args: Any - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: ... @callback @@ -550,7 +549,7 @@ class HomeAssistant: self, target: Callable[..., Awaitable[_R] | _R] | Coroutine[Any, Any, _R], *args: Any, - ) -> asyncio.Future[_R] | None: # pylint: disable=unsubscriptable-object + ) -> asyncio.Future[_R] | None: """Run a job from within the event loop. This method must be run in the event loop. diff --git a/homeassistant/util/async_.py b/homeassistant/util/async_.py index bf7250b68e6..8eb4b31fdac 100644 --- a/homeassistant/util/async_.py +++ b/homeassistant/util/async_.py @@ -41,7 +41,7 @@ def fire_coroutine_threadsafe(coro: Coroutine, loop: AbstractEventLoop) -> None: def run_callback_threadsafe( loop: AbstractEventLoop, callback: Callable[..., T], *args: Any -) -> concurrent.futures.Future[T]: # pylint: disable=unsubscriptable-object +) -> concurrent.futures.Future[T]: """Submit a callback object to a given event loop. Return a concurrent.futures.Future to access the result. diff --git a/homeassistant/util/process.py b/homeassistant/util/process.py index f89b2eb96ee..832ef450dca 100644 --- a/homeassistant/util/process.py +++ b/homeassistant/util/process.py @@ -8,10 +8,7 @@ from typing import Any # mypy: disallow-any-generics -def kill_subprocess( - # pylint: disable=unsubscriptable-object # https://github.com/PyCQA/pylint/issues/4369 - process: subprocess.Popen[Any], -) -> None: +def kill_subprocess(process: subprocess.Popen[Any]) -> None: """Force kill a subprocess and wait for it to exit.""" process.kill() process.communicate() diff --git a/pyproject.toml b/pyproject.toml index d5be195d2b2..a2d7a8721b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ forced_separate = [ combine_as_imports = true [tool.pylint.MASTER] -py-version = "3.8" +py-version = "3.9" ignore = [ "tests", ] @@ -76,6 +76,7 @@ good-names = [ # Enable once current issues are fixed: # consider-using-namedtuple-or-dataclass (Pylint CodeStyle extension) # consider-using-assignment-expr (Pylint CodeStyle extension) +# deprecated-typing-alias (temporarily while updating code to Python 3.9) disable = [ "format", "abstract-class-little-used", @@ -101,6 +102,7 @@ disable = [ "consider-using-f-string", "consider-using-namedtuple-or-dataclass", "consider-using-assignment-expr", + "deprecated-typing-alias", ] enable = [ #"useless-suppression", # temporarily every now and then to clean them up