@@ -303,8 +303,8 @@ def _parse_custom_tags(self) -> str:
303303
304304 # Innermost first parsing loop
305305 # We search for self-closing or container tags matching <[A-Z]
306- self_closing_rx = re .compile (r' <([A-Z][a-zA-Z0-9_]*)(?:\s+([^>]*?))?\s*\/>' )
307- container_rx = re .compile (r' <([A-Z][a-zA-Z0-9_]*)(?:\s+([^>]*?))?\s*>(.*?)</\1>' , re .DOTALL )
306+ self_closing_rx = re .compile (r" <([A-Z][a-zA-Z0-9_]*)(?:\s+([^>]*?))?\s*\/>" )
307+ container_rx = re .compile (r" <([A-Z][a-zA-Z0-9_]*)(?:\s+([^>]*?))?\s*>(.*?)</\1>" , re .DOTALL )
308308
309309 def parse_attributes (attrs_str : str ) -> dict [str , Any ]:
310310 if not attrs_str :
@@ -316,7 +316,7 @@ def parse_attributes(attrs_str: str) -> dict[str, Any]:
316316 for match in attr_rx .finditer (attrs_str ):
317317 name = match .group (1 )
318318 val_group = match .group (0 )
319- if '=' in val_group :
319+ if "=" in val_group :
320320 val = match .group (2 ) or match .group (3 ) or match .group (4 ) or ""
321321 else :
322322 val = True
@@ -338,16 +338,16 @@ def parse_attributes(attrs_str: str) -> dict[str, Any]:
338338 comp_id = f"{ tag_name } _{ tag_counts [tag_name ]} "
339339 self .custom_components [comp_id ] = instance
340340 replacement = f""
341- content = content [:match .start ()] + replacement + content [match .end ():]
341+ content = content [: match .start ()] + replacement + content [match .end () :]
342342 except Exception :
343343 # Validation failed (or other error), leave tag text
344344 # as is (mark temporarily)
345345 failed_marker = f"<__FAILED_SELF_{ tag_name } { attrs_str or '' } />"
346- content = content [:match .start ()] + failed_marker + content [match .end ():]
346+ content = content [: match .start ()] + failed_marker + content [match .end () :]
347347 else :
348348 # Tag name not registered in custom_tags, leave it as is
349349 failed_marker = f"<__FAILED_SELF_{ tag_name } { attrs_str or '' } />"
350- content = content [:match .start ()] + failed_marker + content [match .end ():]
350+ content = content [: match .start ()] + failed_marker + content [match .end () :]
351351 continue
352352
353353 # 2. Try to find the first container tag with no nested un-processed tags.
@@ -358,7 +358,7 @@ def parse_attributes(attrs_str: str) -> dict[str, Any]:
358358 # If inner_text contains '<[A-Z]', there is an inner un-processed tag. Skip for now.
359359 # Note: we exclude '<__FAILED_' markers as they are already processed/failed.
360360 # So we search for '<' followed by an uppercase letter: '<[A-Z]'
361- if re .search (r' <[A-Z]' , inner_text ):
361+ if re .search (r" <[A-Z]" , inner_text ):
362362 continue
363363 container_match = m
364364 break
@@ -376,17 +376,17 @@ def parse_attributes(attrs_str: str) -> dict[str, Any]:
376376 if isinstance (callable_obj , type ):
377377 sig = inspect .signature (callable_obj .__init__ )
378378 params = list (sig .parameters .keys ())
379- if ' self' in params :
380- params .remove (' self' )
379+ if " self" in params :
380+ params .remove (" self" )
381381 else :
382382 sig = inspect .signature (callable_obj )
383383 params = list (sig .parameters .keys ())
384384
385385 param_name = None
386- if ' children' in params :
387- param_name = ' children'
388- elif ' content' in params :
389- param_name = ' content'
386+ if " children" in params :
387+ param_name = " children"
388+ elif " content" in params :
389+ param_name = " content"
390390
391391 try :
392392 if param_name :
@@ -416,29 +416,29 @@ def parse_attributes(attrs_str: str) -> dict[str, Any]:
416416 self .custom_components [comp_id ] = instance
417417 replacement = f""
418418 content = (
419- content [:container_match .start ()]
419+ content [: container_match .start ()]
420420 + replacement
421- + content [container_match .end ():]
421+ + content [container_match .end () :]
422422 )
423423 except Exception :
424424 failed_marker = (
425425 f"<__FAILED_CONT_{ tag_name } { attrs_str or '' } >"
426426 f"{ inner_content } </__FAILED_CONT_{ tag_name } >"
427427 )
428428 content = (
429- content [:container_match .start ()]
429+ content [: container_match .start ()]
430430 + failed_marker
431- + content [container_match .end ():]
431+ + content [container_match .end () :]
432432 )
433433 else :
434434 failed_marker = (
435435 f"<__FAILED_CONT_{ tag_name } { attrs_str or '' } >"
436436 f"{ inner_content } </__FAILED_CONT_{ tag_name } >"
437437 )
438438 content = (
439- content [:container_match .start ()]
439+ content [: container_match .start ()]
440440 + failed_marker
441- + content [container_match .end ():]
441+ + content [container_match .end () :]
442442 )
443443 continue
444444
@@ -455,7 +455,7 @@ def parse_attributes(attrs_str: str) -> dict[str, Any]:
455455
456456 def _traversal_children (self ) -> "list[Component]" :
457457 children = super ()._traversal_children ()
458- if hasattr (self , ' custom_components' ) and self .custom_components :
458+ if hasattr (self , " custom_components" ) and self .custom_components :
459459 for comp in self .custom_components .values ():
460460 if isinstance (comp , Component ):
461461 children .append (comp )
0 commit comments