@@ -61,13 +61,14 @@ def add_handler(
6161 self ,
6262 path : Tuple [str , ...],
6363 handler : object ,
64+ * ,
6465 ignore_direct_marks : bool ,
6566 ) -> None :
6667 # marked
6768 marks = () if ignore_direct_marks else get_marks (handler )
6869 if marks :
6970 for mark in marks :
70- self .add_handler (path + mark , handler , True )
71+ self .add_handler (path + mark , handler , ignore_direct_marks = True )
7172 return
7273
7374 # callable
@@ -81,7 +82,7 @@ def add_handler(
8182 if handler_name .startswith ("__" ):
8283 continue
8384 for sub_path in get_marks (sub_handler ):
84- self .add_handler (path + sub_path , sub_handler , True )
85+ self .add_handler (path + sub_path , sub_handler , ignore_direct_marks = True )
8586 found = True
8687 if found :
8788 return
@@ -95,7 +96,7 @@ def add_handler(
9596 self .add_handler (
9697 path + handler ,
9798 _handler_identity ,
98- True , # does not matter as _handler_identity has no marks
99+ ignore_direct_marks = True , # does not matter as _handler_identity has no marks
99100 )
100101 return
101102
@@ -111,8 +112,10 @@ def add_handler_callable(
111112 raise TypeError (f"{ self .path } : catchall handler exists: { self .handler } " )
112113 if path :
113114 if path [0 ] not in self .children :
114- self .children [path [0 ]] = _HandlerTree (self .path + (path [0 ],))
115- self .children [path [0 ]].add_handler (path [1 :], handler , True )
115+ self .children [path [0 ]] = _HandlerTree ((* self .path , path [0 ]))
116+ self .children [path [0 ]].add_handler (
117+ path [1 :], handler , ignore_direct_marks = True
118+ )
116119 elif self .children :
117120 raise TypeError (f"{ self .path } : handlers exist: { self .children } " )
118121 else :
@@ -162,7 +165,7 @@ def _handle_from_class( # type: ignore[misc]
162165 sub_tree = _HandlerTree ()
163166 items : Iterable [object ] = () # empty iterable
164167 try :
165- sub_tree .add_handler ((), instance , True )
168+ sub_tree .add_handler ((), instance , ignore_direct_marks = True )
166169 except TypeError :
167170 pass # no marks on public attributes
168171 else :
@@ -205,7 +208,7 @@ def _handle_from_class( # type: ignore[misc]
205208 f" Create a { CLASS_HANDLER_METHOD_NAME } "
206209 " method to handle them properly."
207210 )
208- warnings .warn (warning_msg , UserWarning )
211+ warnings .warn (warning_msg , UserWarning , stacklevel = 1 )
209212
210213 if wrapper is None :
211214 # no custom wrapper: only yield instance
@@ -218,5 +221,5 @@ def create_handler(
218221) -> Callable [[Union ["XMLElement" , "XMLText" ]], Iterator [object ]]:
219222 handler_tree = _HandlerTree ()
220223 for arg in args :
221- handler_tree .add_handler ((), arg , False )
224+ handler_tree .add_handler ((), arg , ignore_direct_marks = False )
222225 return handler_tree .handle
0 commit comments