<s> from ... error import GraphQLError <EOL> from ... language import ast <EOL> from . base import ValidationRule <EOL> class LoneAnonymousOperation ( ValidationRule ) : <EOL> __slots__ = '<STR_LIT>' , <EOL> def __init__ ( self , context ) : <EOL> self . operation_count = <NUM_LIT:0> <EOL> super ( LoneAnonymousOperation , self ) . __init__ ( context ) <EOL> def enter_Document ( self , node , key , parent , path , ancestors ) : <EOL> self . operation_count = sum ( <NUM_LIT:1> for definition in node . definitions if isinstance ( definition , ast . OperationDefinition ) ) <EOL> def enter_OperationDefinition ( self , node , key , parent , path , ancestors ) : <EOL> if not node . name and self . operation_count > <NUM_LIT:1> : <EOL> self . context . report_error ( GraphQLError ( self . anonymous_operation_not_alone_message ( ) , [ node ] ) ) <EOL> @ staticmethod <EOL> def anonymous_operation_not_alone_message ( ) : <EOL> return '<STR_LIT>' </s>
