Skip to content

Commit

Permalink
Update Python version used for pylint (home-assistant#63895)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Jan 11, 2022
1 parent 277c12c commit f3bc9fc
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 30 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/azure_event_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(
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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homewizard/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ async def _async_try_connect_and_fetch(ip_address: str) -> dict[str, Any]:
_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,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/homewizard/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def _async_update_data(self) -> DeviceResponseEntry:
"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
Expand Down Expand Up @@ -82,7 +82,7 @@ async def initialize_api(self) -> aiohwenergy:
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
1 change: 0 additions & 1 deletion homeassistant/components/lupusec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Support for Lupusec Home Security system."""
# pylint: disable=import-error
import logging

import lupupy
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/lupusec/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/lupusec/switch.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 16 additions & 17 deletions homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -363,29 +362,29 @@ def add_job(self, target: Callable[..., Any], *args: Any) -> None:
@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
def async_add_job(
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
Expand All @@ -409,27 +408,27 @@ def async_add_job(
@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)
Expand Down Expand Up @@ -473,7 +472,7 @@ def async_create_task(self, target: Awaitable[_R]) -> asyncio.Task[_R]:
@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)

Expand All @@ -497,20 +496,20 @@ def async_stop_track_tasks(self) -> None:
@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.
Expand All @@ -528,29 +527,29 @@ def async_run_hass_job(
@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
def async_run_job(
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.
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/util/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def callback() -> 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.
Expand Down
5 changes: 1 addition & 4 deletions homeassistant/util/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
# 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()
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ forced_separate = [
combine_as_imports = true

[tool.pylint.MASTER]
py-version = "3.8"
py-version = "3.9"
ignore = [
"tests",
]
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit f3bc9fc

Please sign in to comment.