Debian Codegraph @

jedi/third_party/typeshed/stdlib/tokenize.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import FileDescriptorOrPath
3 from collections.abc import Callable, Generator, Iterable, Sequence
4 from re import Pattern
5 from token import *
6 from typing import Any, Final, NamedTuple, TextIO, type_check_only
7 from typing_extensions import TypeAlias, disjoint_base
8
9 if sys.version_info < (3, 12):
10 # Avoid double assignment to Final name by imports, which pyright objects to.
11 # EXACT_TOKEN_TYPES is already defined by 'from token import *' above
12 # in Python 3.12+.
13 from token import EXACT_TOKEN_TYPES as EXACT_TOKEN_TYPES
14
15 __all__ = [
16 "AMPER",
17 "AMPEREQUAL",
18 "AT",
19 "ATEQUAL",
20 "CIRCUMFLEX",
21 "CIRCUMFLEXEQUAL",
22 "COLON",
23 "COLONEQUAL",
24 "COMMA",
25 "COMMENT",
26 "DEDENT",
27 "DOT",
28 "DOUBLESLASH",
29 "DOUBLESLASHEQUAL",
30 "DOUBLESTAR",
31 "DOUBLESTAREQUAL",
32 "ELLIPSIS",
33 "ENCODING",
34 "ENDMARKER",
35 "EQEQUAL",
36 "EQUAL",
37 "ERRORTOKEN",
38 "GREATER",
39 "GREATEREQUAL",
40 "INDENT",
41 "ISEOF",
42 "ISNONTERMINAL",
43 "ISTERMINAL",
44 "LBRACE",
45 "LEFTSHIFT",
46 "LEFTSHIFTEQUAL",
47 "LESS",
48 "LESSEQUAL",
49 "LPAR",
50 "LSQB",
51 "MINEQUAL",
52 "MINUS",
53 "NAME",
54 "NEWLINE",
55 "NL",
56 "NOTEQUAL",
57 "NT_OFFSET",
58 "NUMBER",
59 "N_TOKENS",
60 "OP",
61 "PERCENT",
62 "PERCENTEQUAL",
63 "PLUS",
64 "PLUSEQUAL",
65 "RARROW",
66 "RBRACE",
67 "RIGHTSHIFT",
68 "RIGHTSHIFTEQUAL",
69 "RPAR",
70 "RSQB",
71 "SEMI",
72 "SLASH",
73 "SLASHEQUAL",
74 "STAR",
75 "STAREQUAL",
76 "STRING",
77 "TILDE",
78 "TYPE_COMMENT",
79 "TYPE_IGNORE",
80 "TokenInfo",
81 "VBAR",
82 "VBAREQUAL",
83 "detect_encoding",
84 "generate_tokens",
85 "tok_name",
86 "tokenize",
87 "untokenize",
88 ]
89 if sys.version_info < (3, 13):
90 __all__ += ["ASYNC", "AWAIT"]
91
92 if sys.version_info >= (3, 10):
93 __all__ += ["SOFT_KEYWORD"]
94
95 if sys.version_info >= (3, 12):
96 __all__ += ["EXCLAMATION", "FSTRING_END", "FSTRING_MIDDLE", "FSTRING_START", "EXACT_TOKEN_TYPES"]
97
98 if sys.version_info >= (3, 13):
99 __all__ += ["TokenError", "open"]
100
101 if sys.version_info >= (3, 14):
102 __all__ += ["TSTRING_START", "TSTRING_MIDDLE", "TSTRING_END"]
103
104 cookie_re: Final[Pattern[str]]
105 blank_re: Final[Pattern[bytes]]
106
107 _Position: TypeAlias = tuple[int, int]
108
109 # This class is not exposed. It calls itself tokenize.TokenInfo.
110 @type_check_only
111 class _TokenInfo(NamedTuple):
112 type: int
113 string: str
114 start: _Position
115 end: _Position
116 line: str
117
118 if sys.version_info >= (3, 12):
119 class TokenInfo(_TokenInfo):
120 @property
121 def exact_type(self) -> int: ...
122
123 else:
124 @disjoint_base
125 class TokenInfo(_TokenInfo):
126 @property
127 def exact_type(self) -> int: ...
128
129 # Backwards compatible tokens can be sequences of a shorter length too
130 _Token: TypeAlias = TokenInfo | Sequence[int | str | _Position]
131
132 class TokenError(Exception): ...
133
134 if sys.version_info < (3, 13):
135 class StopTokenizing(Exception): ... # undocumented
136
137 class Untokenizer:
138 tokens: list[str]
139 prev_row: int
140 prev_col: int
141 encoding: str | None
142 def add_whitespace(self, start: _Position) -> None: ...
143 if sys.version_info >= (3, 12):
144 def add_backslash_continuation(self, start: _Position) -> None: ...
145
146 def untokenize(self, iterable: Iterable[_Token]) -> str: ...
147 def compat(self, token: Sequence[int | str], iterable: Iterable[_Token]) -> None: ...
148 if sys.version_info >= (3, 12):
149 def escape_brackets(self, token: str) -> str: ...
150
151 # Returns str, unless the ENCODING token is present, in which case it returns bytes.
152 def untokenize(iterable: Iterable[_Token]) -> str | Any: ...
153 def detect_encoding(readline: Callable[[], bytes | bytearray]) -> tuple[str, Sequence[bytes]]: ...
154 def tokenize(readline: Callable[[], bytes | bytearray]) -> Generator[TokenInfo]: ...
155 def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo]: ...
156 def open(filename: FileDescriptorOrPath) -> TextIO: ...
157 def group(*choices: str) -> str: ... # undocumented
158 def any(*choices: str) -> str: ... # undocumented
159 def maybe(*choices: str) -> str: ... # undocumented
160
161 Whitespace: Final[str] # undocumented
162 Comment: Final[str] # undocumented
163 Ignore: Final[str] # undocumented
164 Name: Final[str] # undocumented
165
166 Hexnumber: Final[str] # undocumented
167 Binnumber: Final[str] # undocumented
168 Octnumber: Final[str] # undocumented
169 Decnumber: Final[str] # undocumented
170 Intnumber: Final[str] # undocumented
171 Exponent: Final[str] # undocumented
172 Pointfloat: Final[str] # undocumented
173 Expfloat: Final[str] # undocumented
174 Floatnumber: Final[str] # undocumented
175 Imagnumber: Final[str] # undocumented
176 Number: Final[str] # undocumented
177
178 def _all_string_prefixes() -> set[str]: ... # undocumented
179
180 StringPrefix: Final[str] # undocumented
181
182 Single: Final[str] # undocumented
183 Double: Final[str] # undocumented
184 Single3: Final[str] # undocumented
185 Double3: Final[str] # undocumented
186 Triple: Final[str] # undocumented
187 String: Final[str] # undocumented
188
189 Special: Final[str] # undocumented
190 Funny: Final[str] # undocumented
191
192 PlainToken: Final[str] # undocumented
193 Token: Final[str] # undocumented
194
195 ContStr: Final[str] # undocumented
196 PseudoExtras: Final[str] # undocumented
197 PseudoToken: Final[str] # undocumented
198
199 endpats: Final[dict[str, str]] # undocumented
200 single_quoted: Final[set[str]] # undocumented
201 triple_quoted: Final[set[str]] # undocumented
202
203 tabsize: Final = 8 # undocumented