From a90ef488a1e619cc790a1180268cbb2801fe2f15 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 30 Nov 2021 16:26:02 +0100 Subject: [PATCH] Add return type annotation to StrEnum (#60624) --- homeassistant/util/enum.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/util/enum.py b/homeassistant/util/enum.py index 8bd01fa9ede..2ebd1678138 100644 --- a/homeassistant/util/enum.py +++ b/homeassistant/util/enum.py @@ -2,13 +2,15 @@ from __future__ import annotations from enum import Enum -from typing import Any +from typing import Any, TypeVar + +T = TypeVar("T", bound="StrEnum") class StrEnum(str, Enum): """Partial backport of Python 3.11's StrEnum for our basic use cases.""" - def __new__(cls, value: str, *args: Any, **kwargs: Any): # type: ignore[no-untyped-def] + def __new__(cls: type[T], value: str, *args: Any, **kwargs: Any) -> T: """Create a new StrEnum instance.""" if not isinstance(value, str): raise TypeError(f"{value!r} is not a string")