Skip to content

Commit

Permalink
Flatten nested ifs into if-elif
Browse files Browse the repository at this point in the history
This makes the control flow slightly easier to understand.
  • Loading branch information
pradyunsg committed Dec 7, 2022
1 parent 0e48461 commit d2a05d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packaging/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ def _parse_extras_list(tokenizer: Tokenizer) -> List[str]:

while True:
tokenizer.consume("WS")
if not tokenizer.check("COMMA"):
if tokenizer.check("IDENTIFIER", peek=True):
tokenizer.raise_syntax_error("Expected comma between extra names")
if tokenizer.check("IDENTIFIER", peek=True):
tokenizer.raise_syntax_error("Expected comma between extra names")
elif not tokenizer.check("COMMA"):
break

tokenizer.read()
tokenizer.consume("WS")

extra_token = tokenizer.expect("IDENTIFIER", expected="extra name after comma")
extras.append(extra_token.text)

Expand Down

0 comments on commit d2a05d6

Please sign in to comment.