MCPcopy Index your code
hub / github.com/python/cpython / peek

Method peek

Tools/peg_generator/pegen/tokenizer.py:47–64  ·  view source on GitHub ↗

Return the next token *without* updating the index.

(self)

Source from the content-addressed store, hash-verified

45 return tok
46
47 def peek(self) -> tokenize.TokenInfo:
48 """Return the next token *without* updating the index."""
49 while self._index == len(self._tokens):
50 tok = next(self._tokengen)
51 if tok.type in (tokenize.NL, tokenize.COMMENT):
52 continue
53 if tok.type == token.ERRORTOKEN and tok.string.isspace():
54 continue
55 if (
56 tok.type == token.NEWLINE
57 and self._tokens
58 and self._tokens[-1].type == token.NEWLINE
59 ):
60 continue
61 self._tokens.append(tok)
62 if not self._path:
63 self._lines[tok.start[0]] = tok.line
64 return self._tokens[self._index]
65
66 def diagnose(self) -> tokenize.TokenInfo:
67 if not self._tokens:

Callers 12

getnextMethod · 0.95
showpeekMethod · 0.45
nameMethod · 0.45
numberMethod · 0.45
stringMethod · 0.45
fstring_startMethod · 0.45
fstring_middleMethod · 0.45
fstring_endMethod · 0.45
opMethod · 0.45
type_commentMethod · 0.45
soft_keywordMethod · 0.45
expectMethod · 0.45

Calls 2

isspaceMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected