@@ -528,12 +528,10 @@ def __init__(
528528 def validate_list_tokens (self ) -> None :
529529 """Lint the list parser."""
530530
531- missing_root = self ._check_missing_root ()
532- self ._check_list_query_missing_operator_nodes (missing_root )
531+ self ._check_missing_root ()
533532 self ._check_list_query_invalid_reference ()
534533
535- def _check_missing_root (self ) -> bool :
536- missing_root = False
534+ def _check_missing_root (self ) -> None :
537535 root_node_content : str = str (
538536 list (self .parser .query_dict .values ())[- 1 ]["node_content" ]
539537 )
@@ -546,45 +544,24 @@ def _check_missing_root(self) -> bool:
546544 details = "The last item of the list must be a combining string." ,
547545 fatal = True ,
548546 )
549- missing_root = True
550- return missing_root
551-
552- def _check_list_query_missing_operator_nodes (self , missing_root : bool ) -> None :
553- if missing_root :
554- return
555- # require combining list items
556- if not any (
557- "#" in str (query ["node_content" ])
558- for query in self .parser .query_dict .values ()
559- ):
560- # If there is no combining list item, raise a linter exception
561- # Individual list items can not be connected
562- # raise ValueError("[ERROR] No combining list item found.")
563- self .add_message (
564- QueryErrorCode .LIST_QUERY_MISSING_OPERATOR_NODES ,
565- list_position = GENERAL_ERROR_POSITION ,
566- positions = [],
567- fatal = True ,
568- )
569547
570548 def _check_list_query_invalid_reference (self ) -> None :
571549 # check if all list-references exist
572550 for ind , query_node in enumerate (self .parser .query_dict .values ()):
573- if "#" in str (query_node ["node_content" ]):
574- # check if all list references exist
575- for match in re .finditer (
576- self .parser .LIST_ITEM_REFERENCE ,
577- str (query_node ["node_content" ]),
578- ):
579- reference = match .group ()
580- position = match .span ()
581- offset = query_node ["content_pos" ][0 ]
582- position = (position [0 ] + offset , position [1 ] + offset )
583- if reference .replace ("#" , "" ) not in self .parser .query_dict :
584- self .add_message (
585- QueryErrorCode .LIST_QUERY_INVALID_REFERENCE ,
586- list_position = ind ,
587- positions = [position ],
588- details = f"List reference { reference } not found." ,
589- fatal = True ,
590- )
551+ # check if all list references exist
552+ for match in re .finditer (
553+ self .parser .LIST_ITEM_REFERENCE ,
554+ str (query_node ["node_content" ]),
555+ ):
556+ reference = match .group ()
557+ position = match .span ()
558+ offset = query_node ["content_pos" ][0 ]
559+ position = (position [0 ] + offset , position [1 ] + offset )
560+ if reference .replace ("#" , "" ) not in self .parser .query_dict :
561+ self .add_message (
562+ QueryErrorCode .LIST_QUERY_INVALID_REFERENCE ,
563+ list_position = ind ,
564+ positions = [position ],
565+ details = f"List reference { reference } not found." ,
566+ fatal = True ,
567+ )
0 commit comments