@@ -46,10 +46,6 @@ class DispatchData:
4646 call_ast_ctx : AstEval | None = field (default = None , kw_only = True )
4747 hass_context : Context | None = field (default = None , kw_only = True )
4848
49- # Normally shouldn't be used.
50- exception : Exception | None = field (default = None , kw_only = True )
51- exception_text : str | None = field (default = None , kw_only = True )
52-
5349
5450class Decorator (ABC ):
5551 """Generic decorator abstraction."""
@@ -70,15 +66,10 @@ class Decorator(ABC):
7066 kwargs : dict [str , Any ]
7167
7268 @final
73- def __init__ (
74- self , raw_args : list [Any ], raw_kwargs : dict [str , Any ], lineno : int , col_offset : int
75- ) -> None :
69+ def __init__ (self , raw_args : list [Any ], raw_kwargs : dict [str , Any ]) -> None :
7670 """Initialize the decorator definition."""
77-
7871 self .raw_args = raw_args
7972 self .raw_kwargs = raw_kwargs
80- self .lineno = lineno
81- self .col_offset = col_offset
8273
8374 async def validate (self ) -> None :
8475 """Validate the arguments."""
@@ -106,12 +97,10 @@ async def validate(self) -> None:
10697 )
10798 raise type_error from err
10899
109- @abstractmethod
110- async def start (self ):
100+ async def start (self ): # noqa: B027
111101 """Start the decorator."""
112102
113- @abstractmethod
114- async def stop (self ):
103+ async def stop (self ): # noqa: B027
115104 """Stop the decorator."""
116105
117106 def __repr__ (self ):
@@ -136,9 +125,6 @@ def __init__(self, ast_ctx: AstEval, name: str) -> None:
136125 self .func_name = name .split ("." )[- 1 ]
137126 self .logger = ast_ctx .get_logger ()
138127
139- self .lineno = ast_ctx .lineno
140- self .col_offset = ast_ctx .col_offset
141-
142128 self .status : DecoratorManagerStatus = DecoratorManagerStatus .INIT
143129 self .startup_time = None
144130 self ._decorators : list [Decorator ] = []
@@ -167,19 +153,14 @@ def get_decorators[DT](self, decorator_type: type[DT] | None = None) -> list[DT]
167153
168154 async def validate (self ) -> None :
169155 """Validate all decorators."""
170- lineno , col_offset = self .ast_ctx .lineno , self .ast_ctx .col_offset
171156 try :
172157 for decorator in self ._decorators :
173- self .ast_ctx .lineno , self .ast_ctx .col_offset = decorator .lineno , decorator .col_offset
174158 _LOGGER .debug ("Validating decorator: %s" , decorator )
175- self .lineno , self .col_offset = decorator .lineno , decorator .col_offset
176159 await decorator .validate ()
177160 except Exception :
178161 self .update_status (DecoratorManagerStatus .INVALID )
179162 raise
180163
181- self .ast_ctx .lineno , self .ast_ctx .col_offset = lineno , col_offset
182-
183164 if len (self ._decorators ) == 0 :
184165 self .update_status (DecoratorManagerStatus .NO_DECORATORS )
185166 else :
@@ -224,6 +205,10 @@ async def stop(self):
224205
225206 self .update_status (DecoratorManagerStatus .STOPPED )
226207
208+ async def handle_exception (self , exc : Exception ) -> None :
209+ """Handle a decorator exception."""
210+ self .ast_ctx .log_exception (exc )
211+
227212 @abstractmethod
228213 async def dispatch (self , data : DispatchData ) -> None :
229214 """Dispatch a trigger call."""
0 commit comments