From 9d9495373f65817faab4aae241ddfc3b9b04aef1 Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Sat, 29 Jun 2024 10:43:49 +0100 Subject: [PATCH] mypy (remove TypeAlias) --- custom_components/ramses_cc/schemas.py | 6 +++--- tests/virtual_rf/virtual_rf.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/custom_components/ramses_cc/schemas.py b/custom_components/ramses_cc/schemas.py index ee221b1..8e4389a 100644 --- a/custom_components/ramses_cc/schemas.py +++ b/custom_components/ramses_cc/schemas.py @@ -5,7 +5,7 @@ import logging from copy import deepcopy from datetime import timedelta -from typing import Any, Final, TypeAlias +from typing import Any, Final, NewType import voluptuous as vol # type: ignore[import-untyped, unused-ignore] from homeassistant.const import CONF_SCAN_INTERVAL @@ -73,7 +73,7 @@ ZoneMode, ) -_SchemaT: TypeAlias = dict[str, Any] +_SchemaT = NewType("_SchemaT", dict[str, Any]) _LOGGER = logging.getLogger(__name__) @@ -154,7 +154,7 @@ def normalise_config(config: _SchemaT) -> tuple[str, _SchemaT, _SchemaT]: } broker_keys = (CONF_SCAN_INTERVAL, CONF_ADVANCED_FEATURES, SZ_RESTORE_CACHE) - return ( + return ( # type: ignore[return-value] port_name, {k: v for k, v in config.items() if k not in broker_keys} | {SZ_PORT_CONFIG: port_config}, diff --git a/tests/virtual_rf/virtual_rf.py b/tests/virtual_rf/virtual_rf.py index 603eead..f232a75 100644 --- a/tests/virtual_rf/virtual_rf.py +++ b/tests/virtual_rf/virtual_rf.py @@ -14,14 +14,14 @@ from collections import deque from io import FileIO from selectors import EVENT_READ, DefaultSelector -from typing import Any, Final, TypeAlias, TypedDict +from typing import Any, Final, NewType, TypedDict from serial import Serial, serial_for_url # type: ignore[import-untyped] from .const import HgiFwTypes -_FD: TypeAlias = int # file descriptor -_PN: TypeAlias = str # port name +_FD = NewType("_FD", int) # file descriptor +_PN = NewType("_PN", str) # port name # _FILEOBJ: TypeAlias = int | Any # int | HasFileno