Skip to content

Commit

Permalink
Add template method: typeof (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Jan 2, 2024
1 parent 6dd049b commit dae618a
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Spook - Not your homie."""
from __future__ import annotations

from typing import TYPE_CHECKING, Any

from ....templating import AbstractSpookTemplateFunction

if TYPE_CHECKING:
from collections.abc import Callable


class SpookTemplateFunction(AbstractSpookTemplateFunction):
"""Spook template function to debug types."""

name = "typeof"

requires_hass_object = False
is_available_in_limited_environment = True
is_filter = True
is_global = True

def function(self) -> Callable[..., Any]:
"""Return the python method that runs this template function."""
return lambda o: o.__class__.__name__

0 comments on commit dae618a

Please sign in to comment.