mirror of
https://github.com/elisspace/core.git
synced 2026-09-29 22:09:55 +00:00
Generics and other type hint improvements (#45250)
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
"""Util to handle processes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
from typing import Any
|
||||
|
||||
# mypy: disallow-any-generics
|
||||
|
||||
|
||||
def kill_subprocess(process: subprocess.Popen) -> None:
|
||||
def kill_subprocess(
|
||||
# pylint: disable=unsubscriptable-object # https://github.com/PyCQA/pylint/issues/4034
|
||||
process: subprocess.Popen[Any],
|
||||
) -> None:
|
||||
"""Force kill a subprocess and wait for it to exit."""
|
||||
process.kill()
|
||||
process.communicate()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Unit system helper class and methods."""
|
||||
from numbers import Number
|
||||
from typing import Optional
|
||||
from typing import Dict, Optional
|
||||
|
||||
from homeassistant.const import (
|
||||
CONF_UNIT_SYSTEM_IMPERIAL,
|
||||
@@ -31,6 +31,8 @@ from homeassistant.util import (
|
||||
volume as volume_util,
|
||||
)
|
||||
|
||||
# mypy: disallow-any-generics
|
||||
|
||||
LENGTH_UNITS = distance_util.VALID_UNITS
|
||||
|
||||
MASS_UNITS = [MASS_POUNDS, MASS_OUNCES, MASS_KILOGRAMS, MASS_GRAMS]
|
||||
@@ -135,7 +137,7 @@ class UnitSystem:
|
||||
# type ignore: https://github.com/python/mypy/issues/7207
|
||||
return volume_util.convert(volume, from_unit, self.volume_unit) # type: ignore
|
||||
|
||||
def as_dict(self) -> dict:
|
||||
def as_dict(self) -> Dict[str, str]:
|
||||
"""Convert the unit system to a dictionary."""
|
||||
return {
|
||||
LENGTH: self.length_unit,
|
||||
|
||||
Reference in New Issue
Block a user