mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 20:40:18 +00:00
Use singleton enum for "not set" sentinels (#41990)
* Use singleton enum for "not set" sentinel https://www.python.org/dev/peps/pep-0484/#support-for-singleton-types-in-unions * Remove unused variable
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Typing Helpers for Home Assistant."""
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, Mapping, Optional, Tuple, Union
|
||||
|
||||
import homeassistant.core
|
||||
@@ -16,3 +17,12 @@ TemplateVarsType = Optional[Mapping[str, Any]]
|
||||
|
||||
# Custom type for recorder Queries
|
||||
QueryType = Any
|
||||
|
||||
|
||||
class UndefinedType(Enum):
|
||||
"""Singleton type for use with not set sentinel values."""
|
||||
|
||||
_singleton = 0
|
||||
|
||||
|
||||
UNDEFINED = UndefinedType._singleton # pylint: disable=protected-access
|
||||
|
||||
Reference in New Issue
Block a user