@@ -1088,34 +1088,33 @@ def expect_optional_token(lexer: Lexer, kind: TokenKind) -> Optional[Token]:
10881088 return None
10891089
10901090
1091- def expect_keyword (lexer : Lexer , value : str ) -> Token :
1091+ def expect_keyword (lexer : Lexer , value : str ) -> None :
10921092 """Expect the next token to be a given keyword.
10931093
1094- If the next token is a given keyword, return that token after advancing the lexer.
1094+ If the next token is a given keyword, advance the lexer.
10951095 Otherwise, do not change the parser state and throw an error.
10961096 """
10971097 token = lexer .token
10981098 if token .kind == TokenKind .NAME and token .value == value :
10991099 lexer .advance ()
1100- return token
1101-
1102- raise GraphQLSyntaxError (
1103- lexer .source , token .start , f"Expected { value !r} , found { token .desc } "
1104- )
1100+ else :
1101+ raise GraphQLSyntaxError (
1102+ lexer .source , token .start , f"Expected { value !r} , found { token .desc } "
1103+ )
11051104
11061105
1107- def expect_optional_keyword (lexer : Lexer , value : str ) -> Optional [ Token ] :
1106+ def expect_optional_keyword (lexer : Lexer , value : str ) -> bool :
11081107 """Expect the next token optionally to be a given keyword.
11091108
1110- If the next token is a given keyword, return that token after advancing the lexer.
1111- Otherwise, do not change the parser state and return None .
1109+ If the next token is a given keyword, return True after advancing the lexer.
1110+ Otherwise, do not change the parser state and return False .
11121111 """
11131112 token = lexer .token
11141113 if token .kind == TokenKind .NAME and token .value == value :
11151114 lexer .advance ()
1116- return token
1115+ return True
11171116
1118- return None
1117+ return False
11191118
11201119
11211120def unexpected (lexer : Lexer , at_token : Token = None ) -> GraphQLError :
0 commit comments